Skip to main content

Interface: AmnesiaProviderProps

Defined in: provider.tsx:40

Props for AmnesiaProvider. Extends AmnesiaProviderOptions.

Extends

Properties

capacity?

readonly optional capacity?: number

Defined in: types.ts:312

Maximum number of entries retained on the past stack. When the limit is reached, the oldest entry is dropped on every new push.

Defaults to 100. Set to Infinity to disable, but be aware closures may retain large amounts of memory.

Inherited from

AmnesiaStoreOptions.capacity


children

children: ReactNode

Defined in: provider.tsx:42

Child tree that should share this history store.


coalesceWindowMs?

readonly optional coalesceWindowMs?: number

Defined in: types.ts:320

Maximum time (in milliseconds) between two pushes that share a non-empty coalesceKey for them to merge into a single entry.

Defaults to 400.

Inherited from

AmnesiaStoreOptions.coalesceWindowMs


devToolsId?

optional devToolsId?: string

Defined in: provider.tsx:85

Stable id under which to register with the devtools registry. When omitted, an auto-generated amnesia-N id is assigned on first mount and reused across re-renders. Pin a known id if you want external tooling to find the provider by name.


enableDevTools?

optional enableDevTools?: boolean

Defined in: provider.tsx:77

Register the provider with the global devtools registry under window.__REACT_AMNESIA_DEVTOOLS__. Off by default; opt in for debugging, browser-extension integration, or AI-agent introspection.

The registry is lazy-installed: when no provider sets enableDevTools={true} anywhere in the tree, no global is created.


metaTransform?

readonly optional metaTransform?: (meta) => Record<string, unknown> | undefined

Defined in: types.ts:369

Sanitizer applied to meta before it is exposed in the public snapshot or passed to lifecycle hooks. Use this to redact sensitive fields without forcing every call site to remember the rule.

Only invoked when meta is defined. The return value replaces meta in the public HistoryEntry; returning undefined strips it.

The transform should be pure and stable — it runs every time the snapshot is rebuilt and every time a hook is fired.

Parameters

ParameterType
metaRecord<string, unknown>

Returns

Record<string, unknown> | undefined

Inherited from

AmnesiaStoreOptions.metaTransform


onAmend?

readonly optional onAmend?: (entry, scopeId) => void

Defined in: types.ts:401

Lifecycle hook fired after a successful amend on scopeId. The entry is the updated top-of-past entry.

Parameters

ParameterType
entryHistoryEntry
scopeIdstring

Returns

void

Inherited from

Readonly.onAmend


onClear?

readonly optional onClear?: (scopeId) => void

Defined in: types.ts:420

Lifecycle hook fired after clear() on scopeId (and only when the call actually cleared something). When the provider's clear() clears all scopes, this fires once per cleared scope.

Parameters

ParameterType
scopeIdstring

Returns

void

Inherited from

Readonly.onClear


onError?

readonly optional onError?: AmnesiaErrorHandler

Defined in: types.ts:326

Custom error reporter for failures inside redo / undo. See AmnesiaErrorHandler.

Inherited from

AmnesiaStoreOptions.onError


onPush?

readonly optional onPush?: (entry, scopeId) => void

Defined in: types.ts:395

Lifecycle hook fired after a successful push commits a new entry to the past stack of scopeId. Coalesce-merges do not fire this — only the first push of a coalesce burst counts as a logical user action.

Hook payloads are dispatched after the snapshot is updated and after subscribers have been notified, so handlers see a quiescent store. A throw inside the handler is caught and ignored.

The entry's meta (when present) has already been passed through the scope's metaTransform.

Parameters

ParameterType
entryHistoryEntry
scopeIdstring

Returns

void

Inherited from

Readonly.onPush


onRedo?

readonly optional onRedo?: (entry, scopeId) => void

Defined in: types.ts:413

Lifecycle hook fired after a successful redo on scopeId. The entry is the one that was moved from future to past.

Parameters

ParameterType
entryHistoryEntry
scopeIdstring

Returns

void

Inherited from

Readonly.onRedo


onUndo?

readonly optional onUndo?: (entry, scopeId) => void

Defined in: types.ts:407

Lifecycle hook fired after a successful undo on scopeId. The entry is the one that was moved from past to future.

Parameters

ParameterType
entryHistoryEntry
scopeIdstring

Returns

void

Inherited from

Readonly.onUndo


scopes?

optional scopes?: Record<string, ScopeOptions>

Defined in: provider.tsx:67

Per-scope option overrides keyed by scope id. Each entry merges over the provider-level defaults at scope-creation time. Settings are frozen once a scope is first accessed.

Example

<AmnesiaProvider scopes={{ canvas: { capacity: 1000 } }}>
...
</AmnesiaProvider>

store?

optional store?: Amnesia

Defined in: provider.tsx:53

Use a pre-built store as the default scope's backing instance instead of letting the provider create one. Other scopes are still created lazily on demand.

Useful for tests and for sharing a store with non-React code (e.g. a canvas controller). When supplied, this store keeps its capacity / coalesce settings.