Stone.js API
    Preparing search index...

    Interface StoreDefinition<State>

    What a store declares about itself.

    interface StoreDefinition<
        State extends Record<string, any> = Record<string, any>,
    > {
        name: string;
        perRequest?: boolean;
        state: State;
    }

    Type Parameters

    • State extends Record<string, any> = Record<string, any>
    Index
    name: string

    The name it is resolved under, in the container and in the snapshot.

    perRequest?: boolean

    Whether the server keeps one instance per request. Default true, and the default matters.

    A store held as a module-level singleton leaks one visitor's state into the next visitor's page during server rendering. It is the most common SSR state bug there is, and it is invisible in development because there is only ever one request at a time. The kernel already gives an ephemeral container per event, so honouring it costs nothing and closes the hole by default. Set false only for state that is genuinely process-wide, like a feature-flag cache.

    state: State

    The state it starts from.