Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Keep components that depend on window/breakpoints as client components
Use a client boundary for browser hooks and preserve SSR-safe initialization; use client alone does not make window available during prerender.
Bad example
| 1 | // server component |
| 2 | export function ThreadPageContent() { |
| 3 | const bp = useBreakpoint(); // depends on window, breaks on server |
| 4 | } |
Explanation (EN)
A Server Component cannot call an interactive browser hook.
Objašnjenje (HR)
Good example
| 1 | 'use client'; |
| 2 | export function ThreadPageContent() { |
| 3 | const bp = useBreakpoint(); |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Place stateful browser hooks in a Client Component, then separately make render and module evaluation safe for server prerendering.
Exceptions / Tradeoffs (EN)
A use client directive does not guarantee code never executes during SSR. Read browser globals in an appropriate client lifecycle or use a supported no-SSR boundary when truly necessary.