[**Documentation**](../../../../README)

***

[Documentation](../../../../README) / [@zerotal/flow](../../README) / [index](../README) / DurableOption

# Type Alias: DurableOption

> **DurableOption** = `boolean` \| \{ `ttl?`: `string`; `scope?`: `"user"` \| `"session"`; \}

Defined in: [flow/src/durable.ts:45](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/durable.ts#L45)

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](../functions/setDurableStore)) it also survives a server redeploy.

## Example

```ts
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
}
```
