Server Components als Standard, Daten auf dem Server geladen, Budgets für Core Web Vitals.
Constitution — Next.js app
Version 1.0.0 · Ratified 2026-11-10
These principles hold for every spec, plan and task of the project. A spec may add rules; it never weakens these.
-
Server Components by default. Components are React Server Components unless they need state, effects or browser APIs.
"use client"sits on the smallest leaf that needs it; a client directive on a page or layout fails the review. -
Data fetched on the server. Pages and layouts read their data in Server Components or Route Handlers, never with a client-side fetch for the first render. Independent requests run in parallel with
Promise.all; a request waterfall fails the review. -
Core Web Vitals budgets. At the 75th percentile on mobile, LCP stays under 2.5 s, INP under 200 ms and CLS under 0.1. Lighthouse CI runs on the key routes and the build fails when a budget is broken.
-
Explicit caching. Every fetch states how it is cached (
cache,next.revalidateor tags) and every mutation callsrevalidatePathorrevalidateTag. Nobody has to guess why a page shows stale data. -
Mutations through Server Actions. Forms post to Server Actions that validate their input with a schema and check authorization on the server. Data coming from the client is never trusted, even when the form already checked it.
-
Optimized images and fonts. Images use
next/imagewithwidthandheightorfillandsizes; fonts load withnext/font. A raw<img>fails the lint rule@next/next/no-img-element. -
Secrets stay on the server. Only variables prefixed
NEXT_PUBLIC_reach the browser. A module that reads a secret importsserver-only, so importing it from a client component breaks the build. -
Loading and error states per route. Every route segment that fetches data has a
loading.tsxor a Suspense boundary and anerror.tsx. A missing record callsnotFound()instead of rendering an empty page. -
Typed and tested. TypeScript runs in
strictmode, route params and search params are typed, and Playwright tests cover the critical flows. They are green before the merge.