Skip to content

Instantly share code, notes, and snippets.

@tigawanna
Created September 5, 2022 15:50
Show Gist options
  • Save tigawanna/7933de34fc1f68417eb7cb81baecc012 to your computer and use it in GitHub Desktop.
Save tigawanna/7933de34fc1f68417eb7cb81baecc012 to your computer and use it in GitHub Desktop.
adding vite enviromet variables : firebase api cnofig
  • create a .env file in the root directory
  VITE_apiKey=zahtddfrsfSyCHJYZaDa9s47oP4L7Cc
  VITE_authDomain=firebaseapp.firebaseapp.com
  VITE_databaseURL=https://firebaseapp.firebaseio.com
  VITE_projectId=firebaseapp
  VITE_storageBucket=firebaseapp.appspot.com
  VITE_messagingSenderId=200000020053535353535353535353
  VITE_appId=1:50000000080792:web:6676767676d766d7676sw6
  • then in the app
const firebaseConfig = {
  apiKey: import.meta.env.VITE_apiKey,
  authDomain: import.meta.env.VITE_authDomain,
  databaseURL: import.meta.env.VITE_databaseURL,
  projectId: import.meta.env.VITE_projectId,
  storageBucket: import.meta.env.VITE_storageBucket,
  messagingSenderId: import.meta.env.VITE_messagingSenderI,
  appId: import.meta.env.VITE_appId,
};

remember to include .env it in the .gitignore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment