Skip to content

API Reference ​

Welcome to the API Reference for pinia-plugin-state-persistence. Below is an overview of the main API features and utilities provided by the plugin.

Table of Contents ​

createStatePersistence ​

Overview ​

The createStatePersistence function initializes the state persistence plugin for Pinia. This function accepts a global configuration object that determines how the state is stored and retrieved for all stores.

Syntax ​

ts
import { 
createStatePersistence
} from 'pinia-plugin-state-persistence'
createStatePersistence
(globalOptions: GlobalPersistOptions)

Parameters ​

ParameterTypeDescription
globalOptionsGlobalConfigurationA configuration object to define global persistence behavior (see Configuration).

Notes ​

  • The createStatePersistence function accepts global configuration options to apply consistent settings across stores.
  • For store-specific behavior, refer to PersistOptions.
  • The key in the globalOptions object acts as a prefix for all store keys, ensuring consistent naming and avoiding conflicts.
  • The plugin supports both synchronous (localStorage) and asynchronous (localForage) storage options.

For more details on using the plugin, see the Guide.