Skip to content

Can you make stores available in all components? #1197

Closed Answered by posva
edwh asked this question in Help and Questions
Discussion options

You must be logged in to vote

Setting this.$store or similar is fine for prototyping but cancels out some of the improvements pinia brings like automatic dynamic modules and especially typing and autocompletion.

One solution that works with both is using auto imports. By setting the dirs option to the folder where your stores are defined, you should be able to directly call useMyStore() everywhere needed and still benefit from TypeScript and better code splitting (dynamic modules)

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@edwh
Comment options

@dreambo8563
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by posva
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants