Build failing when pinia store is used in modules
See original GitHub issuePlease check this issue here, its either pinia related or vite-ssg - but in any case I couldn’t figure out the best way to install global middleware that uses the store, that doesn’t throw this error on build.
Any suggestions on how to access the store in a router.beforeEach
, which is initialized with the app?
And in case the store uses localStorage initialization which won’t be available during generation, any best practices there?
Would be great if one could direct me to an example repo with such middleware.
Issue Analytics
- State:
- Created 2 years ago
- Comments:21 (1 by maintainers)
Top Results From Across the Web
Can't use vue-router and pinia inside a single store
They can't be used at the module route, and are often used within component setup functions and store actions. You don't need to...
Read more >Using a store outside of a component - Pinia
The easiest way to ensure this is always applied is to defer calls of useStore() by placing them inside functions that will always...
Read more >Module: pinia
Doesn't fail on access with strings, making it much easier to write generic functions that do not care about the kind of store...
Read more >Introduction - Pinia
A timeline to track actions, mutations; Stores appear in components where they are used; Time travel and easier debugging. Hot module replacement.
Read more >Pinia not installed? : r/vuejs - Reddit
Did you forget to install pinia? const pinia = createPinia() app.use(pinia) This will fail in production. at useStore ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That did the trick!
Try awaiting router only on server side with
if (!ctx.isClient)