REACT -Define and access env variable from front-end

In your React.js app, you may need to define some environment variable depending on your application logic

You can define those variables in webpack.config.js file

You have the webpack.DefinePlugin({}) plug-in to do this

So if you want to define API_URL, you can do it in following way

If you want to access it through React Component you can do