Skip to content
Discussion options

You must be logged in to vote

This should be solved 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. So you could use whatever environment you want. Build once, run anywhere.

import { unstable_noStore as noStore } from 'next/cache';
 
export default function Component() {
  noStore(); // Opt-into dynamic rendering
  // This value will be evaluated at runtime
  const value = process.env.MY_VALUE
  ...
}

You can also opt into dynamic rendering in other ways, like using cookies or headers, but this is an example.

Replies: 22 comments 58 replies

Comment options

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

@CaptainT33mo
Comment options

@CaptainT33mo
Comment options

@JustinYeoh93
Comment options

@HasanMothaffar
Comment options

Comment options

You must be logged in to vote
13 replies
@moondustkj
Comment options

@vrajpal-jhala
Comment options

@moondustkj
Comment options

@vrajpal-jhala
Comment options

@moondustkj
Comment options

Comment options

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

@nandorojo
Comment options

Comment options

You must be logged in to vote
1 reply
@kristian-nst
Comment options

Comment options

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

Comment options

You must be logged in to vote
0 replies
Comment options

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

@andrewmclagan
Comment options

@logan-orion
Comment options

@nandorojo
Comment options

Comment options

You must be logged in to vote
9 replies
@vmc08
Comment options

@ShawnCentra
Comment options

@dsteinbach-ep
Comment options

@homocodian
Comment options

@DNoel26
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
1 reply
@JorgeSivil
Comment options

Comment options

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

@thebergamo
Comment options

@sanalpanicker
Comment options

@hubenschmidt
Comment options

@thebergamo
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
10 replies
@rtrembecky
Comment options

@kairilliet
Comment options

@rtrembecky
Comment options

@rtrembecky
Comment options

@leerob
Comment options

Answer selected by leerob
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