@pinia/root / pinia
pinia
Index
Enumerations
Enumeration | Description |
---|---|
MutationType | Possible types for SubscriptionCallback |
Interfaces
Interface | Description |
---|---|
_StoreOnActionListenerContext | Actual type for StoreOnActionListenerContext. Exists for refactoring purposes. For internal use only. For internal use only |
_StoreWithState | Base store with state and functions. Should not be used directly. |
_SubscriptionCallbackMutationBase | Base type for the context passed to a subscription callback. Internal type. |
DefineSetupStoreOptions | Options parameter of defineStore() for setup stores. Can be extended to augment stores with the plugin API. |
DefineStoreOptions | Options parameter of defineStore() for option stores. Can be extended to augment stores with the plugin API. |
DefineStoreOptionsBase | Options passed to defineStore() that are common between option and setup stores. Extend this interface if you want to add custom options to both kinds of stores. |
DefineStoreOptionsInPlugin | Available options when creating a pinia plugin. |
MapStoresCustomization | Interface to allow customizing map helpers. Extend this interface with the following properties: |
Pinia | Every application must own its own pinia to be able to create stores |
PiniaCustomProperties | Interface to be extended by the user when they add properties through plugins. |
PiniaCustomStateProperties | Properties that are added to every store.$state by pinia.use() . |
PiniaPlugin | Plugin to extend every store. |
PiniaPluginContext | Context argument passed to Pinia plugins. |
SetupStoreDefinition | Return type of defineStore() with a setup function. - Id is a string literal of the store's name - SS is the return type of the setup function |
StoreDefinition | Return type of defineStore() . Function that allows instantiating a store. |
StoreProperties | Properties of a store. |
SubscriptionCallbackMutationDirect | Context passed to a subscription callback when directly mutating the state of a store with store.someState = newValue or store.$state.someState = newValue . |
SubscriptionCallbackMutationPatchFunction | Context passed to a subscription callback when store.$patch() is called with a function. |
SubscriptionCallbackMutationPatchObject | Context passed to a subscription callback when store.$patch() is called with an object. |
Type Aliases
Type alias | Description |
---|---|
_ActionsTree | Type of an object of Actions. For internal usage only. For internal use only |
_Awaited | - |
_DeepPartial | Recursive Partial<T> . Used by ['$patch']. |
_ExtractActionsFromSetupStore | For internal use only |
_ExtractActionsFromSetupStore_Keys | Type that enables refactoring through IDE. For internal use only |
_ExtractGettersFromSetupStore | For internal use only |
_ExtractGettersFromSetupStore_Keys | Type that enables refactoring through IDE. For internal use only |
_ExtractStateFromSetupStore | For internal use only |
_ExtractStateFromSetupStore_Keys | Type that enables refactoring through IDE. For internal use only |
_GettersTree | Type of an object of Getters that infers the argument. For internal usage only. For internal use only |
_MapActionsObjectReturn | For internal use only |
_MapActionsReturn | For internal use only |
_MapStateObjectReturn | For internal use only |
_MapStateReturn | For internal use only |
_MapWritableStateObjectReturn | For internal use only |
_MapWritableStateReturn | For internal use only |
_Method | Generic type for a function that can infer arguments and return type |
_Spread | For internal use only. |
_StoreObject | For internal use only. |
_StoreWithActions | Store augmented for actions. For internal usage only. For internal use only |
_StoreWithGetters | Store augmented with getters. For internal usage only. For internal use only |
_UnwrapAll | Type that enables refactoring through IDE. For internal use only |
PiniaStorePlugin | Plugin to extend every store. |
StateTree | Generic state of a Store |
Store | Store type to build a store. |
StoreActions | Extract the actions of a store type. Works with both a Setup Store or an Options Store. |
StoreGeneric | Generic and type-unsafe version of Store. Doesn't fail on access with strings, making it much easier to write generic functions that do not care about the kind of store that is passed. |
StoreGetters | Extract the getters of a store type. Works with both a Setup Store or an Options Store. |
StoreOnActionListener | Argument of store.$onAction() |
StoreOnActionListenerContext | Context object passed to callbacks of store.$onAction(context => {}) TODO: should have only the Id, the Store and Actions to generate the proper object |
StoreState | Extract the state of a store type. Works with both a Setup Store or an Options Store. Note this unwraps refs. |
SubscriptionCallback | Callback of a subscription |
SubscriptionCallbackMutation | Context object passed to a subscription callback. |
Variables
Variable | Description |
---|---|
PiniaVuePlugin | Vue 2 Plugin that must be installed for pinia to work. Note you don't need this plugin if you are using Nuxt.js. Use the buildModule instead: https://pinia.vuejs.org/ssr/nuxt.html. |
Functions
Function | Description |
---|---|
acceptHMRUpdate | Creates an accept function to pass to import.meta.hot in Vite applications. |
createPinia | Creates a Pinia instance to be used by the application |
defineStore | Creates a useStore function that retrieves the store instance |
disposePinia | Dispose a Pinia instance by stopping its effectScope and removing the state, plugins and stores. This is mostly useful in tests, with both a testing pinia or a regular pinia and in applications that use multiple pinia instances. Once disposed, the pinia instance cannot be used anymore. |
getActivePinia | Get the currently active pinia if there is any. |
mapActions | Allows directly using actions from your store without using the composition API (setup() ) by generating an object to be spread in the methods field of a component. |
mapGetters | Alias for mapState() . You should use mapState() instead. |
mapState | Allows using state and getters from one store without using the composition API (setup() ) by generating an object to be spread in the computed field of a component. |
mapStores | Allows using stores without the composition API (setup() ) by generating an object to be spread in the computed field of a component. It accepts a list of store definitions. |
mapWritableState | Allows using state and getters from one store without using the composition API (setup() ) by generating an object to be spread in the computed field of a component. |
setActivePinia | Sets or unsets the active pinia. Used in SSR and internally when calling actions and getters |
setMapStoreSuffix | Changes the suffix added by mapStores() . Can be set to an empty string. Defaults to "Store" . Make sure to extend the MapStoresCustomization interface if you are using TypeScript. |
shouldHydrate | Returns whether a value should be hydrated |
skipHydrate | Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a stateful object in the store but it isn't really state. e.g. returning a router instance in a setup store. |
storeToRefs | Creates an object of references with all the state, getters, and plugin-added state properties of the store. Similar to toRefs() but specifically designed for Pinia stores so methods and non reactive properties are completely ignored. |