November 2017
Beginner to intermediate
398 pages
8h 42m
English
The store state is serialized by the server on a __INITIAL_STATE__ variable in the HTML page. We can use this to set the state even before the app is mounted, so the components will have access to it.
Edit the entry-client.js file and use the store.replaceState method before mounting the app:
createApp({ locale,}).then(({ app, store }) => { if (window.__INITIAL_STATE__) { store.replaceState(window.__INITIAL_STATE__) } app.$mount('#app')})
Now, the store will have the data sent by the server.
Read now
Unlock full access