How to persist state across Mini App sessions. Cookies do not work in the sandboxed iframe environment. Use localStorage or IndexedDB instead.
Mini Apps run as sandboxed cross-origin iframes inside the Startale App. This environment imposes browser-level storage restrictions that differ from a normal browser tab. Understanding them upfront prevents silent bugs in production.
See Iframe environment for the full sandbox and allow reference.The allow-same-origin flag preserves the Mini App’s own origin (so the Mini App can access its own localStorage), but the frame is still third-party to app.startale.com.Safari / iOS, Intelligent Tracking Prevention: ITP blocks third-party cookie storage in cross-origin iframes by default. document.cookie = "..." runs without throwing an error, but the cookie is silently dropped or scoped to ephemeral storage that does not survive navigation. This is not a bug in the Startale App; it is Safari’s enforced policy.Chrome, CHIPS (Partitioned Cookies): Third-party cookies require the Partitioned attribute. Without it, behavior is unreliable and being phased toward full removal.The key misconception:SameSite=None; Secure controls whether a cookie is sent on cross-site requests. It does not override ITP or Partitioned Cookie policies that block the cookie from being stored in the first place.
localStorage works reliably in the sandboxed iframe because allow-same-origin preserves the Mini App’s origin. Storage is scoped to your Mini App’s origin and is stable across repeated sessions launched from app.startale.com.
The reliable hooks for catching a frame close or navigation are visibilitychange and pagehide. Register them on mount and write to localStorage synchronously inside the handler.
Write synchronously inside pagehide. The browser may freeze the JavaScript thread immediately after the event fires, so async operations including IndexedDB writes are not reliable at this point. Use localStorage.setItem; it is synchronous.
Restore state on mount before calling sdk.actions.ready():
Backend authentication: replace cookies with Bearer tokens
If your Mini App authenticates against a backend API, return the session token in the JSON response body and store it in localStorage. Do not rely on Set-Cookie.
// Auth flow: store token from response body, not from Set-Cookieconst { token } = await fetch('https://api.your-app.com/auth', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ address }),}).then((r) => r.json())localStorage.setItem('your-app-name:auth_token', token)// Subsequent authenticated requestsconst data = await fetch('https://api.your-app.com/deposit', { headers: { Authorization: `Bearer ${localStorage.getItem('your-app-name:auth_token')}`, },}).then((r) => r.json())
Your backend must accept Authorization: Bearer <token> instead of reading from the Cookie header.
For structured data, larger payloads, or binary assets, use IndexedDB. It follows the same origin rules as localStorage and works reliably inside the iframe.
Do not write to IndexedDB inside a pagehide handler. IndexedDB operations are asynchronous and will not complete before the browser freezes the thread. Use localStorage.setItem for any state that must be saved on close.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Startale Documentation","description":"Official developer documentation for the Startale App SDK and the Startale App.","colors":{"primary":"#000000","light":"#FFFFFF","dark":"#000000"},"logo":{"light":"https://mintcdn.com/startalegroup/8zMDHw3JAiczr_n0/images/logo-light.svg?fit=max\u0026auto=format\u0026n=8zMDHw3JAiczr_n0\u0026q=85\u0026s=db1497afaec16d966a1cafc45bd39b36","dark":"https://mintcdn.com/startalegroup/8zMDHw3JAiczr_n0/images/logo-dark.svg?fit=max\u0026auto=format\u0026n=8zMDHw3JAiczr_n0\u0026q=85\u0026s=25fc88450c3bf185492290b0756cb45a","href":"/"},"favicon":{"light":"https://mintcdn.com/startalegroup/8zMDHw3JAiczr_n0/images/symbol-black.svg?fit=max\u0026auto=format\u0026n=8zMDHw3JAiczr_n0\u0026q=85\u0026s=55f72ab01cdec8f36f3ac0c7a5e31fa0","dark":"https://mintcdn.com/startalegroup/8zMDHw3JAiczr_n0/images/symbol-white.svg?fit=max\u0026auto=format\u0026n=8zMDHw3JAiczr_n0\u0026q=85\u0026s=9ea7dac0da63612750deff896ef953c9"},"navbar":{"links":[{"icon":"folder","href":"https://startale.com/en/brand-kit","label":"Brand kit"},{"icon":"discord","href":"https://discord.gg/startale","label":"Support"}],"primary":{"type":"github","href":"https://github.com/StartaleGroup/app-sdk"}},"footer":{"socials":{"discord":"https://discord.gg/startale","github":"https://github.com/StartaleGroup","x":"https://x.com/StartaleGroup","linkedin":"https://www.linkedin.com/company/startale"},"links":[{"items":[{"label":"Startale","href":"https://startale.com/en"},{"label":"Startale App","href":"https://app.startale.com/"},{"label":"About Us","href":"https://startale.com/en/about-us"}]}]},"search":{"prompt":"Search Startale Documentation"},"seo":{"indexing":"navigable"},"contextual":{"options":["copy","view","claude","chatgpt","perplexity"],"display":"header"},"styling":{"latex":false},"navigation":{"global":{"anchors":[{"anchor":"GitHub","icon":"github","href":"https://github.com/StartaleGroup/app-sdk"},{"anchor":"Discord","icon":"discord","href":"https://discord.gg/startale"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"startalegroup","hasAudioNarration":false,"actualSubdomain":"startalegroup","customDomains":["docs.startale.com"],"gitSource":{"type":"github","owner":"startalegroup","repo":"startale-docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6ad6d1475c341c45a36cc28d","clientVersion":"0.0.4117","searchFilterCounts":[{"language":"default","tag":"Mini Apps","count":19},{"language":"default","tag":"API Reference","count":14},{"language":"default","tag":"App SDK","count":12},{"language":"default","tag":"RPC methods","count":9},{"language":"default","tag":"Tutorials","count":9},{"language":"default","tag":"Get Started","count":7},{"language":"default","tag":"Wallet","count":6},{"language":"default","tag":"Concepts","count":5},{"language":"default","tag":"Host APIs","count":5},{"language":"default","tag":"Platform capabilities","count":4}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":"pagination-prev,pagination-next{display:flex;border:1px solid rgba(255, 255, 255, 0.10);border-radius:0.75rem;padding:1rem 1.25rem;transition:border-color 150ms ease, background-color 150ms ease}pagination-prev:hover,pagination-next:hover{border-color:rgba(255, 255, 255, 0.25);background-color:rgba(255, 255, 255, 0.03)}html:not(.dark) pagination-prev,html:not(.dark) pagination-next{border-color:rgba(0, 0, 0, 0.10)}html:not(.dark) pagination-prev:hover,html:not(.dark) pagination-next:hover{border-color:rgba(0, 0, 0, 0.25);background-color:rgba(0, 0, 0, 0.02)}navbar-link{border:1px solid rgba(255, 255, 255, 0.10);border-radius:10px;padding:0.4rem 1.25rem;transition:border-color 150ms ease, background-color 150ms ease}#navbar navbar-link+navbar-link{margin-left:0.5rem}navbar-link:hover{border-color:rgba(255, 255, 255, 0.25);background-color:rgba(255, 255, 255, 0.04)}html:not(.dark) navbar-link{border-color:rgba(0, 0, 0, 0.10)}html:not(.dark) navbar-link:hover{border-color:rgba(0, 0, 0, 0.25);background-color:rgba(0, 0, 0, 0.03)}"}],"page":{"pagePath":"miniapps/capabilities/storage","slug":"/miniapps/capabilities/storage","pageMetadata":{"title":"Storage","description":"How to persist state across Mini App sessions. Cookies do not work in the sandboxed iframe environment. Use localStorage or IndexedDB instead.","href":"/miniapps/capabilities/storage"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"How to persist state across Mini App sessions. Cookies do not work in the sandboxed iframe environment. Use localStorage or IndexedDB instead.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,em:`em`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,..._provideComponents(),...props.components},{CodeBlock,Heading,Table,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Mini Apps run as sandboxed cross-origin iframes inside the Startale App. This environment imposes browser-level storage restrictions that differ from a normal browser tab. Understanding them upfront prevents silent bugs in production.`}),`\n`,_jsx(Heading,{level:`2`,id:`what-works-and-what-does-not`,children:`What works and what does not`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Mechanism`}),_jsx(_components.th,{children:`Works`}),_jsx(_components.th,{children:`Notes`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`localStorage`})}),_jsx(_components.td,{children:`Yes`}),_jsxs(_components.td,{children:[`Recommended. Stable across sessions from `,_jsx(_components.code,{children:`app.startale.com`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`IndexedDB`})}),_jsx(_components.td,{children:`Yes`}),_jsxs(_components.td,{children:[`Same origin rules as `,_jsx(_components.code,{children:`localStorage`}),`. Good for structured or large data.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`sessionStorage`})}),_jsx(_components.td,{children:`Yes`}),_jsx(_components.td,{children:`Not persisted across page reloads or frame re-opens. Suitable for ephemeral in-session state only.`})]}),_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[`JavaScript cookies (`,_jsx(_components.code,{children:`document.cookie`}),`)`]}),_jsx(_components.td,{children:`No`}),_jsx(_components.td,{children:`Silently dropped on Safari and iOS due to Intelligent Tracking Prevention. See below.`})]}),_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[_jsx(_components.code,{children:`Set-Cookie`}),` from your backend`]}),_jsx(_components.td,{children:`No`}),_jsx(_components.td,{children:`Same cross-origin restriction: cookies set by a third-party origin are blocked in iframes.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Storage Access API`}),_jsx(_components.td,{children:`No`}),_jsxs(_components.td,{children:[`Not available. The iframe sandbox is missing `,_jsx(_components.code,{children:`allow-storage-access-by-user-activation`}),`.`]})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`why-cookies-fail-silently`,children:`Why cookies fail silently`}),`\n`,_jsxs(_components.p,{children:[`Mini App URLs are always cross-origin relative to `,_jsx(_components.code,{children:`app.startale.com`}),` (all Mini Apps are hosted on their own domain). The Startale App embeds them with:`]}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`sandbox=\"allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-downloads\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/miniapps/capabilities/iframe-environment`,children:`Iframe environment`}),` for the full sandbox and `,_jsx(_components.code,{children:`allow`}),` reference.`]}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`allow-same-origin`}),` flag preserves the Mini App’s own origin (so the Mini App can access its own `,_jsx(_components.code,{children:`localStorage`}),`), but the frame is still third-party to `,_jsx(_components.code,{children:`app.startale.com`}),`.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Safari / iOS, Intelligent Tracking Prevention:`}),` ITP blocks third-party cookie storage in cross-origin iframes by default. `,_jsx(_components.code,{children:`document.cookie = \"...\"`}),` runs without throwing an error, but the cookie is silently dropped or scoped to ephemeral storage that does not survive navigation. This is not a bug in the Startale App; it is Safari’s enforced policy.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Chrome, CHIPS (Partitioned Cookies):`}),` Third-party cookies require the `,_jsx(_components.code,{children:`Partitioned`}),` attribute. Without it, behavior is unreliable and being phased toward full removal.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`The key misconception:`}),` `,_jsx(_components.code,{children:`SameSite=None; Secure`}),` controls whether a cookie is `,_jsx(_components.em,{children:`sent`}),` on cross-site requests. It does not override ITP or Partitioned Cookie policies that block the cookie from being `,_jsx(_components.em,{children:`stored`}),` in the first place.`]}),`\n`,_jsx(Heading,{level:`2`,id:`localstorage-the-recommended-approach`,children:`localStorage: the recommended approach`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`localStorage`}),` works reliably in the sandboxed iframe because `,_jsx(_components.code,{children:`allow-same-origin`}),` preserves the Mini App’s origin. Storage is scoped to your Mini App’s origin and is stable across repeated sessions launched from `,_jsx(_components.code,{children:`app.startale.com`}),`.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`6`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Persist state`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`localStorage.setItem(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'game:round'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, JSON.stringify({ round: 5, score: 1200 }))`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Restore on re-open`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` saved = localStorage.getItem(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'game:round'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` state = saved ? JSON.parse(saved) : { round: 1, score: 0 }`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Namespace your keys.`}),` Use a consistent prefix to avoid collisions between multiple Mini Apps on the same origin:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`9`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`9`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` STORAGE_PREFIX = `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'your-app-name:'`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` save = (key: string, value: unknown) =>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` localStorage.setItem(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`${STORAGE_PREFIX}${key}`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, JSON.stringify(value))`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` restore = \u003cT>(key: string, fallback: T): T => {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` raw = localStorage.getItem(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`${STORAGE_PREFIX}${key}`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` raw !== `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`null`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ? (JSON.parse(raw) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` T) : fallback`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`saving-state-on-close`,children:`Saving state on close`}),`\n`,_jsxs(_components.p,{children:[`The reliable hooks for catching a frame close or navigation are `,_jsx(_components.code,{children:`visibilitychange`}),` and `,_jsx(_components.code,{children:`pagehide`}),`. Register them on mount and write to `,_jsx(_components.code,{children:`localStorage`}),` synchronously inside the handler.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`19`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`19`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { sdk } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '@farcaster/miniapp-sdk'`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`function`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` saveState(state: GameState) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` localStorage.setItem(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'your-app-name:state'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, JSON.stringify(state))`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Register on mount`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` handleHide = () => {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (document.visibilityState === `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'hidden'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` saveState(currentState)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` handlePageHide = () => {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` saveState(currentState)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`document.addEventListener(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'visibilitychange'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, handleHide)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`window.addEventListener(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'pagehide'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, handlePageHide)`})]}),`\n`]})})}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Write synchronously inside `,_jsx(_components.code,{children:`pagehide`}),`. The browser may freeze the JavaScript thread immediately after the event fires, so async operations including `,_jsx(_components.code,{children:`IndexedDB`}),` writes are not reliable at this point. Use `,_jsx(_components.code,{children:`localStorage.setItem`}),`; it is synchronous.`]})}),`\n`,_jsxs(_components.p,{children:[`Restore state on mount before calling `,_jsx(_components.code,{children:`sdk.actions.ready()`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`tsx`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`tsx`,children:_jsxs(_components.code,{language:`tsx`,numberOfLines:`7`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`useEffect(() => {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` saved = localStorage.getItem(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'your-app-name:state'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (saved) {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` restoreState(JSON.parse(saved))`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` sdk.actions.ready()`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}, [])`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`backend-authentication-replace-cookies-with-bearer-tokens`,children:`Backend authentication: replace cookies with Bearer tokens`}),`\n`,_jsxs(_components.p,{children:[`If your Mini App authenticates against a backend API, return the session token in the JSON response body and store it in `,_jsx(_components.code,{children:`localStorage`}),`. Do not rely on `,_jsx(_components.code,{children:`Set-Cookie`}),`.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`15`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`15`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Auth flow: store token from response body, not from Set-Cookie`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { token } = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fetch(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'https://api.your-app.com/auth'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` method: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'POST'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` headers: { `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'Content-Type'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'application/json'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` body: JSON.stringify({ address }),`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}).then((r) => r.json())`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`localStorage.setItem(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'your-app-name:auth_token'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, token)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Subsequent authenticated requests`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` data = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` fetch(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'https://api.your-app.com/deposit'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` headers: {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Authorization: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`Bearer ${localStorage.getItem('your-app-name:auth_token')}`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}).then((r) => r.json())`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Your backend must accept `,_jsx(_components.code,{children:`Authorization: Bearer \u003ctoken>`}),` instead of reading from the `,_jsx(_components.code,{children:`Cookie`}),` header.`]}),`\n`,_jsx(Heading,{level:`2`,id:`indexeddb-structured-or-large-data`,children:`IndexedDB: structured or large data`}),`\n`,_jsxs(_components.p,{children:[`For structured data, larger payloads, or binary assets, use `,_jsx(_components.code,{children:`IndexedDB`}),`. It follows the same origin rules as `,_jsx(_components.code,{children:`localStorage`}),` and works reliably inside the iframe.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`13`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`13`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { openDB } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'idb'`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` db = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` openDB(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'your-app-name'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, 1, {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` upgrade(db) {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` db.createObjectStore(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'state'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`})`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Write`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` db.put(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'state'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, { round: 5, score: 1200 }, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'game'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Read`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` saved = `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` db.get(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'state'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'game'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`]})})}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Do not write to IndexedDB inside a `,_jsx(_components.code,{children:`pagehide`}),` handler. `,_jsx(_components.code,{children:`IndexedDB`}),` operations are asynchronous and will not complete before the browser freezes the thread. Use `,_jsx(_components.code,{children:`localStorage.setItem`}),` for any state that must be saved on close.`]})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Storage","description":"How to persist state across Mini App sessions. Cookies do not work in the sandboxed iframe environment. Use localStorage or IndexedDB instead.","href":"/miniapps/capabilities/storage"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"What works and what does not","slug":"what-works-and-what-does-not","depth":2,"children":[]},{"title":"Why cookies fail silently","slug":"why-cookies-fail-silently","depth":2,"children":[]},{"title":"localStorage: the recommended approach","slug":"localstorage-the-recommended-approach","depth":2,"children":[]},{"title":"Saving state on close","slug":"saving-state-on-close","depth":2,"children":[]},{"title":"Backend authentication: replace cookies with Bearer tokens","slug":"backend-authentication-replace-cookies-with-bearer-tokens","depth":2,"children":[]},{"title":"IndexedDB: structured or large data","slug":"indexeddb-structured-or-large-data","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"startalegroup","siteName":"Startale Documentation","title":"Storage - Startale Documentation","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-16T16:01:08.780Z","originalFileLocation":"miniapps/capabilities/storage.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"How to persist state across Mini App sessions. Cookies do not work in the sandboxed iframe environment. Use localStorage or IndexedDB instead.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Startale Documentation\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/startalegroup/rYVC4b2I4120L7iK/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/startalegroup/rYVC4b2I4120L7iK/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/startalegroup/rYVC4b2I4120L7iK/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/startalegroup/rYVC4b2I4120L7iK/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/startalegroup/rYVC4b2I4120L7iK/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/startalegroup/rYVC4b2I4120L7iK/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/startalegroup/rYVC4b2I4120L7iK/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/startalegroup/rYVC4b2I4120L7iK/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/startalegroup/rYVC4b2I4120L7iK/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Storage - Startale Documentation\">\u003cmeta data-mint-head property=\"og:description\" content=\"How to persist state across Mini App sessions. Cookies do not work in the sandboxed iframe environment. Use localStorage or IndexedDB instead.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Startale Documentation\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.startale.com/miniapps/capabilities/storage\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://startalegroup.mintlify.site/_mintlify/api/og/v2?division=Platform+capabilities\u0026amp;title=Storage\u0026amp;description=How+to+persist+state+across+Mini+App+sessions.+Cookies+do+not+work+in+the+sandboxed+iframe+environment.+Use+localStorage+or+IndexedDB+instead.\u0026amp;theme=ee23fc698a76559443f94ada\u0026amp;signature=663a9edcd1dcedef2be17058bacb27a92325f00dcd64eb09fd1afc64eef0847c\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Storage - Startale Documentation\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"How to persist state across Mini App sessions. Cookies do not work in the sandboxed iframe environment. Use localStorage or IndexedDB instead.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://startalegroup.mintlify.site/_mintlify/api/og/v2?division=Platform+capabilities\u0026amp;title=Storage\u0026amp;description=How+to+persist+state+across+Mini+App+sessions.+Cookies+do+not+work+in+the+sandboxed+iframe+environment.+Use+localStorage+or+IndexedDB+instead.\u0026amp;theme=ee23fc698a76559443f94ada\u0026amp;signature=663a9edcd1dcedef2be17058bacb27a92325f00dcd64eb09fd1afc64eef0847c\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/startalegroup/rYVC4b2I4120L7iK/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Startale Documentation\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#000000\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.startale.com/miniapps/capabilities/storage\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/miniapps/capabilities/storage.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.startale.com/#organization\",\"name\":\"Startale Documentation\",\"url\":\"https://docs.startale.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/startalegroup/8zMDHw3JAiczr_n0/images/logo-light.svg?fit=max\u0026auto=format\u0026n=8zMDHw3JAiczr_n0\u0026q=85\u0026s=db1497afaec16d966a1cafc45bd39b36\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.startale.com#website\",\"name\":\"Startale Documentation\",\"url\":\"https://docs.startale.com\",\"publisher\":{\"@id\":\"https://docs.startale.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.startale.com/miniapps/capabilities/storage#webpage\",\"url\":\"https://docs.startale.com/miniapps/capabilities/storage\",\"name\":\"Storage\",\"description\":\"How to persist state across Mini App sessions. Cookies do not work in the sandboxed iframe environment. Use localStorage or IndexedDB instead.\",\"dateModified\":\"2026-10-16T16:01:08.780Z\",\"isPartOf\":{\"@id\":\"https://docs.startale.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.startale.com/miniapps/capabilities/storage#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.startale.com/miniapps/capabilities/storage#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Platform capabilities\",\"item\":\"https://docs.startale.com/miniapps/capabilities/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Storage\",\"item\":\"https://docs.startale.com/miniapps/capabilities/storage\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.startale.com/miniapps/capabilities/storage#article\",\"headline\":\"Storage\",\"name\":\"Storage\",\"description\":\"How to persist state across Mini App sessions. Cookies do not work in the sandboxed iframe environment. Use localStorage or IndexedDB instead.\",\"url\":\"https://docs.startale.com/miniapps/capabilities/storage\",\"mainEntityOfPage\":{\"@id\":\"https://docs.startale.com/miniapps/capabilities/storage#webpage\"},\"dateModified\":\"2026-10-16T16:01:08.780Z\",\"publisher\":{\"@id\":\"https://docs.startale.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.startale.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Startale Documentation\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Startale Documentation\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/miniapps/capabilities/storage.md","siteName":"Startale Documentation","nav":{"global":{"anchors":[{"anchor":"GitHub","icon":"github","href":"https://github.com/StartaleGroup/app-sdk"},{"anchor":"Discord","icon":"discord","href":"https://discord.gg/startale"}]},"tabs":[{"tab":"Get Started","pages":[{"title":"Get Started","href":"/introduction"}]},{"tab":"App SDK","pages":[{"title":"App SDK","href":"/app-sdk/installation"}]},{"tab":"Mini Apps","groups":[{"group":"Overview","icon":"compass","pages":[{"title":"Mini Apps overview","href":"/miniapps/overview"},{"title":"Mini App quickstart","href":"/miniapps/quickstart"},{"title":"Test your Mini App","href":"/miniapps/testing"}]},{"group":"Manifest","icon":"file-code","pages":[{"title":"Manifest","href":"/miniapps/manifest"},{"title":"Image and video specs","href":"/miniapps/media-specs"},{"title":"Categories","href":"/miniapps/categories"},{"title":"Embed meta tag","href":"/miniapps/embed"}]},{"group":"Host APIs","icon":"play","pages":[{"title":"Runtime context","href":"/miniapps/runtime-context"},{"title":"Wallet integration","href":"/miniapps/wallet-integration"},{"title":"NFT assets","href":"/miniapps/nft-assets"},{"title":"SDK actions","href":"/miniapps/sdk-actions"},{"title":"Deep linking","href":"/miniapps/deep-linking"}]},{"group":"Platform capabilities","icon":"browser","pages":[{"title":"Platform capabilities","href":"/miniapps/capabilities/overview"},{"title":"Iframe environment","href":"/miniapps/capabilities/iframe-environment"},{"title":"Files and sharing","description":"Download files and open the native share sheet from your Mini App using standard web APIs.","href":"/miniapps/capabilities/files-and-sharing"},{"title":"Storage","href":"/miniapps/capabilities/storage"}]},{"group":"Notifications","icon":"bell","pages":[{"title":"Notifications","description":"Wire your Mini App backend to the Notification Server to receive lifecycle events and send push notifications to users.","href":"/miniapps/notifications"},{"title":"Notification Policy","href":"/miniapps/notification-policy"}]},{"group":"Ship it","icon":"rocket","pages":[{"title":"Submission","href":"/miniapps/submission"}]}]},{"tab":"Tutorials","pages":[{"title":"Tutorials","href":"/tutorials/overview"}]},{"tab":"API Reference","pages":[{"title":"API Reference","href":"/api-reference/create-startale-account-sdk"}]}]},"basePath":"","title":"Storage - Startale Documentation","buildId":"dpl_41S5Z2jG9QnfDRwN1KZrLdBwj7DM","deploymentId":"dpl_41S5Z2jG9QnfDRwN1KZrLdBwj7DM","dynamics":[],"chunks":[]}