Replies: 9 comments 2 replies
-
Hello! Did you check out https://nextjs.org/docs/basic-features/environment-variables#exposing-environment-variables-to-the-browser ? Next.js supports environment variables thought .env files. If you want to create variable with |
Beta Was this translation helpful? Give feedback.
-
@D-Thrane did you found the solution? I'm facing same issue |
Beta Was this translation helpful? Give feedback.
-
Same issue for me, it works when I'm in development but when I build project variable from Build is done with docker container First:.env file
next.config.js
_app.tsx
Secund:.env file
_app.tsx
I have also tried with Runing on
|
Beta Was this translation helpful? Give feedback.
-
I am also having the same issue, tried with env But nothing helped. Running on |
Beta Was this translation helpful? Give feedback.
-
Did anyone ever find a solution to this matter. in my next.config.mjs, I have: /** @type {import('next').NextConfig} */ export default nextConfig; and In .env.local I have: NEXT_PUBLIC_SITE_URL="http://localhost:3000" |
Beta Was this translation helpful? Give feedback.
-
I got the same problem. tried changing the next.config file, tried importing async function through config file Do let me know if it solves your problem |
Beta Was this translation helpful? Give feedback.
-
Same problem: /api/route.ts .env.local but return undefined |
Beta Was this translation helpful? Give feedback.
-
When I need env variables I just add them in next.config file… have u ever
tried?
|
Beta Was this translation helpful? Give feedback.
-
In a client component in Next.js 14 app router when prefixing the .env variable with the "NEXT_PUBLIC_" so if in .env :
Then in the code call it like normal such as: process.env.NEXT_PUBLIC_MY_VAR it worked for me. |
Beta Was this translation helpful? Give feedback.
-
I want to use a environment variable in _app.tsx but i get undefined.
I have tried to name it NEXT_PUBLIC_ and have tried the following i next.config
I'm running next 12.0.10
Beta Was this translation helpful? Give feedback.
All reactions