Skip to content
All articles

How to Save Data in an AI-Built App

7 min readHosting, AI publishing

To save data in an AI-built app, you have two places to put it. Things that belong to one person (their settings, a half-finished form, a saved game) go in that person's browser. Things that more than one person should see, or that you want to read back later (sign-ups, scores, votes), go in a shared store that lives with the page. Most apps that "forget everything" were built with neither, and the fix is to tell your AI which of the two you want.

This post covers why an app built in a chat loses its state, what each place keeps and where it lets you down, and the wording that gets your AI to build the right one the first time.

Why you have to save data in an AI-built app on purpose

You asked Claude or ChatGPT for a habit tracker, a quote calculator or a small quiz. It works. You tick three boxes, reload the page, and the boxes are empty again.

Nothing broke. Unless you ask otherwise, an app like this keeps what you typed in the page's memory, and a page's memory lasts as long as the tab does. Reload, close the tab or open the link on your phone and it starts from zero. The AI built what you described, and "remember this tomorrow" was not in the description.

So the question to settle before you share the link is who needs to see the saved thing. If the answer is "the same person, next time they open it", you want browser storage. If the answer is "me" or "everyone", you want a shared store.

Browser storage: what stays with one visitor

Browsers come with places a page can keep things between visits. The two you will hear named are localStorage, which holds small pieces of text, and IndexedDB, which holds larger and more structured data. Neither needs a server, an account or a key. The page writes, the browser keeps it, and the page reads it back on the next visit.

A page published on SnapHost can use both, along with the other standard browser storage, with nothing to configure. Each site runs on its own isolated origin, so what a site stores is private to that site and no other SnapHost site can read or change it. This does not depend on your plan. Hosting interactive apps has the short version.

That makes browser storage the right home for:

  • A saved game or a quiz someone is halfway through.
  • A light or dark theme choice, a chosen currency, a default filter on a dashboard.
  • A long form the reader should be able to leave and come back to.
  • A personal checklist that nobody else needs to see.

The buttons people expect from an app work as well. A "Print this page" button and an "Are you sure?" prompt behave the way they would on any website.

What browser storage will not do

The data lives in one browser on one device, and that has consequences worth knowing before you promise anyone their progress is safe.

  • It does not follow the person. A checklist ticked on a laptop is empty on the same person's phone. Two browsers on one computer are two separate stores.
  • You cannot see it. If twenty people fill in the tracker, you have no way to read their answers. Nothing was sent anywhere.
  • It can be cleared. The browser or the visitor can wipe it, as on any website. Treat it as a convenience, and do not keep the only copy of anything important there.
  • It is tied to the address. Browsers key a site's storage to the address it is viewed on. A visitor who opens the same site on your custom domain and on its SnapHost share link gets two separate stores. Pick one address to hand out and stay with it.
  • It is not offline mode. Service workers and offline use are not supported on SnapHost yet. An app that registers one still runs, but the registration does not take effect.

If the list above rules out what you had in mind, you are looking for the other kind of saving.

Shared data: what you and other visitors can see

A guestbook, a leaderboard, a waitlist and an RSVP list have something in common: the person who writes the entry is not the only one who needs to read it. That data has to live somewhere outside any one browser.

The usual advice at this point is to set up a database, and it is the moment many people give up on the app. On SnapHost a published page carries a small built-in helper called window.SNAPHOST. One call saves a record to a named collection and another reads records back:

await window.SNAPHOST.append('scores', { name: 'Dana', score: 4200 })

const { records } = await window.SNAPHOST.query('scores', { order: 'desc', limit: 50 })

You will rarely type that yourself. The site's Data settings have ready-made recipes (contact form, waitlist, RSVP, guestbook, shared counter, clock-in, leaderboard) that set the data up and hand you a snippet, and a connected AI can add it to the page for you. Collect and store data covers both routes.

Two settings decide who sees what. Each collection is private by default, which means visitors can add entries and only you can read them, in the dashboard. That suits a contact form. Switch a collection to public and anyone who can open the page can read it, which is what a scoreboard needs. On a private page, only the people who got past the access check can add or read entries at all, and you can record who wrote each one by their verified email. On a public page there is no identity, so entries are anonymous.

Collecting data this way is a Pro feature. On Free the page still publishes, but it cannot save to or read from the shared store. Collect form responses without a backend goes deeper on forms in particular.

Which one to ask your AI for

A quick way to decide is to finish the sentence "this should still be there when...".

  • "...the same person reloads the page": browser storage.
  • "...the same person opens it on another device": this is the awkward one. Shared data can do it on a private page, where an entry can carry the reader's verified email, but the page can only read a collection that is public to everyone who can open it. Fine for a team tool, wrong for anything personal.
  • "...I want to read what people entered": shared data, private collection.
  • "...the next visitor arrives": shared data, public collection.
  • "...the tab closes, and not after": nothing to do. A calculator that starts clean each time is fine as it is.

Then say it in the request, because the AI will not guess. Something like: "Save the checklist in localStorage so it is still there after a reload." Or: "Save each RSVP with window.SNAPHOST.append to a collection called rsvp, and do not show other people's answers on the page."

If you are publishing a single React component, the file Claude gives you as an artifact, the same advice applies: ask for the storage by name inside the component. How to publish a React component as a web page covers that route.

Using both in one app

A good small app often uses both. Take a team lunch poll. The vote itself goes to a shared collection, so the tally is the same for whoever opens the page. The fact that this browser has already voted goes in browser storage, so the page can show "you picked Thai" instead of the form on the next visit.

If losing the browser copy would lose something that matters, put it in the shared store and keep the browser copy as a shortcut.

The shared store is meant for small structured entries. One record can be up to 64 KB. A site can hold 50 collections with 100,000 records in each, and up to 100 MB of records in total, inside the 5 GB a Pro workspace gets. Form entries, scores and votes fit comfortably. Photos, videos and file uploads do not belong there.

What it costs

Browser storage costs nothing extra and works on Free, where you can have up to three pages at a time, each private to up to three people or public, served at sites.snaphost.ai with a small SnapHost mark in the corner. A habit tracker or a quiz that only needs to remember its own visitor is fully covered there.

Shared data comes with Pro, which is 19 euros a month per member who can publish. People who only open pages are not charged. Pricing has the current plans.

Check it before you send the link

  1. Publish the app and open the link you plan to send, not a preview.
  2. Enter something, reload, and see whether it is still there. If it is gone, the app is keeping it in memory. Ask your AI to save it, and say where.
  3. Open the same link in a second browser. If the data should be shared, it should appear. If it is meant to be personal, it should not.
  4. For shared data, open the site's Data tab in the dashboard and confirm the entry arrived.
  5. Send one address. When you update the app later it keeps the same link, so ask your AI to keep the same storage names, or returning visitors will find their saved state missing.

Keep reading