Skip to main content
The State component stores session state that persists across function calls for the same user.

Basic usage

Constructor

Any
default:"None"
Initial state value of any type. The value is deepcopied
int | float | None
default:"None"
Seconds to keep state after creation/update. If None, stored indefinitely
Callable[[Any], None] | None
default:"None"
Function called when state is deleted, receives state value as argument

Events

  • change - Triggered when state value changes

Examples

Chat history

With TTL

With cleanup callback