How to use .env file and use in React js
Copy Below Code
View As A Text File
Show Text Only
Show API
Edit Code
Step 1 =
Create .env file on root directory
Step 2 =
Make variables like this.
REACT_APP_APP_URL=http://localhost:3000
Note that the environment variables in React must be prefixed with REACT_APP_, otherwise React will ignore the variable during bundling.
Step 3 =
Use variable like this in any file
"process.env.REACT_APP_APP_URL"