Home > Back-end >  How to add a classname that is only present during development?
How to add a classname that is only present during development?

Time:01-30

I want to add a classname that is only present during development.

Something like this:

 <body className={`${ devMode ? 'debug-screens' : '' }`}> 

I'm hosting my project on Vercel, how can I know when my project is running on localhost or it's deployed?

CodePudding user response:

You can use the following to detect the current environment:

const env = process.env.NODE_ENV
if(env === "development"){
  // do something
}
else if (env === "production"){
 // do something
}
  • Related