localStorage
, sessionStorage
or any other mechanism you wish.NgxsStoragePluginModule
into your app module like:key
: State name(s) to be persisted. You can pass a string or array of strings that can be deeply nested via dot notation. If not provided, it defaults to all states using the @@STATE
key.storage
: Storage strategy to use. This defaults to LocalStorage but you can pass SessionStorage or anything that implements the StorageEngine API.deserialize
: Custom deserializer. Defaults to JSON.parse
serialize
: Custom serializer. Defaults to JSON.stringify
migrations
: Migration strategiesbeforeSerialize
: Interceptor executed before serializationafterDeserialize
: Interceptor executed after deserializationkey
option is used to determine what states should be persisted in the storage. key
shouldn't be a random string, it has to coincide with your state names. Let's look at the below example:key
option, so it's enough just to write:NovelsState
? Then we would have needed to pass its name to the key
option:NovelsState
and DetectivesState
:StorageEngine
interface.animals
to newAnimals
.version
: The version we are migratingversionKey
: The identifier for the version key (Defaults to 'version')migrate
: A function that accepts a state and expects the new state in return.key
: The key for the item to migrate. If not specified, it takes the entire storage state.