pinia-plugin-persistedstate icon indicating copy to clipboard operation
pinia-plugin-persistedstate copied to clipboard

[nuxt] "Hydration text content mismatch" in client side with nuxt 3

Open DonSalvador opened this issue 3 years ago • 2 comments

Describe the bug

When using the plugin on the client side with Nuxt 3, a mismatch in hydration appears.

Reproduction

https://stackblitz.com/edit/nuxt-starter-9mvexw?file=composables/authStore.ts

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.10 - /bin/yarn
    npm: 7.17.0 - /bin/npm

Used Package Manager

npm

Validations

DonSalvador avatar Aug 14 '22 08:08 DonSalvador

Ok i got time to try it and it is indeed weird, does it cause any problem besides the warning ?

prazdevs avatar Sep 01 '22 13:09 prazdevs

No warning. I ended up using <client-only> which I think is appropriate since the data will only be available on the client.

DonSalvador avatar Sep 05 '22 17:09 DonSalvador

@DonSalvador try registering the plugin like this instead:

export default defineNuxtPlugin((nuxtApp: any) => {
  nuxtApp.$pinia.use(piniaPluginPersistedstate)
})

aka. on nuxtApp.$pinia instead of on $pinia, that resolved it for me...

toniengelhardt avatar Nov 14 '22 10:11 toniengelhardt

v3 is now release with available nuxt module as well! docs are also deployed 🚀 closing this for now, if still having issues, feel free to reopen

prazdevs avatar Nov 26 '22 01:11 prazdevs