4.1 - Environment Variables Not Loaded
If environment variables are not loaded correctly, here are the solutions.
Problem: Variables not accessible
Symptoms:
import.meta.env.VITE_*variables returnundefined- Console errors indicating missing variables
Solutions
1. Check the VITE_ prefix
⚠️ All environment variables must be prefixed with VITE_ to be accessible in Vite code.
❌ Incorrect:
PRIVY_APP_ID=your_app_id
✅ Correct:
VITE_PRIVY_APP_ID=your_app_id
2. Restart the development server
After modifying the .env file, you must restart your development server:
# Stop the server (Ctrl+C)
# Then restart it
pnpm dev
3. Check the .env file location
The .env file must be at the root of your project, at the same level as package.json:
project/
├── .env ← Here
├── package.json
├── src/
└── ...
4. Check the .env file format
The .env file must follow this format:
VITE_PRIVY_APP_ID=your_app_id
VITE_PINATA_JWT_KEY=your_jwt_key
VITE_IPFS_GATEWAY=gateway.pinata.cloud
Important points:
- No spaces around the
= - No quotes around values (unless necessary)
- No comments on the same line as variables