DEV Community

Oscar Herrera
Oscar Herrera

Posted on

Nextjs environment variables

I often forget how next.js handles environment variables, so im writing this post for anyone that needs a quick reference.

By default any environment variable that is not prefixed with NEXT_PUBLIC runs in node.js, its accessible in server components, actions, and routes

VAR=mysecret

Environment variables that are prefixed with NEXT_PUBLIC_
are accessible to the browser

NEXT_PUBLIC_VAR=value

Top comments (0)