pinia-plugin-persist-state 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,3 +4,13 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.1]
9
+
10
+ ### Fixed
11
+ - Prevented `remember is not a function` at component setup by making store method augmentation available immediately on the client.
12
+ - Moved persisted-state bootstrap behind hydration lifecycle execution (`hydrate`) instead of running it in the store constructor.
13
+ - Hardened browser-runtime detection (`typeof window !== 'undefined'`) for SSR compatibility.
14
+
15
+ ### Changed
16
+ - Test setup now uses `createHydrationPlugin(..., { runtimeEnvironment: 'client' })` to validate client-only subscribers in Node test runtime.
package/README.md CHANGED
@@ -11,6 +11,7 @@ A small Pinia plugin that adds persistence and optional encryption to your Pinia
11
11
  - Per-store options via `storeOptions` when defining a store
12
12
  - Augmented store API: `persistState`, `remember`, `removePersistedState`, `watch`, `stopWatch`
13
13
  - Simple initialization through `createPersistStatePlugin(dbName?, cryptKey?)`
14
+ - SSR-safe hydration flow: methods are injected immediately on client, persistence restore is executed during hydration lifecycle
14
15
 
15
16
  ---
16
17
 
@@ -28,7 +29,7 @@ Then register the plugin with Pinia in your app entry (see `src/main.ts`):
28
29
  import { createApp } from 'vue'
29
30
  import { createPinia } from 'pinia'
30
31
  import { createPlugin } from 'pinia-plugin-subscription'
31
- import { createPersistStatePlugin } from 'persist-pinia-state'
32
+ import { createPersistStatePlugin, PLUGIN_NAME } from 'persist-pinia-state'
32
33
 
33
34
  const app = createApp(App)
34
35
  const pinia = createPinia()
@@ -37,11 +38,24 @@ const pinia = createPinia()
37
38
  // and an optional `cryptKey` to enable encryption support
38
39
  pinia.use(createPlugin([
39
40
  createPersistStatePlugin('localStorage', 'my-secret-key')
40
- ], true))
41
+ ]))
41
42
 
42
43
  app.use(pinia)
43
44
  ```
44
45
 
46
+ For Nuxt/SSR projects, prefer `createHydrationPlugin` from `pinia-plugin-subscription` when you need runtime overrides:
47
+
48
+ ```ts
49
+ import { createHydrationPlugin } from 'pinia-plugin-subscription'
50
+ import { createPersistStatePlugin } from 'persist-pinia-state'
51
+
52
+ pinia.use(createHydrationPlugin([
53
+ createPersistStatePlugin('localStorage', 'my-secret-key')
54
+ ], {
55
+ runtimeEnvironment: import.meta.client ? 'client' : 'server'
56
+ }))
57
+ ```
58
+
45
59
  ---
46
60
 
47
61
  ## 📚 Usage