Agent skill · cognitedata
handle-startup-state
MUST be used when a Flows/Fusion app needs to read state it was launched with — a deep link, a shareable URL, or startup/bootstrap arguments set by a host embedding the app (e.g. a Flows dashboard widget). Triggers: initialState, connectToHostApp initialState, startup arguments, bootstrap state, initial state, deep link, restore state on mount, syncInternalState, customAppInternalState.
What it needs
About 5k tokens when loaded.
What this skill does
Handle Startup State Reads the optional initialState string returned by connectToHostApp() and restores it before first render, so the app opens directly into the right view instead of always starting from defaults. Requires @cognite/app-sdk's connectToHostApp() handshake already wired up. If auth isn't wired up yet, run the setup-flows-auth skill first. What initialState actually is initialState is a single opaque string, present on the object returned by connectToHostApp(): Your app never needs to know how it got there — treat it the same way regardless of source: A user opened a shareable URL your app previously wrote via api.syncInternalState(...) (the customAppInternalState URL param). A host embedded your app with a startup argument baked in (a Flows dashboard widget, or any other surface that programmatically launches your app with initial arguments). The app was reloaded and the current URL still has the param from an earlier syncInternalState call. All three arrive through the same field. Design your restore logic once and it covers all of them. Step 1 — Decide your encoding Pick one encoding and use it consistently: Serialized route (a path string) — if your app's state maps cleanly onto a URL you'd otherwise navigate to. JSON string — if you need multiple independent fields (active tab, filters, selected IDs). This is the more common choice and the one used below. Step 2 — Read initialState on mount, defensively Restore before the first meaningful render. Malformed state must never crash the app — the host cannot guarantee the string is well-formed (it never parses it either), and an older app version may have written a different shape. Key points: Merge, don't replace: { ...DEFAULTSTATE, ...parsed } so a partial or older-shaped payload still yields a usable state object, instead of undefined fields breaking downstream components. try/catch around JSON.parse, always — this is the one part of this skill that is not optional. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills cognitedata/handle-startup-state