State persistence between sessions, with nextjs and mobx

237 Views Asked by At

Has anybody else managed to get state persistence between sessions, with nextjs and mobx?

I keep running into issues with this. Any help would be appreciated.

1

There are 1 best solutions below

4
Honorable con On

You have to save it in localStorage, and initialize state with it :

example :

const [state, setState] = useState(localStorage.getItem(‘state’));