New: Cookbooks and AI ExplanationsStep-by-Step recipes to solve problems connected to Roadmaps and Cheat Sheets. Need more details? Use AI buttons for structured and simple explanations with concrete examples throughout the whole platform.Take a look
You read import.meta.env.VITE_API_URL and get undefined, even though the value sits right there in your .env file.
What you'll have at the end
A working fetch call that reads its address from import.meta.env.VITE_API_URL, logged correctly in the console
You need
A Vite dev server already running, and a fetch call somewhere in the project that builds its request address from a value read out of Vite's client-side environment object.
Not covered
Passing a real secret or API key through this same variable, since anything carrying the required prefix ships as plain, readable text in the browser bundle.
Leans on
Checked 21 Aug 2026
Part of the Vite cookbook