-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement nuxtServerInit Action to load data from server-side on the initial load #1080
Comments
There should be a way to add this for both setup and option stores. Maybe a specific name for an action is enough. One important thing to note is that given the nature of stores in pinia, you need explicitly say somewhere in your server code which stores must run this action as they need to be instantiated on the server. By default, if no store is ever user, no store is ever instantiated and therefore no server init function can run. |
Thanks for this workaround, I would also love to see the feature implemented |
Did the stores are shared? |
This solution is workaround for me: nuxt.config.ts
plugins/init.server.ts
|
@nestle49 Can this be placed as a nitro plugin in a nuxt project instead? |
Any update on this ? |
It looks like currently, we can't use a store with
Tested with Nuxt/Bridge btw. |
What problem is this solving
Implement something like NuxtServerInit Action, so we can load data from the server-side and give it directly to the client-side on the initial load/render.
Proposed solution
Include an
index.js
file inside/stores
with anuxtServerInit
action which will be called from the server-side on the initial load.Describe alternatives you've considered
The only way I found to do this is using Pinia with Vuex, using the
nuxtServerInit
from Vuex:The text was updated successfully, but these errors were encountered: