TL;DR
This 18-item checklist covers critical Next.js security configurations: API routes, middleware, server components, and security headers. 6 critical items must be fixed before launch, 7 important items within the first week, and 5 recommended items when you can.
Quick Checklist (5 Critical Items)
Environment Variables 3
API Routes (App Router) 4
Middleware 2
Server Components & Server Actions 3
::checklist-item{label="Sensitive data not passed to client components" description="Don't pass secrets, full user objects, or internal IDs to "use client". How to secure client data"} :: ::checklist-item{label="server-only package used for sensitive modules" description="Import "server-only" to prevent accidental client bundling. How to use server-only package"} ::
Security Headers 3
Authentication (NextAuth/Auth.js) 3
How to Use This Checklist
Go through each item before deploying your Next.js project. Open browser DevTools, go to Network tab, and check what data your app is sending. Look for exposed tokens, full database records, or sensitive fields.
How do I secure Next.js API routes?
Check authentication in every API route using getServerSession() or your auth library. Verify the user has permission to access the requested resource. Validate all inputs with Zod or similar. Implement rate limiting on sensitive endpoints.
What security headers should I add to Next.js?
Add X-Frame-Options (DENY), X-Content-Type-Options (nosniff), Referrer-Policy (strict-origin-when-cross-origin), Strict-Transport-Security (for HTTPS), and Content-Security-Policy. Configure these in next.config.js headers() function.
How do I prevent exposing secrets in Next.js?
Never use NEXT_PUBLIC_ prefix for secrets. Use the "server-only" package for modules with sensitive code. Keep secrets in Server Components and API routes only. Never pass sensitive data as props to client components.
Scan Your Next.js Project
Our scanner checks for exposed secrets, missing auth, and security misconfigurations.
Start Free Scan