# How To Add Firebase To Your Flutter App?

> In this lesson, we are going to learn how we can add Firebase to our flutter application. And we are going the follow the official documentation.

- Author: [Azraf Al Monzim](https://monzim.com/)
- Published: 2023-03-14
- Updated: 2026-06-13
- Topic: Flutter & Dart
- Canonical: https://monzim.com/blog/how-to-add-firebase-to-your-flutter-app

---

```bash
# create a flutter app run this command
flutter create app_name --org com.YOUR_ORG_NAME
```

## Step 2: Create a Firebase Console Account

Visit the [Firebase Console](https://console.firebase.google.com/) and log in with your Google account. Optionally, create a new project with a unique name.

## Step 3: Open Flutter Project in IDE

Open your Flutter project in your preferred IDE (e.g., VSCode).

### Prerequisites

Make sure you have the following installed:

- Firebase CLI
- Flutterfire CLI

**Already setup firebase and flutterfire cli then skips (1.0-2.0)**

1.  Install Firebase CLI

    ```bash
    # To follow the next Step you must npm or yarn installs your system. (install npm)
    npm install -g firebase-tools
    ```

    For Linux:

    ```bash
    curl -sL https://firebase.tools | bash
    ```

2.  Configure Firebase CLI

    Log in to your account with Firebase CLI:

    ```bash
    firebase login
    ```

    It will open a new tab in chrome select the account and give the permission. If you successfully log in then flow to the next step.

3.  Install Flutterfire CLI:

    ```bash
    dart pub global activate flutterfire_cli
    ```

## Step 4: Initialize Firebase in Your App

Open your project in VSCode and navigate to the root directory. Run the following commands in the terminal:

1.  From your Flutter project directory, run the following command to install the [core plugin](https://pub.dev/packages/firebase_core):

    ```bash
    flutter pub add firebase_core
    ```

2.  Ensure your Flutter app's Firebase configuration is up-to-date

    ```bash
    flutterfire configure
    ```

3.  In your `lib/main.dart` file, import the Firebase core plugin and the configuration file you generated earlier:

    ```dart
    import 'package:firebase_core/firebase_core.dart';
    import 'firebase_options.dart';
    ```

4.  Also in your `lib/main.dart` file, initialize Firebase using the `DefaultFirebaseOptions` object exported by the configuration file:

    ```dart
    await Firebase.initializeApp(
      options: DefaultFirebaseOptions.currentPlatform,
    );
    ```

5.  Rebuild your Flutter application:

    ```bash
    flutter run
    ```

For more details, refer to the [official Firebase CLI documentation](https://firebase.google.com/docs/cli) and [Flutter setup guide](https://firebase.google.com/docs/flutter/setup).
