Give an app state that survives closing it, and decide whether that state belongs to one device, one account, or everyone with the link. Starts from an app you have already built in Build a mini app.
1
Ask the app to remember
Tell the assistant what should persist when you request or revise the app. An app keeps only the state you ask for, so without a request like "keep a running total" or "remember which ones are checked", it starts fresh every time it opens.
2
Choose who the state belongs to
Use Save app and set State, which defaults to Device.
state scope
Scope
Who shares the state
Device
Each device saves state
User
Each account saves state
Shared
Everyone shares one live state
The app itself does not change between these. The same app saved at Device is a private tracker; saved at Shared, everyone with the link sees one live copy. Change the scope later by editing the saved app.
the same app under each scope
Device
phone
laptop
→
state
state
two devices, two separate states
User
phone
laptop
→
state
same account, one state on both
Shared
you
anyone
anyone
→
state
everyone with the link, one live state
3
Clear the state to start over
Open Storage and clear an app's state, which deletes what it has stored and leaves the app itself in place. This is how a poll or tracker is reused for a new week rather than carrying last week's entries.
Asking for a reset control when you build the app gives you the same result from inside the app.
How state is counted
State is counted by size: each key's name plus the data stored in it. A key holding a single number takes a few bytes, while a key holding a long list grows as the list does. Reads and writes are included, however often the app makes them. You get 500 KB free across all your apps.
What an app stores decides how much it uses. Asking the assistant to keep only what the app needs, such as trimming old entries from a list, keeps it small. Device-scope apps do not count at all.
Storage shows your usage against your limit and lists your apps with the size of each.
When you reach the limit
Writes that keep or shrink an app's data continue normally, so an app can still update what it already has. What is blocked is any write that would grow its data past the limit, so an app trying to save more reports that storage is full. Clearing an app's state frees its space immediately.
Shared state is open to anyone with the link
Anyone who opens a shared app can read and change its state, which is what lets a poll work without accounts. There are no per-person permissions, so a shared app is not the place for anything private. Use User scope to keep state per account.
Simultaneous changes
Incrementing a counter and appending to a list are applied on the server inside a row-locked transaction, so when several people act at the same moment each change lands rather than overwriting another. There is nothing to switch on.