Skip to main content

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

Platform details

  • Snapchat — Not supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Not supported.

  • Camera Kit Mobile — Not 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

  1. In the Snap Cloud dashboard, open Project Settings.

  2. Under Data API, copy the project URL.

  3. Under API Keys, copy the anon public key.

  4. Open config.js and 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

  1. Open a terminal in the web app folder:

    cd path/to/webapp
  2. Start a local server:

    python3 -m http.server 8000
  3. In your browser, open http://localhost:8000.

Serve the web app with Node.js

  1. Install the serve package and start it in the web app folder:

    npm install -g serve
    serve .
  2. 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.