aristocratjnr@portfolio:~/check
$ ./check-display.sh
Detected viewport
~ Narrow layout — some features optimized for desktop
$ cat ./contact-info
Obuobi Ayim David — Software Engineer & QA
$ ./resume --brief
aristocratjnrportfolio|available for work|0%|contact||
← Back to blog
SizeLine
Why I love type-safe routing — Obuobi Ayim DavidJuly 22, 2026 · 5 min read
NAME

Why I love type-safe routing — Typed route patterns mean a broken link is a compile error, not a 3am production incident. Here is the pattern I reach for.

SYNOPSIS

why-i-love-type-safe-routing [TypeScript, DX]

DESCRIPTION

Most routing bugs are silent. You rename a path, forget one link, and suddenly a whole section of your app 404s for users while your local build stays green.

ENCODE THE PATH ONCE

By declaring routes as typed patterns, every href is built from a single source of truth:

let routes = route({
  blog: get("/blog"),
  blogPost: get("/blog/:slug"),
});

// slug is required and typed — no typos survive the compiler
routes.blogPost.href({ slug: post.slug });
  • Renaming a path updates every generated href automatically.
  • Missing or wrong params are caught at build time.
  • Dynamic segments are typed, not strings you hope are correct.

It's a small shift that pays for itself the first time a refactor would have otherwise broken a deep link.

← Why CSS is still a superpower
Why open source helps you grow →

Subscribe to the newsletter

Get notified when I publish new articles — no spam, unsubscribe anytime.