Skip to content

Instantly share code, notes, and snippets.

@indreklasn
Created January 26, 2024 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indreklasn/d1087cca693cad1b2a4cd12cca3b4b38 to your computer and use it in GitHub Desktop.
Save indreklasn/d1087cca693cad1b2a4cd12cca3b4b38 to your computer and use it in GitHub Desktop.
// Create a .env file at your project root:
// add your variables:
VITE_API_KEY=your_api_key_here
// Accessing Environment Variables:
// In your Vite project, you can access the environment variable directly:
const apiKey = import.meta.env.VITE_API_KEY;
// webpack:
REACT_APP_API_KEY=your_api_key_here
// accessing variables:
const apiKey = process.env.REACT_APP_API_KEY;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment