Can I use Pinia without installing it? #1085
-
Hi, I'm wondering if I could use Pinia without installing it via the usual The reason I ask is because all components are exported to Custom Elements so there's no Vue instance to install the plugin. This comment by @LinusBorg might explain my motivation: vuejs/vue-web-component-wrapper#93 (comment) Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
You could technically do Note that if you are shipping components that use Pinia, you should consider using provide/inject instead. If you still want to use pinia, users of your components should install the pinia instance themselves if they are building a Vue application. |
Beta Was this translation helpful? Give feedback.
-
Hello, I'm having the same use case, we would like to have web components and share a store between them.
I have a dead simple exemple.
It's probably a dumb mistake on my part, but any help would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
You could technically do
setActivePinia(createPinia())
. Pinia Plugins require an app instance to be effective, so you might need to write topinia._a
a fake app and make sure to do it before any call topinia.use()
.Note that if you are shipping components that use Pinia, you should consider using provide/inject instead. If you still want to use pinia, users of your components should install the pinia instance themselves if they are building a Vue application.