Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

useLiveState

useLiveState<Schema>(handle): LiveStateView<ReadonlyLiveState<output<Schema>>>

A live state as the page shows it, kept at each revision while the component is mounted: a banner for “double coins this weekend”, in a room game and a game played alone alike. The initial state while it loads. A room game’s systems read readLiveState instead, the state the room applied.

Type Parameter
Schema extends ZodMiniType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>
Parameter Type
handle LiveStateHandle<string, Schema>

LiveStateView<ReadonlyLiveState<output<Schema>>>

const { state } = useLiveState(events);
return state.doubleCoins ? <Text>Double coins!</Text> : null;