Next.js Discord

Discord Forum

Why my front can't access to .env ?

Answered
Awakno posted this in #help-forum
Open in Discord
Hi, I want to create a Admin Page for my website, but when I do a condition to check if good email, process.env.admin_mail return undefined ?

Anyone know why ?
Answered by B33fb0n3
you can't access your serverside only env variables on the clientside.

You can create a .env file and add your public variable there with NEXT_PUBLIC_YOUR_ENV=12345. After that you are able to access it on the clientside
View full answer

3 Replies

@Awakno Hi, I want to create a Admin Page for my website, but when I do a condition to check if good email, process.env.admin_mail return undefined ? Anyone know why ?
you can't access your serverside only env variables on the clientside.

You can create a .env file and add your public variable there with NEXT_PUBLIC_YOUR_ENV=12345. After that you are able to access it on the clientside
Answer
Oh ok thx
happy to help