Using the Browser Address Bar as a Save File in a 9.6 KB TypeScript App
Architecture lessons from building 404 — Not Found: non-throwing URL hash parsers, pure procedural rules, and 98 deterministic Vitest tests with zero runtime dependencies.
Treating Untrusted URL Edits as First-Class Input
In 404 — Not Found, players literally edit window.location.hash to move past walls and unlock doors. Because users type directly into the address bar, malformed strings, missing parameters, and out-of-range coordinates are normal gameplay — never exceptions.
By writing a defensive parser that always clamps coordinates and falls back cleanly to valid defaults, the state layer never throws regardless of what a user types.
Deriving World State Instead of Duplicating It
Rather than storing mutable door or plate flags separately from the URL, every collision check and door state is derived purely from the current parsed state and seeded room geometry. That pure boundary allowed 98 Vitest unit tests — including 44 procedural generation invariants — to run in milliseconds without a browser.