Skip to main content
zerotal

Documentation


Documentation / @zerotal/flow / index / DurableOption

Type Alias: DurableOption

DurableOption = boolean | { ttl?: string; scope?: "user" | "session"; }

Defined in: flow/src/durable.ts:45

A component's durable-snapshot opt-in, set as static durable on the component.

  • true — enable with defaults (24h TTL, "user" scope).
  • { ttl, scope } — enable with a custom lifetime and keying:
    • ttl — a duration string like "30s", "15m", "2h", "7d" (defaults to 24h if omitted/unparseable).
    • scope"user" keys by authenticated user (falling back to session when anonymous); "session" always keys by session, for per-device durability even while logged in.

Remarks

When enabled, the component's signed snapshot is persisted after every request and restored on a fresh GET (skipping onMount), so a user resumes across a tab close/reopen, a device switch, or a reconnect. With a persistent store (see setDurableStore) it also survives a server redeploy.

Example

class Wizard extends Component {
  static durable = { ttl: "2h", scope: "session" } satisfies DurableOption;
  // ...on the final step:
  @expose finish() { this.clearDurable(); } // drop stored state on completion
}