Skip to content
Advertisement

Nuxt SSR app does not share date from store between two windows

I have a Nuxt SSR app which need to open new window on link click, but new window does not have actual data in the store. There are only default values. How can I share actual values in the store between this two pagaes?

This is the code of new page which ask for currency value:

JavaScript

Advertisement

Answer

Yes, if you open a new tab, Vue will need to re-hydrate from the start, you cannot transfer the state from one page to the other with just Vue.

You’ll need to use something to persist the data. A quick search brings up this exact answer with quite more details: https://stackoverflow.com/a/66872372/8816585

So, using localStorage could be a simple and quick way of getting things done

JavaScript

Then, on the other side

JavaScript

Query params could also be a solution with

JavaScript

And getting it on the other side with

JavaScript

A conditional checking if coolData is populated in the other page (yet, same file) and everything should be working fine.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement