Class

State

State(hanko, flowName, response, optionsopt)

Represents a state in a flow with associated actions and properties.
Constructor

# new State(hanko, flowName, response, optionsopt)

Parameters:
Name Type Attributes Default Description
hanko Hanko The Hanko instance for API interactions.
flowName FlowName The name of the flow this state belongs to.
response FlowResponse.<TState> The flow response containing state data.
options StateInitConfig <optional>
{} Configuration options for state initialization.

View Source lib/flow-api/State.ts, line 15

Classes

State

Methods

# dispatchAfterStateChangeEvent()

Dispatches an event after the state has changed.

View Source lib/flow-api/State.ts, line 407

# removeFromLocalStorage() → {void}

Removes the current state from localStorage.

View Source lib/flow-api/State.ts, line 428

void

# saveToLocalStorage() → {void}

Saves the current state to localStorage.

View Source lib/flow-api/State.ts, line 421

void

# serialize() → {SerializedState}

Serializes the current state into a storable format.

View Source lib/flow-api/State.ts, line 414

The serialized state object.
SerializedState

# async static create(hanko, flowName, configopt) → {Promise.<AnyState>}

Creates a new state instance, using cached or fetched data.
Parameters:
Name Type Attributes Default Description
hanko Hanko The Hanko instance for API interactions.
flowName FlowName The name of the flow.
config StateCreateConfig <optional>
{} Configuration options.
dispatchAfterStateChangeEvent boolean <optional>
true Whether to dispatch an event after state change.
excludeAutoSteps AutoStepExclusion <optional>
null States to exclude from auto-step processing, or "all".
cacheKey string <optional>
"hanko-flow-state" Key for localStorage caching.
loadFromCache boolean <optional>
true Whether to attempt loading from cache.

View Source lib/flow-api/State.ts, line 468

A promise resolving to the created state.
Promise.<AnyState>

# async static deserialize(hanko, serializedState, configopt) → {Promise.<AnyState>}

Deserializes a state from a serialized state object.
Parameters:
Name Type Attributes Default Description
hanko Hanko The Hanko instance for API interactions.
serializedState SerializedState The serialized state data.
config StateCreateConfig <optional>
{} Configuration options.
dispatchAfterStateChangeEvent boolean <optional>
true Whether to dispatch an event after state change.
excludeAutoSteps AutoStepExclusion <optional>
null States to exclude from auto-step processing, or "all".
cacheKey string <optional>
"hanko-flow-state" Key for localStorage caching.
loadFromCache boolean <optional>
true Whether to attempt loading from cache.

View Source lib/flow-api/State.ts, line 483

A promise resolving to the deserialized state.
Promise.<AnyState>

# async static fetchState(hanko, href, bodyopt) → {Promise.<FlowResponse.<any>>}

Fetches state data from the server.
Parameters:
Name Type Attributes Description
hanko Hanko The Hanko instance for API interactions.
href string The endpoint to fetch from.
body any <optional>
Optional request body.

View Source lib/flow-api/State.ts, line 493

A promise resolving to the flow response.
Promise.<FlowResponse.<any>>

# async static initializeFlowState(hanko, flowName, response, optionsopt) → {Promise.<AnyState>}

Initializes a flow state, processing auto-steps if applicable.
Parameters:
Name Type Attributes Default Description
hanko Hanko The Hanko instance for API interactions.
flowName FlowName The name of the flow.
response FlowResponse.<any> The initial flow response.
options StateInitConfig <optional>
{} Configuration options.
dispatchAfterStateChangeEvent boolean <optional>
true Whether to dispatch an event after state change.
excludeAutoSteps AutoStepExclusion <optional>
null States to exclude from auto-step processing, or "all".
previousAction ActionInfo <optional>
null Information about the previous action.
isCached boolean <optional>
false Whether the state is loaded from cache.
cacheKey string <optional>
"hanko-flow-state" Key for localStorage caching.

View Source lib/flow-api/State.ts, line 445

A promise resolving to the initialized state.
Promise.<AnyState>

# static readFromLocalStorage(cacheKey) → {SerializedState|undefined}

Retrieves and parses state data from localStorage.
Parameters:
Name Type Description
cacheKey string The key used to store the state in localStorage.

View Source lib/flow-api/State.ts, line 453

The parsed serialized state, or undefined if not found or invalid.
SerializedState | undefined