A
A
Alexander Silaev2021-06-16 00:51:32
Vue.js
Alexander Silaev, 2021-06-16 00:51:32

How to implement SSR without using global storage (using Vue 3 as an example)?

Good day!
For Vue 3, there was an opinion that the global storage (like Vuex) is no longer needed and can easily be replaced by the built-in tools of Vue 3 itself ( example or example ).
If I adhere to this opinion and build my application without a single global store, then how can I implement client-side data hydration?

Using Vuex, everything is simple:
- I store all the data in the global storage
- on the server I save the entire storage state per page
- on the client I pull up the state saved on the server to the storage
- profit

Without Vuex, it's not at all clear how to "throw" data to the client. There are only options in my head that, in fact, repeat what Vuex does ... just a little differently.

Therefore, the question is: are there proven practices/patterns that will allow you to implement a full-fledged SSR (stateful from server to client) without global storage?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stefan, 2021-06-16
@MEDIOFF

What about Vuex and SSR? Vuex simply stores the state - no Vuex has no state, you do not transfer anything to the client from the server, the client goes to you every time for a new page, and you give it to him already filled with all the data - this is SSR, for example, you usually have Vue receives a list of products from the server, as it receives cards, with SSR you give the page immediately with the cards ready.
In fact, SSR is needed for SEO for the most part, since I don’t know people who cut off js in the browser
. If SSR is needed, then I recommend not reinventing the wheel, but looking towards Nuxt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question