Where an AI-built app keeps its data
Data that must outlive one visit — or one restart, or one
redeploy — belongs on the server, in a database or files on storage that
outlives the container; only disposable state belongs in the
browser. An app can look finished while keeping its data in the
wrong place: a todo list in localStorage, a cart in a
JavaScript variable, a file written inside the container. Each works on
the machine that built it, then shows the next visitor different data or
loses everything on the next deploy.
The four places data can live
| Where | Survives | Read by |
|---|---|---|
Browser storage: localStorage,
sessionStorage, IndexedDB |
A refresh; localStorage even closing the browser, since
it has no expiration time |
That visitor's browser |
| Process memory: a variable or an in-process cache | Until the process stops | Requests handled by that process |
| The container's own filesystem | Until the container is replaced | That container |
| A database, or files on a mounted volume, outside the container | Restarts, redeploys and new containers | Every copy of the app that can reach it |
The first row is not nothing: saving a draft locally is a real feature. The mistake is using it for data that is meant to be shared or permanent.
Browser storage belongs to one browser
localStorage is a place in one visitor's
browser, not on the server. MDN says it "is partitioned by
origin only. All documents with the same origin have access to the same
localStorage area, and it persists even when the browser is
closed and reopened" (Web
Storage API, checked 2026-11-10). Another visitor, on another
browser or device, has a different storage area, and a private window
deletes its own when it closes (Window.localStorage,
checked 2026-11-10).
So a page that keeps the list only in localStorage gives
every visitor their own list. Nothing is shared, because there is no
copy anywhere but each browser.
Process memory and the container's disk end with the process
A variable ends with the process, and a file in the container ends with the container. The Twelve-Factor App puts it plainly: "Twelve-factor processes are stateless and share-nothing. Any data that needs to persist must be stored in a stateful backing service, typically a database" (checked 2026-11-10). Docker's storage docs are as direct about the filesystem: "Data written to the container layer doesn't persist when the container is destroyed" (Storage, checked 2026-11-10).
A redeploy replaces the container, and a crash restarts the process, so neither a variable nor a file written next to the code is persistence. Kubernetes makes the same point from the other side: Pods are "designed as relatively ephemeral, disposable entities" (Pods, checked 2026-11-10).
What to use instead
Store the data where its life does not depend on the app process: a database server, or a database file or other files on storage mounted into the container. A Kubernetes PersistentVolume is exactly that: "PVs are volume plugins like Volumes, but have a lifecycle independent of any individual Pod that uses the PV" (Persistent Volumes, checked 2026-11-10). A redeploy can then swap the container while the data stays.
Two limits come with that:
- A volume is a disk, not a backup. Deleting it deletes the data with it. Take a copy somewhere else if losing the data would matter.
- One volume usually means one copy of the app. On hosts that attach a volume to a single container, several replicas cannot share it. If the app must run more than one copy, use a database server the copies connect to instead of one file on a disk.
For a small app with one process, a single database file on a volume is enough. For several writers, a database server handles the concurrent connections.
Check before shipping
Ask these about every piece of state, not just the obvious database:
- Shared or personal? Does another visitor need to see it? If yes, it cannot live only in the browser.
- Does it survive a restart? A variable or an in-process cache does not.
- Does it survive a redeploy? A file written inside the image does not.
- How many copies of the app will run? More than one rules out a volume that attaches to a single container.
- Can you get it back? A volume gives persistence, not backup.
Example: a shared todo list
A todo list where every visitor sees the same items has two jobs: store the list on the server, and store it somewhere that outlives the container. The version built alongside this page keeps the todos in a small database file on a mounted volume, serves them through a JSON API, and tells open pages about each write so they refresh; the page itself holds only what it last rendered. The same design works for a guestbook, a shared shopping list or a small internal tool.
Cloudish, as one disclosed example
Cloudish is made by Hal9, which started this wiki, so it appears here
as an example and not as a recommendation. Its app API takes
volumeEnabled, volumeSizeGb (1, 5 or 20) and
volumeMountPath (default /data), and mounts
that volume into the container. The same documentation notes the limit
above in its own words: "A volume attaches to one container only, so it
rules out replicas" (Cloudish
agent instructions, checked 2026-11-10). The todo app above enables
the volume and writes its database under /data.
Related pages
See also
Glossary terms used on this page: Agent, API, Container, Deploy, Host, Tool.
Sources
All checked on 2026-11-10.
- MDN, Web
Storage API;
Window.localStorage - The Twelve-Factor App, Processes
- Docker, Storage
- Kubernetes, Pods; Persistent Volumes
- Cloudish, agent instructions
First version written with AI assistance while building a shared todo app on 2026-11-10, and checked against the sources on 2026-11-10. Found a mistake? Fix it or open an issue. Text licensed under CC BY 4.0.