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).
fullstack ruleP1stack specificStack: react
nextjsssrdata-fetchingperformance
Fetch initial page data on the server, not on mount
Load a page's initial data in the server-side data function and pass it as props instead of fetching in a client useEffect on mount.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetsx
| 1 | const TickerPage = () => { |
| 2 | const [data, setData] = useState(null); |
| 3 | useEffect(() => { |
| 4 | fetchTicker().then(setData); // fetched on the client after mount |
| 5 | }, []); |
| 6 | return <View data={data} />; |
| 7 | }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | export const getServerSideProps = async () => { |
| 2 | const data = await fetchTicker(); |
| 3 | return { props: { data } }; |
| 4 | }; |
| 5 |
|
| 6 | const TickerPage = ({ data }) => <View data={data} />; |
Explanation (EN)
Objašnjenje (HR)