Connecting to the Backend - Consuming APIs - UseEffect Hook
Using environment variables in Vite
// Bash
touch .env// Bash
VITE_API_KEY=your-api-key
VITE_API_URL=https://api.example.com// in you API component
const apiKey = import.meta.env.VITE_API_KEY;
const apiUrl = import.meta.env.VITE_API_URL;
console.log("API Key:", apiKey);
console.log("API URL:", apiUrl);PreviousHands-on : Build a Grocery List AppNextLesson 1 - Connecting to the Back End - Understanding Side Effects, Hooks and useEffect - Overview
Last updated