Skip to content

Better support for runtime environment variables. #44628

Closed Answered by leerob
svenvandescheur asked this question in Help
Discussion options

You must be logged in to vote

Next.js can support both build time and runtime environment variables.

By default, environments variables are only available on the server. To expose an environment variable to the browser, it must be prefixed with NEXT_PUBLIC_. However, these public environment variables will be inlined into the JavaScript bundle during next build.

To read runtime environment variables, we recommend incrementally adopting the App Router. With the App Router, we can safely read environment variables on the server during dynamic rendering. This allows you to use a singular Docker image that can be promoted through multiple environments with different values.

// This is as of Next.js 14, but you could also …

Replies: 24 comments 56 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@airtonix
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@ashleygeorgeclarke
Comment options

@Guo-dalu
Comment options

@AugustDev
Comment options

@HofmannZ
Comment options

@airtonix
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@philwolstenholme
Comment options

Comment options

You must be logged in to vote
7 replies
@obukhov
Comment options

@HofmannZ
Comment options

@andonirdgz
Comment options

@houtan-rocky
Comment options

@HofmannZ
Comment options

Comment options

You must be logged in to vote
4 replies
@nareshbhatia
Comment options

@steve-haar
Comment options

@nass59
Comment options

@leerob
Comment options

Comment options

You must be logged in to vote
2 replies
@leerob
Comment options

@nareshbhatia
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
12 replies
@raldred
Comment options

@jasonjohnlee
Comment options

@nwoodr94
Comment options

@leerob
Comment options

@nwoodr94
Comment options

Answer selected by leerob

This comment was marked as off-topic.

Comment options

You must be logged in to vote
2 replies
@leerob
Comment options

@nedcerneckis
Comment options

Comment options

You must be logged in to vote
3 replies
@leerob
Comment options

@MuellerMarvin
Comment options

@leerob
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
11 replies
@HofmannZ
Comment options

@rfviolato
Comment options

@HofmannZ
Comment options

@sanalpanicker
Comment options

@HofmannZ
Comment options

Comment options

You must be logged in to vote
6 replies
@dukemai
Comment options

@HofmannZ
Comment options

@dukemai
Comment options

@RafalJachimczyk
Comment options

@rezaUniqe
Comment options

Comment options

You must be logged in to vote
2 replies
@leerob
Comment options

@josehernandezv
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
Converted from issue

This discussion was converted from issue #44184 on January 06, 2023 07:53.