You built a little tool. Someone sets it up just how they like it, and then asks: "Can I send this to my team?"
You could add accounts, a database and an API. Or you can put the whole state in the URL.
That's how share links work on WheelOfSpins, a free spin wheel and random picker. A teacher adds 30 student names, picks colors, turns on "remove winner", and gets one link to paste into the class chat. No sign-up, no server storage. Here's how to build the same thing for your own app.
Step 1: Decide what state actually matters
Don't serialize everything. Pick the smallest object that recreates the experience:
const state = { v: 1, // version, so you can change the format later title: "Who presents today?", entries: ["Asha", "Ben", "Chen", "Dina"], removeWinner: true, colors: ["#7c3aed", "#f59e0b"] }; Short keys keep links short. The v field will save you later, when you change the format and old links still need to open.
Step 2: Encode it safely for a URL
JSON.stringify gives you a string, but quotes, spaces and non-English names don't survive URLs well. Convert to UTF-8 bytes, then to URL-safe Base64:
function toBase64Url(bytes) { let bin = ""; bytes.forEach(b => (bin += String.fromCharCode(b))); return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""); } function fromBase64Url(str) { const bin = atob(str.replace(/-/g, "+").replace(/_/g, "/")); return Uint8Array.from(bin, c => c.charCodeAt(0)); } Going through TextEncoder first matters. Plain btoa() throws on characters like "é" or "शिक्षक", and your users will type names in every language.
Step 3: Compress it (built into the browser)
A list of 30 names can turn into a very long link. Modern browsers ship CompressionStream, so you don't need a library:
async function compress(text) { const stream = new Blob([text]).stream() .pipeThrough(new CompressionStream("deflate-raw")); return new Uint8Array(await new Response(stream).arrayBuffer()); } async function decompress(bytes) { const stream = new Blob([bytes]).stream() .pipeThrough(new DecompressionStream("deflate-raw")); return new Response(stream).text(); } Repetitive data like lists of names and colors often shrinks a lot. Put the pieces together:
async function stateToLink(state) { const packed = await compress(JSON.stringify(state)); return `${location.origin}${location.pathname}#s=${toBase64Url(packed)}`; } async function linkToState(hash) { const raw = new URLSearchParams(hash.slice(1)).get("s"); if (!raw) return null; return JSON.parse(await decompress(fromBase64Url(raw))); } Step 4: Use the hash, not the query string
Notice the #s=.... Everything after # stays in the browser and is never sent to your server. That gives you three things for free:
- Privacy: student names or giveaway entrants don't end up in server logs or analytics.
- No backend: static hosting is enough.
- Instant loads: the page reads
location.hashand rebuilds the state straight away.
Step 5: Treat incoming links as untrusted input
Anyone can craft a URL, so validate before you use it:
function sanitize(s) { if (!s || s.v !== 1 || !Array.isArray(s.entries)) return null; return { v: 1, title: String(s.title ?? "").slice(0, 100), entries: s.entries.slice(0, 500).map(e => String(e).slice(0, 80)), removeWinner: Boolean(s.removeWinner), colors: (s.colors ?? []).filter(c => /^#[0-9a-f]{6}$/i.test(c)).slice(0, 20) }; } And always render entries with textContent, never innerHTML. A name like <img src=x onerror=...> should show up as text, not run.
Step 6: Mind the length
Browsers handle very long URLs, but chat apps, email clients and QR codes don't always. Keep an eye on the size, and if a link gets very long, show a gentle warning ("This link is long and may break in some apps") instead of failing quietly.
The result
One button, one link, zero accounts. The person receiving the link sees exactly what the sender set up, and nothing was stored anywhere.
You can try it on wheelofspins.com: build a wheel, tap share, and open the link on another device. It's free and needs no sign-up.
What else would you put in a URL instead of a database? Let me know in the comments.
