Can we use process.env.* in next.config.js? #81107
kientrant1
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
Hi, yes, for example here, https://nextjs.org/docs/app/guides/multi-zones#how-to-route-requests-to-the-right-zone, they use the BLOG_DOMAIN env ~ just be careful cuz IIRC, some of these are copied during build, and others read as the server starts ~ something like that |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
May I ask whether this statement is correct or not?
next.config.js is a Node.js file that runs exclusively on the server-side during the Next.js build process and when the development server is started. Since it runs in a Node.js environment, it has full access to the process.env object, just like any other Node.js script.
next.config.js
I'm using nextjs v14 and not sure if this is officially supported from Nextjs. If following this way, I can share server key - MY_SERVER_KEY to client component through declaring these keys in next.config.js. Then, I don't have duplicated a server key into NEXT_PUBLIC_MY_SERVER_KEY
Beta Was this translation helpful? Give feedback.
All reactions