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
,