Skip to content

Early loading of data into stores #988

Discussion options

You must be logged in to vote

I think you could accomplish this by booting up Pinia and the relevant store outside of Vue:

import { createPinia } from 'pinia'

// Init our pinia instance
const pinia = createPinia()
const store = useStore(pinia) // pass the instance to our store, instead of inferring it from our Vue app

whenDataLoaded.then(data => {
  store.$state = data // replace the store's state without our data
  createApp(App).use(pinia).mount('#app')
})

See also: https://pinia.vuejs.org/core-concepts/outside-component-usage.html

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Matt-Deacalion
Comment options

Answer selected by Matt-Deacalion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants