Reusing Nuxt server state on the client with a setup store #1213
-
At Openverse, we are converting 1 our state management from Vuex to Pinia. We are using Nuxt 2 with Composition API, and have converted most stores to setup stores. However, we are now facing a problem with hydrating the state in a setup store. The callback inside the store setup function runs both on the server and on the client. If we create a state object using What is the correct way of reusing the Nuxt server state on the client in a setup store? I tried a hack using a state from
I used Thank you for all your work on the Vue ecosystem. Footnotes |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I've found the solution for this problem in Pinia documentation: https://pinia.vuejs.org/cookbook/composables.html#ssr The
(The code is from the Composables/SSR page that is linked above). |
Beta Was this translation helpful? Give feedback.
I've found the solution for this problem in Pinia documentation: https://pinia.vuejs.org/cookbook/composables.html#ssr
The
ref
values that should not be re-initialized on the client side need to useskipHydration
helper function:(The code is from the Compos…