World Kindness Day Web App Setup
Set up and run the companion web app of the World Kindness Day sample, which shows the pledge total from Snap Cloud that a SPECS Lens updates.
- Snapchat: not supported
- SPECS: fully supported
- Camera Kit Web: not supported
- Camera Kit Mobile: not supported
- SnapchatNot supported
- SPECSFully supported
- Camera Kit WebNot supported
- Camera Kit MobileNot supported
The World Kindness Day web app shows the global pledge total that the World Kindness Day Lens updates. It reads the total from your Snap Cloud project.
The web app needs a working Snap Cloud backend. Create your own Snap Cloud project and its tables, functions, and permissions first: see World Kindness Day Snap Cloud Setup. Then return here to connect the web app to it.
Download the web app ZIP.
What's in the World Kindness Day web app ZIP
index.html
- Defines the structure of the page.
- Shows the live global pledge count.
- Loads the CSS and JavaScript files.
- Uses no frameworks: plain HTML.
styles.css
- Contains all the layout and styling rules.
- Handles the sky background, the balloon visuals, the fonts, and responsive behavior.
- Change colors, spacing, and animation timing here.
app.js
The main application logic:
- Connects to Snap Cloud and retrieves the total number of pledges.
- Updates the page in real time when the database changes.
- Calls the RPC function
get_kindness_total_all().
config.js
Holds your Snap Cloud project URL and anon public key, which keeps credentials separate from the app's logic.
Add your Snap Cloud project keys to config.js
-
In the Snap Cloud dashboard, open Project Settings.
-
Under Data API, copy the project URL.
-
Under API Keys, copy the anon public key.
-
Open
config.jsand replace the placeholders with your values:export const SUPABASE_URL = 'YOUR_SUPABASE_URL';export const SUPABASE_ANON_KEY = 'YOUR_PUBLIC_ANON_KEY';
In some versions of the dashboard both values are on one page, Project Settings > API, as Project URL and anon public key.
Run the World Kindness Day web app locally
Any static file server works. Here are two options, depending on what you have installed.
Serve the web app with Python
-
Open a terminal in the web app folder:
cd path/to/webapp -
Start a local server:
python3 -m http.server 8000 -
In your browser, open
http://localhost:8000.
Serve the web app with Node.js
-
Install the
servepackage and start it in the web app folder:npm install -g serveserve . -
Open the link printed in the terminal.
Once the server is running and your project keys are in config.js, the app shows the live total number of pledges.
Related
- World Kindness Day Snap Cloud Setup: the backend the web app reads.
- World Kindness Day Lens Setup: the Lens that writes the pledges.
- World Kindness Day Lens & Web App: how the pieces fit together.