Post

We want people to be able to share the settings for our games and tools, or save their own settings. To account for all the options, we have two ways of initializing state using Sveltekit features: shared URL and Local Storage stores. If people have a better way to do this, let me know!

For shared URLs, we The URLs encode the settings and then read them in Sveltekit's load function for the page, doing some validity checks, which are passed in on the data prop. We assume if you visit via a shared URL, we'll overwrite Local Storage state. Example: phonicsandstuff.com/sound-letter...

0 reposts1 like

Argh, typos. I do wish Bluesky had an edit option. I meant... For shared URLs, we encode the settings and then read them in Sveltekit's load function for the page

When we mount the page, we check if we received data from load. If we didn't, then we check Local Storage (again verifying data), if nothing is there, we initialize it and put in a default. We use a store for each page's menus, and so far we aren't near the limit of local storage, but we'll see.

This is my cobbled together solution to let users share stuff, while maintaining their local device settings. It feels a bit janky, so would love suggestions to improve it or more efficient ways to implement.