
When you add any variable into your .env file you can use this variable in anywhere in your application.
First of all create .env file in your application :
Example .env file content: Lets add custom environment variable.
Put this line in file :
PUBLIC_URL="/react/"
We defined our PUBLİC_URL variable as environment variable. Also you can add more variables you want.
How to use this in rect project:
const ExampleComponent = () => {
return (
<div>{process.env.PUBLIC_URL}</div>
)
}
export default ExampleComponent;
As you can see in example it is simple as i show you. It will be just like a variable.