Skip to content
Data

Collect & store data

Any published site can save and read its own data with no server to run and no keys to manage. Use it for contact forms, waitlists, RSVPs, guestbooks, scoreboards, and more. Collecting data is available on Pro.

The easy way: a ready-made recipe

You usually do not build any of this by hand. In the site's Data settings, pick a recipe (contact form, waitlist, RSVP, guestbook, shared counter, clock-in, or leaderboard). SnapHost sets up the data and hands you a snippet to drop into your page. Your AI assistant can do the same and even add it to the page for you.

Or write it yourself

Every published page has a small built-in helper called window.SNAPHOST. If you are building the page yourself (or asking an assistant to), this is all it takes to save and read data. Data is grouped into named collections, and each saved item is a record.

Save and read
// Save a record to a collection. The collection is created on the first save.
await window.SNAPHOST.append('signups', { email: 'jane@acme.com' })

// Read records back, newest first.
const { records } = await window.SNAPHOST.query('signups', { order: 'desc', limit: 50 })

You can also filter, sort, and page through records, and fold a collection down to the latest entry per person, which is handy for things like an RSVP list that people can update.

Showing who did something

For a leaderboard, guestbook, or comments, you often want to show who wrote each entry. Ask SnapHost who is viewing, and save that into the record yourself. On a private site this is the viewer's verified email; on a public site there is no identity, so entries stay anonymous.

Attribute an entry
// Show who did something: read the viewer, then store it in the record.
const me = await window.SNAPHOST.viewer()
const entry = { score: 4200 }
if (me.kind === 'viewer' && me.id) entry.who = me.id
await window.SNAPHOST.append('leaderboard', entry)

Who can read what

Each collection has a setting for who can read it:

  • Private (the default). Visitors can add entries, but only you can read them. This is the safe default for a contact form or waitlist: submissions are never visible to other visitors. You review them in the dashboard.
  • Public. Anyone who can open the page can read the collection. Turn this on for something meant to be shared, like a guestbook or a scoreboard.

When you publish or update a site, SnapHost reads your page's code and sets new collections up to match it: a collection your page reads from is made public so the page works out of the box, while one it only submits to stays private. You are told what was set up, and a choice you have made yourself is never changed.

The site's own privacy still applies on top: on a private site, only people who passed the access gate can add or read entries. You can also pause a collection at any time to stop new entries.

Keeping data clean

SnapHost can learn the shape of your data from the entries that come in, and you can fine-tune it in the Data tab. If you want, you can require every entry to match a set of rules, so bad or incomplete submissions are rejected automatically.

Showing stored data safely

Treat anything a visitor submits as untrusted. When you display stored values on a page, set them as plain text rather than raw HTML, so a value can never run as code. The ready-made recipes already do this for you.

Good to know

This is meant for small, structured data and events, not large files: think form entries and scores, not video. Pro includes 5 GB of storage, and you get a heads-up before you reach a limit, so nothing is ever dropped silently.