← Todas las plantillas

Server Components por defecto, datos obtenidos en el servidor, presupuestos de 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.

  1. 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.

  2. 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.

  3. 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.

  4. Explicit caching. Every fetch states how it is cached (cache, next.revalidate or tags) and every mutation calls revalidatePath or revalidateTag. Nobody has to guess why a page shows stale data.

  5. 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.

  6. Optimized images and fonts. Images use next/image with width and height or fill and sizes; fonts load with next/font. A raw <img> fails the lint rule @next/next/no-img-element.

  7. Secrets stay on the server. Only variables prefixed NEXT_PUBLIC_ reach the browser. A module that reads a secret imports server-only, so importing it from a client component breaks the build.

  8. Loading and error states per route. Every route segment that fetches data has a loading.tsx or a Suspense boundary and an error.tsx. A missing record calls notFound() instead of rendering an empty page.

  9. Typed and tested. TypeScript runs in strict mode, route params and search params are typed, and Playwright tests cover the critical flows. They are green before the merge.