/custom lets users enter 10–30 words and generate a link. Someone else opens the link and plays the same set. No login. So the question is: where do those 30 words live?
The lightest option is URL fragment encoding:
// encode const payload = JSON . stringify ( words ) ; const encoded = compressToEncodedURIComponent ( payload ) ; // lz-string const url = `${location.origin}/custom#${encoded}` ;
// decode (after hydration) const raw = location . hash . slice ( 1 ) ; if ( raw ) { const words = JSON . parse ( decompressFromEncodedURIComponent ( raw ) ) ; validate ( words ) ; // required: 10–30 items, per-word length cap, strip control chars }
Enter fullscreen mode
Exit fullscreen mode
I use the fragment, not the query string, because fragments never leave the browser — the word set stays invisible to the server. lz-string 's compressToEncodedURIComponent outputs URL-safe characters, no extra escaping needed.
The real cost of this approach : 30 words compressed is still a few hundred characters.…