World Kindness Day Lens & Web App
Connect a SPECS Lens to a companion web app through Snap Cloud with the World Kindness Day sample: the Lens writes pledges, the web app shows the total.
- 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 sample connects a SPECS Lens and a companion web app through one Snap Cloud project. When a user chooses a balloon and speaks their pledge in the Lens, the Lens writes a record to the Snap Cloud database. The global pledge counter in the web app then updates without a page refresh.
Why the Lens and web app pattern matters
Many SPECS experiences need some form of persistence: saving user actions, syncing state across users, or showing information outside the Lens. This sample keeps the integration minimal, so you can use it as a reference, a starting point, or a learning resource.
Use it to:
- Understand how a Lens writes data to Snap Cloud securely.
- Learn how to query that data back with RPC functions.
- See how a web client reads the same data.
- Get a working pattern to adapt for your own projects.
The pattern, Lens writes, Snap Cloud stores, web app reads, applies to any experience that needs a live public counter, a shared map, a multiplayer leaderboard overlay, or other persistent state across devices.
How the World Kindness Day sample uses Snap Cloud
The Lens signs the user in with the same signInWithIdToken call as the other Snap Cloud examples (see Create the client and sign in). It then calls the RPC function pledge_and_total_once(), which inserts the user's pledge into the kindness_pledges table once and returns the global total. The web app calls get_kindness_total_all() to show the same total.
Set up the World Kindness Day sample
The setup is split across three guides. Start with the Snap Cloud project, then choose whether to run only the Lens, or the Lens and the web app.
| Step | Guide |
|---|---|
| 1. Create tables and RPC functions | World Kindness Day Snap Cloud Setup |
| 2. Connect the Lens in Lens Studio | World Kindness Day Lens Setup |
| 3. Configure and run the web app | World Kindness Day Web App Setup |
Option A: run only the Lens
Open the World Kindness Day sample project from the SPECS sample projects on the Lens Studio Home Page. Import your Snap Cloud credentials and connect the Lens to your backend as described in World Kindness Day Lens Setup. The Lens writes pledge data to your database, which you can inspect in the Snap Cloud dashboard.
Option B: run the Lens and the web app
Complete Option A first. Then download the web app ZIP and configure it with your project URL and anon key as described in World Kindness Day Web App Setup. The web app then shows the same global pledge total that the Lens updates.
Related
- World Kindness Day Snap Cloud Setup: the tables and RPC functions both clients use.
- World Kindness Day Lens Setup: the Lens side.
- World Kindness Day Web App Setup: the web side.
- Examples: the other Snap Cloud examples.