Skip to content

Setting up the .env file

Abdul Malik edited this page Mar 4, 2023 · 1 revision

Setting up Firebase Environment Variables

In order to use Firebase services in this project, you'll need to obtain the necessary environment variables for your Firebase project. These variables are specified in a file named .env.example.txt.

Obtaining Firebase Configuration Values

To obtain the configuration values for your Firebase project, follow these steps:

  1. Create a Firebase project: If you haven't already, create a new Firebase project by following the instructions in the Firebase documentation.

  2. Find your Firebase API key: To obtain your Firebase API key, navigate to the "General" tab of your project settings. Scroll down to the "Your apps" section and click on the "Web" icon. Under the "Firebase SDK snippet" section, you'll find your API key.

  3. Find your Firebase App ID: To obtain your Firebase App ID, navigate to the "General" tab of your project settings. Scroll down to the "Your apps" section and click on the "Web" icon. Under the "Firebase SDK snippet" section, you'll find your App ID.

  4. Find your Firebase Messaging Sender ID: To obtain your Firebase Messaging Sender ID, navigate to the "Cloud Messaging" tab of your project settings. You'll find your Sender ID listed at the top of the page.

  5. Find your Firebase project ID: To obtain your Firebase project ID, navigate to the "General" tab of your project settings. You'll find your project ID listed at the top of the page.

  6. Find your Firebase storage bucket URL: To obtain your Firebase storage bucket URL, navigate to the "Storage" tab of your project settings. You'll find your bucket URL listed at the top of the page.

  7. Configure your Firebase project for iOS: If your project supports iOS, you'll also need to obtain the iOS-specific configuration values. To obtain your iOS client ID, navigate to the "General" tab of your project settings and click on the "iOS app" icon. Under the "Firebase SDK snippet" section, you'll find your iOS client ID. To obtain your iOS bundle ID, navigate to the "General" tab of your Xcode project and copy your bundle ID.

Note: Some of these values may also be directly found in the google-services.json file that you can find in your firebase console.

Adding Firebase Configuration Values to .env File

Once you have obtained the necessary configuration values for your Firebase project

  1. Create a .env file in the root of your project.

  2. Add the following lines to the file:

apiKey=<YOUR_API_KEY>
appId=<YOUR_APP_ID>
messagingSenderId=<YOUR_MESSAGING_SENDER_ID>
projectId=<YOUR_PROJECT_ID>
storageBucket=<YOUR_STORAGE_BUCKET_URL>
iosClientId=<YOUR_IOS_CLIENT_ID>
iosBundleId=<YOUR_IOS_BUNDLE_ID>

Replace <YOUR_API_KEY>, <YOUR_APP_ID>, <YOUR_MESSAGING_SENDER_ID>, <YOUR_PROJECT_ID>, <YOUR_STORAGE_BUCKET_URL>, <YOUR_IOS_CLIENT_ID>, and <YOUR_IOS_BUNDLE_ID> with the corresponding values you obtained from the Firebase console.

For more information, refer to the official Firebase documentation.