Skip to content

storeOptions

storeOptions<TSchema, TContext, TSyncPayloadSchema>(options): RegistryStoreOptions<TSchema, TContext, TSyncPayloadSchema>

Defined in: packages/@livestore/livestore/src/store/StoreRegistry.ts:385

Helper for defining reusable store options with full type inference. Returns options that can be passed to useStore() or storeRegistry.preload().

TSchema extends LiveStoreSchema<DbSchema, EventDefRecord>

The LiveStore schema type

TContext = { }

User-defined context attached to the store

TSyncPayloadSchema extends Schema<any, any, never> = Schema<JsonValue, JsonValue, never>

Schema for the sync payload sent to the backend

RegistryStoreOptions<TSchema, TContext, TSyncPayloadSchema>

The store configuration options

RegistryStoreOptions<TSchema, TContext, TSyncPayloadSchema>

The same options object, unchanged

At runtime this is an identity function that returns the input unchanged. Its value lies in enabling TypeScript’s excess property checking to catch typos and configuration errors, while allowing options to be shared across useStore(), storeRegistry.preload(), storeRegistry.getOrLoad(), etc.

export const issueStoreOptions = (issueId: string) =>
storeOptions({
storeId: `issue-${issueId}`,
schema,
adapter,
unusedCacheTime: 30_000,
})
// In a component
const issueStore = useStore(issueStoreOptions(issueId))
// In a route loader or event handler
storeRegistry.preload({
...issueStoreOptions(issueId),
unusedCacheTime: 10_000,
});