Using NODE_ENV to specify whether to show something in production or not
Answered
Pacific anchoveta posted this in #help-forum
Pacific anchovetaOP
Hey!
Recently I've been using something like this a lot:
And I've been doing that specifically to just log arrays and objects to make it easier for me to work with them since I enjoy it this way. I've been wondering if it has any downsides? I was also wondering if it hurts when such code is commited and pushed to production - it should be fine since it won't run anyways, right?
Or maybe there's a better way to do it and I am missing something? Appreciate all and any advice
Recently I've been using something like this a lot:
if (process.env.NODE_ENV === "development") {
console.log('Thing:' thing);
}And I've been doing that specifically to just log arrays and objects to make it easier for me to work with them since I enjoy it this way. I've been wondering if it has any downsides? I was also wondering if it hurts when such code is commited and pushed to production - it should be fine since it won't run anyways, right?
Or maybe there's a better way to do it and I am missing something? Appreciate all and any advice

Answered by B33fb0n3
I never experienced any downsides with this. You also won't have any security issues when you use this serverside. And lastly even if you just console.log something, this is absolutly fine
5 Replies
@Pacific anchoveta Hey!
Recently I've been using something like this a lot:
typescript
if (process.env.NODE_ENV === "development") {
console.log('Thing:' thing);
}
And I've been doing that specifically to just log arrays and objects to make it easier for me to work with them since I enjoy it this way. I've been wondering if it has any downsides? I was also wondering if it hurts when such code is commited and pushed to production - it should be fine since it won't run anyways, right?
Or maybe there's a better way to do it and I am missing something? Appreciate all and any advice <:peepoLove:826185019281899611>
I never experienced any downsides with this. You also won't have any security issues when you use this serverside. And lastly even if you just console.log something, this is absolutly fine
Answer
@B33fb0n3 I never experienced any downsides with this. You also won't have any security issues when you use this serverside. And lastly even if you just console.log something, this is absolutly fine
Pacific anchovetaOP
How about using it in client components?
I mean to be fair if it's sent to a client component it shouldn't matter since the user is getting this data anyways, only in a different format
I mean to be fair if it's sent to a client component it shouldn't matter since the user is getting this data anyways, only in a different format

@Pacific anchoveta How about using it in client components?
I mean to be fair if it's sent to a client component it shouldn't matter since the user is getting this data anyways, only in a different format <:shrugR:727587457046151301>
yea, when its used inside a client component it may be included inside the bundle as well. So make sure you don't share any sensitive data. ENV variables itself will be automatically fitered by nextjs
Pacific anchovetaOP
gotcha, thanks a lot for the help!
happy to help