L
L
LazarusNucleros2020-05-08 15:05:09
Vue.js
LazarusNucleros, 2020-05-08 15:05:09

How to pass data from backend to vuex on first render?

Welcome all.

There is a site on Wordpress with Woocommerce, as well as a self-written plugin that implements additional functionality.

Front plan to do with Vue (Vue, Vuex)

The site is not a SPA.

Actually, the question arose - is it possible to somehow transfer data during the first rendering not to components (using props), but directly to the Vuex store? At the same time, it would be desirable to avoid data duplication.

Or is it worth abandoning the multi-page application on Vue and implementing SSR using NuxtJs? But how to make it work if the hosting only has php ?

Thanks in advance for your replies.

PS - I'm new to this business, pliz don't throw slippers if I'm talking nonsense. I didn't on purpose :(

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2020-05-08
@AndrewRusinas

Well, hosting for anyone will have to change and rent a VPS.
The question is not really clear. If you use Vue, then you can call the beforeEach method on the Vue Router and call the necessary methods of the store there, which will save data to it (with the condition that this data is not there, so as not to load the backend).
With nuxt it's a bit more complicated, you have to make middleware there. You can read more in the documentation .
What specifically to use - depends on the task. Of course, an online store needs SSR if you need traffic not only from Google (and, as practice shows, Google also works better with SSR).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question