how to display different data based on vercel env
Unanswered
Orange-tailed bumble bee posted this in #help-forum
Orange-tailed bumble beeOP
Using Vercel with two environments, main for production and dev for preview, how can I show dynamic data based on these two environments?
3 Replies
@Orange-tailed bumble bee Using Vercel with two environments, main for production and dev for preview, how can I show dynamic data based on these two environments?
you can access env variables via
If you just want to get the current env (dev, prod, ...) you can access the env variable
process.env.variablename. And after you accessed it, you can make conditional statements with it. For example:if(process.env.variablename === "production")
// do stuffIf you just want to get the current env (dev, prod, ...) you can access the env variable
NODE_ENV. That will give you a string of the current enviorement (test, production or development)@Orange-tailed bumble bee solved?
@B33fb0n3 <@421263317609218048> solved?
Orange-tailed bumble beeOP
This worked in nextjs and vercel
process.env.NEXT_PUBLIC_VERCEL_ENV
Thanks for your help & time
process.env.NEXT_PUBLIC_VERCEL_ENV
Thanks for your help & time