Menu

← All guides

Keep state in an app

July 29, 2026

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 in units, where one unit is one named key the app stores, whatever the size of the value inside it. A key holding a single number and a key holding a long list each count as one.

The assistant decides how many keys an app uses. Asking it to keep the app's state in a single value reduces the count. Device-scope apps do not use units at all.

Storage shows your usage against your limit and lists your apps with the unit count for each.

When you reach the limit

Writes to keys that already exist continue normally, so an app whose state exists keeps working. What is blocked is creating a new key, so an app trying to add one reports that storage is full. Clearing an app's state releases its units 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.