.env with typescript #13328
Answered
by
sondh5
visakadivines
asked this question in
Help
.env with typescript
#13328
-
I'm using nextjs with typescript and I can't figure out how to get .env to work with it. When I run 'npm run dev' I see an info message saying "Loaded env from .env" however, all of my environment variables are undefined in my component files and pages. I feel like I'm missing something simple here. Any help would be much appreciated. |
Beta Was this translation helpful? Give feedback.
Answered by
sondh5
May 25, 2020
Replies: 1 comment 1 reply
-
Have you tried with prefix Otherwise module.exports = {
env: {
ENV_VAR_NAME: process.env.ENV_VAR_NAME
}
} When you run
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
visakadivines
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Have you tried with prefix
NEXT_PUBLIC_
https://nextjs.org/blog/next-9-4#new-environment-variables-support
Otherwise
Did you set env in
next.config.js
When you run
npm run dev
, did you see like this