Skip to content Skip to sidebar Skip to footer

How To Persist Ui Component State Data In Sapper?

In a Sapper app, I want to be able to persist the state of some UI components so I can navigate the app without losing state when the user returns to the pages using those componen

Solution 1:

Provide a dummy store for SSR.

It is always possible to do feature detection with something like typeof localStorage !== 'undefined'.

Your component code will re-run in the browser, even if the page was SSR'd. This means that if it is fed a different store, the browser-only values will take over and update existing state (inherited from the server).

See this answer for an example.

Post a Comment for "How To Persist Ui Component State Data In Sapper?"