DB_HOST=localhost DB_PORT=5432 DB_USERNAME=myuser DB_PASSWORD=mypassword API_KEY= myapikey

Vite uses dotenv under the hood.

Assuming you are running your app in (e.g., npm start or next dev ), the system looks for environment files in the following priority order (lowest to highest, where highest wins):

You must prefix your variables with REACT_APP_ to access them in the browser.

How can I handle dev and testing environment on a single machine?