Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP1stack specificStack: React Router / Next.js
routingparamscorrectnessrobustness
Read identifiers from route params, not by parsing the path client-side
Define dynamic route segments (e.g. /person/:id/:name) and read them with the router's params hook instead of slicing window.location, which is brittle and client-dependent.
PR: hegnar-bellsheep-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | const id = window.location.pathname.split('/')[2]; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | // route: /person/:name/:id |
| 2 | const { id, name } = useParams(); |
Explanation (EN)
Objašnjenje (HR)