- Forums
- react
- Use .Env Variables In React Ionic Application With Vite
This Page Contains information about Use .Env Variables In React Ionic Application With Vite By jackson in category react with 0 Replies. [5126], Last Updated: Mon Jun 24, 2024
jackson
Sat May 27, 2023
0 Comments
1517 Visits
This is going to be very short and sweet on how to use environment variables with a Ionic React Vite application:
.env file:
VITE_BASE_API_URL=http://localhost/api
Usage: import.meta.env.VITE_BASE_API_URL
In the example above, we are declaring the value of API_URL with the prefix VITE_BASE_
Example Code:
export default axios.create({
baseURL: import.meta.env.VITE_BASE_API_URL
,