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 ruleP2stack specificStack: react
nextjsroutingredirects
Prefer config-level redirects over redirect-only page components
Implement pure URL redirects in the framework's config redirects instead of creating a page whose only job is to redirect.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | // pages/ticker/[fullName]/index.ts |
| 2 | export const getServerSideProps = ({ params }) => ({ |
| 3 | redirect: { destination: `/ticker/${params.fullName}/markedsdata`, permanent: true }, |
| 4 | }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | // next.config.js |
| 2 | redirects: async () => [ |
| 3 | { source: '/ticker/:fullName', destination: '/ticker/:fullName/markedsdata', permanent: true }, |
| 4 | ] |
Explanation (EN)
Objašnjenje (HR)