storeOptions
storeOptions<
TSchema,TContext,TSyncPayloadSchema>(options):RegistryStoreOptions<TSchema,TContext,TSyncPayloadSchema>
Defined in: livestore/dist/store/StoreRegistry.d.ts:188
Helper for defining reusable store options with full type inference. Returns
options that can be passed to useStore() or storeRegistry.preload().
Type Parameters
Section titled “Type Parameters”TSchema
Section titled “TSchema”TSchema extends LiveStoreSchema<DbSchema, EventDefRecord>
The LiveStore schema type
TContext
Section titled “TContext”TContext = { }
User-defined context attached to the store
TSyncPayloadSchema
Section titled “TSyncPayloadSchema”TSyncPayloadSchema extends Schema<any, any, never> = Schema<JsonValue, JsonValue, never>
Schema for the sync payload sent to the backend
Parameters
Section titled “Parameters”options
Section titled “options”RegistryStoreOptions<TSchema, TContext, TSyncPayloadSchema>
The store configuration options
Returns
Section titled “Returns”RegistryStoreOptions<TSchema, TContext, TSyncPayloadSchema>
The same options object, unchanged
Remarks
Section titled “Remarks”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.
Example
Section titled “Example”export const issueStoreOptions = (issueId: string) => storeOptions({ storeId: `issue-${issueId}`, schema, adapter, unusedCacheTime: 30_000, })
// In a componentconst issueStore = useStore(issueStoreOptions(issueId))
// In a route loader or event handlerstoreRegistry.preload({ ...issueStoreOptions(issueId), unusedCacheTime: 10_000,});