Next.js Launch Security Checklist: 18 Items Before Going Live

Share

TL;DR

TL;DR

Next.js apps need attention to API routes, Server Components, environment variables, and middleware. Before launch, verify authentication on all protected routes, check NEXT_PUBLIC_ variables don't contain secrets, add security headers, and test Server Actions for authorization.

Next.js has both client and server code in the same project, which can lead to confusion about what runs where. This checklist covers Next.js-specific security concerns, from environment variables to Server Actions to API routes.

Environment Variables 4

API Routes and Server Actions 4

Authentication and Middleware 4

Security Headers 3

Database and Data 3

What security checks should I do before deploying Next.js?

Before deploying Next.js, verify environment variables are set correctly (NEXT_PUBLIC_ only for client-safe values), add authentication to API routes, configure security headers, test Server Actions for proper authorization, and ensure database queries use parameterized statements.

::

How do I secure Next.js API routes?

Secure Next.js API routes by adding authentication middleware, validating request bodies with a schema validator like Zod, implementing rate limiting, checking user permissions for sensitive operations, and ensuring errors don't leak sensitive information.

Are Server Actions secure by default?

Server Actions run on the server but can be invoked directly from the client. They're not secure by default. You need to add authentication checks and input validation in every Server Action that modifies data or accesses protected resources.

::

Scan Your Next.js App

Automated scanning finds issues in API routes, env vars, and more.

Start Free Scan

Launch Security

Next.js Launch Security Checklist: 18 Items Before Going Live