CreateStoreType

Interface representing the data structure of thecreateStore()method's output.

src/types.ts
import type { UseBoundStore } from 'zustand'
 import type {
  StoreApiWithPersist,
  StoreApiWithSubscribeWithSelector,
} from 'zustand/middleware'

type CreateStoreType<StoreDataType> = UseBoundStore<
  StoreType<StoreDataType>
> & {
  persist?: StoreApiWithPersist<StoreType<StoreDataType>>['persist']
  subscribeWithSelector?: StoreApiWithSubscribeWithSelector<
    StoreType<StoreDataType>
  >['subscribe']
}

API reference

The following elements are provided on top of the regular ones returned by zustand's createStore().

persist

persist?: StoreApiWithPersist<StoreType<StoreDataType>>['persist']

Only provided if you've enabled thepersistmiddleware.

The detailed API reference is available here:

subscribeWithSelector

subscribeWithSelector?: StoreApiWithSubscribeWithSelector<
  StoreType<StoreDataType>
>['subscribe']

Only provided if you've enabled thesubscribemiddleware.

It uses the exact same API as the new subscribeWithSelector() middleware introduced with zustand 3.6.0. The only difference is that zfy allows you to plug it in by simply adding a boolean to createStore() 3rd (options) argument.

The detailed API reference is available here:

Last updated