This Gist shows one method of setting up localStorage with Sapper using if (process.browser).
Here is the assumed file structure inside the src directory used in this Gist:
└── src
├── components
│ └── Btn.svelte
├── routes
│ └── _layout.svelte
└── stores
└── store.js
Wonderful, thanks!
If anyone is having trouble still, you can try the
onMount
method from Svelte in lieu ofprocess.browser
. Then, the rest is the same.