Next.js how to show something in development and hide in production

I wanted to display some information on the website only if it was in development, on my local machine, and not in the deployed website.

Here’s how I did it:

const isDev = process.env.NODE_ENV === 'development'
{isDev && (
  <p>local only</p>
)}


This content originally appeared on flaviocopes.com and was authored by flaviocopes.com

I wanted to display some information on the website only if it was in development, on my local machine, and not in the deployed website.

Here’s how I did it:

const isDev = process.env.NODE_ENV === 'development'
{isDev && (
  <p>local only</p>
)}


This content originally appeared on flaviocopes.com and was authored by flaviocopes.com


Print Share Comment Cite Upload Translate Updates
APA

flaviocopes.com | Sciencx (2021-05-08T05:00:00+00:00) Next.js how to show something in development and hide in production. Retrieved from https://www.scien.cx/2021/05/08/next-js-how-to-show-something-in-development-and-hide-in-production/

MLA
" » Next.js how to show something in development and hide in production." flaviocopes.com | Sciencx - Saturday May 8, 2021, https://www.scien.cx/2021/05/08/next-js-how-to-show-something-in-development-and-hide-in-production/
HARVARD
flaviocopes.com | Sciencx Saturday May 8, 2021 » Next.js how to show something in development and hide in production., viewed ,<https://www.scien.cx/2021/05/08/next-js-how-to-show-something-in-development-and-hide-in-production/>
VANCOUVER
flaviocopes.com | Sciencx - » Next.js how to show something in development and hide in production. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/08/next-js-how-to-show-something-in-development-and-hide-in-production/
CHICAGO
" » Next.js how to show something in development and hide in production." flaviocopes.com | Sciencx - Accessed . https://www.scien.cx/2021/05/08/next-js-how-to-show-something-in-development-and-hide-in-production/
IEEE
" » Next.js how to show something in development and hide in production." flaviocopes.com | Sciencx [Online]. Available: https://www.scien.cx/2021/05/08/next-js-how-to-show-something-in-development-and-hide-in-production/. [Accessed: ]
rf:citation
» Next.js how to show something in development and hide in production | flaviocopes.com | Sciencx | https://www.scien.cx/2021/05/08/next-js-how-to-show-something-in-development-and-hide-in-production/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.