Skip to content
Discussion options

You must be logged in to vote

bro BTW this is very common In Next.js if you search on google and youtube you can get it easily but not a problem .env.local only works on your local machine. For Vercel deployment, you need to add the same environment variables inside the Vercel dashboard.

Go to:

Vercel Dashboard → Project → Settings → Environment Variables

click on add environment variable

Add your variable there, then redeploy the project.

Example local file:

NEXT_PUBLIC_APP_URL=https://your-domain.vercel.app
DATABASE_URL=your_database_url
API_SECRET_KEY=your_secret_key

Use public variables in the browser with NEXT_PUBLIC_:

const appUrl = process.env.NEXT_PUBLIC_APP_URL;
console.log(appUrl);

Use private variables o…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Suresh-Mahat
Comment options

Answer selected by Suresh-Mahat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants