Capítulo 71 de 456
Checklist page: optimizations and patterns to apply during development and before shipping a Next.js app to production, plus the automatic optimizations that require no configuration.
cookies() and the searchParams prop opt the entire route into Dynamic Rendering (or the whole app if used in the Root Layout) — wrap in <Suspense> where appropriate to scope the impact.server-only, so auth/authz checks aren't only at Proxy/layout/page level.useReportWebVitals: hook to send Core Web Vitals data to analytics tools before going to production.| Category | Key recommendations |
|---|---|
| Routing/rendering | Layouts for partial rendering; <Link> for prefetch; catch-all + not-found error handling; watch "use client" boundary placement |
| Data fetching/caching | Server Components for server-side fetch; Route Handlers only from Client Components (not from Server Components); Streaming/loading.js; Parallel Data Fetching; verify caching, use unstable_cache for non-fetch requests |
| UI/accessibility | Server Actions for forms; app/global-error.tsx; app/global-not-found.tsx; Font Module; <Image>; <Script>; eslint-plugin-jsx-a11y |
| Security | Tainting for sensitive data; verify auth/authz inside every Server Action (not just Proxy/layout checks); Data Access Layer + rate limiting; .env.* in .gitignore, only NEXT_PUBLIC_ vars exposed; Content Security Policy |
| Metadata/SEO | Metadata API; OG images; sitemaps and robots files |
| Type safety | TypeScript + TS Plugin |
cookies(), searchParams) atrás de <Suspense>: opta a rota inteira (ou o app todo, se no Root Layout) em Dynamic Rendering sem intenção.next build localmente para pegar erros de build, depois next start para medir performance num ambiente parecido com produção.NEXT_PUBLIC_-prefixed é a única forma seguro de expor env var ao cliente; todo .env.* precisa estar no .gitignore.