← Stack guides

Security for your Next.js app

Next.js makes it easy to mix server and client code, and that is exactly where most flaws slip in: one NEXT_PUBLIC variable too many, an unprotected API route, or source maps in production. Scan your app and know for sure in 30 seconds.

Typical risks in Next.js

Secrets in the bundle via NEXT_PUBLIC

Anything prefixed with NEXT_PUBLIC_ ships to the browser. A private key there is exposed forever to anyone who opens DevTools.

Unauthorized API routes

An API route is a public URL. If you only hide the button in the UI but do not check the session in the handler, anyone can call it directly.

Default source maps and headers

Next.js does not add security headers for you, and many builds publish source maps that let anyone rebuild your code. Both are fixed in next.config.

Related checks

Does your Next.js app pass these checks?

Scan it free and get a fix prompt for every issue we find.

Scan my site free