Definition
What it is
Routes come in two flavours. Static routes match an exact path (/about, /contact). Dynamic routes use patterns with parameters (/users/{id}, /posts/{slug}) and extract values. A router is the component that takes an incoming request and selects the matching route by comparing method + path.
In server-rendered frameworks (Laravel, Rails, Django), routes live in dedicated files (routes/web.php, config/routes.rb, urls.py). In file-based frameworks (Next.js, EIK CMS, Hugo), the file path is the route. In a REST API, routes may be auto-derived from resources.
Why it matters
Routing errors are the most common cause of "it works locally, 404 in production" — different configs, different orderings. A route evaluated 20 times per request (because the router iterates the whole list) is a hidden latency source. A route that matches too loosely (/{path}/*) can shadow protected routes.
Static vs dynamic vs file-based
Type | Example | Framework |
|---|---|---|
Static |
| All |
Dynamic |
| Express, Laravel, Rails |
Regex |
| Framework-specific |
File-based |
| EIK CMS, Hugo, Next.js |
Resource |
| Rails |
The dispatch flow
graph LR R[Request] --> RT[Router] RT --> M[Match pattern] M --> MW[Middleware] MW --> H[Handler] H --> Resp[Response] style RT fill:#E8F5E9
How to design routes well
Routes that age
Nouns, not verbs
GET /users/42, notGET /getUser?id=42.HTTP method = action
GET read, POST create, PUT replace, PATCH update, DELETE remove.
Stable identifiers in path
Slugs and IDs, not state (
/users/current-user-with-name-ana).Order matters
Specific routes before generic:
/users/mebefore/users/{id}.Version the contract
/v1/users/42lets you break without breaking clients.
Common failures
Origin
The word comes from Old French rute / Latin rupta via — a cleared road. Network routing (IP routing, 1970s) gave the term its computing sense: choosing the path a packet takes. Web frameworks (Rails, 2004; Express, 2010) adopted it for URL-to-handler mapping.
Routing is the process of selecting a path for traffic in a network or between or across multiple networks.
— RFC 791, *Internet Protocol*, 1981 (paraphrase)
Evidence
FAQ
- Route vs path?
Path is the URL part; route is the (method + pattern + handler) triple.
- File-based vs config-based?
File-based is convention-over-config (Next.js, Hugo); config-based is explicit (Express, Rails).
- When to use wildcards?
Only for intentional catch-alls (
/admin/{path*}), never as default.- How many routes max?
No hard limit; keep it under 500 for maintainability.
Connections
- endpoint
- router
- middleware
- controller
Fielding, R., Nottingham, M. & Reschke, J. (2022). RFC 9110. https://www.rfc-editor.org/rfc/rfc9110
Express.js (2024). Routing guide. https://expressjs.com/en/guide/routing.html
Etymology
Origin: borrowed
route(noun): from Latin rupta via, "broken way"
Semantic network
● broader ● narrower ● related
Used in the garden
- Nginx Mastery: Host Multiple Apps with One Server, Conquer LatAm Tech Costs (4×)
- Low-Code Automation for Logistics PyMEs (4×)
- Serverless Savings: Cut Cloud Costs by 40% with Elegant Patterns (2×)
- Algorithmic Arbitrage: Capitalizing on B2B Marketplace Inefficiencies (2×)
- The Forgotten Secret: Digital Businesses Generating Real Wealth Today (1×)
- The Forgotten Secret: Profitable Businesses That Will Set You Free (1×)
- Beyond K MRR: Dominating Your Niche with Lean Scaling in LatAm (1×)
- Architecting API Dominance: Design a REST API That Scales From Day One (1×)
- The Silent Engine: Automating Acquisition for Bootstrapped Micro-SaaS (1×)
- The City That Branded Its Smell (1×)
- Unlock Wealth: The Secret Formula for Profitable Businesses That *Actually* Work (1×)
- Unlock Google's Visual Secrets: A Practical Guide to Rich Snippets for Niche E-commerce (1×)
- The Forgotten Secret: Repeat and Continue for Profitable Business (1×)
- Headless Directory Systems: Monopolizing Regional Web Traffic (1×)
- Unlock Digital Success! 10 Secret Web Gems for Budget-Conscious Entrepreneurs (1×)
- Unleash Hyper-Growth: Dominate Your LatAm Micro-Niche Under K MRR (1×)
- The Fast Money Trap: Why We Fall for It and How to Avoid It? (1×)
- Unleash Your Potential: Proven Digital Businesses for Real Wealth (1×)
- Unlock Real-Time Power: Vanilla JS & SSE for Elite Dashboards (1×)
- Under 30 and already feeling 'old'? The Science of Micro-Habits That Reignite Your Vital Spark. (1×)
Sources
Fielding, R., Nottingham, M. & Reschke, J. (2022). RFC 9110. https://www.rfc-editor.org/rfc/rfc9110
Express.js (2024). https://expressjs.com/en/guide/routing.html