Log into Firebase using your Google Account by running the following
command:
firebaselogin
Install the FlutterFire CLI by running the following command from any
directory:
dartpubglobalactivateflutterfire_cli
Step 2: Configure your apps to use Firebase
Use the FlutterFire CLI to configure your Flutter apps to connect to Firebase.
From your Flutter project directory, run the following command to start the
app configuration workflow:
flutterfireconfigure
What does thisflutterfire configureworkflow do?
Theflutterfire configureworkflow does the following:
Asks you to select the platforms (iOS, Android, Web) supported in your
Flutter app. For each selected platform, the FlutterFire CLI creates a new
Firebase app in your Firebase project.
You can select either to use an existing Firebase project or to create a
new Firebase project. If you already have apps registered in an existing
Firebase project, the FlutterFire CLI will attempt to match them based on
your current Flutter project configuration.
Creates a Firebase configuration file (firebase_options.dart) and adds it
to yourlib/directory.
(forCrashlyticsorPerformance Monitoringon Android)Adds the required
product-specific Gradle plugins to your Flutter app.
Step 3: Initialize Firebase in your app
From your Flutter project directory, run the following command to install
the core plugin:
flutterpubaddfirebase_core
From your Flutter project directory, run the following command to ensure
that your Flutter app's Firebase configuration is up-to-date:
flutterfireconfigure
In yourlib/main.dartfile, import the Firebase core plugin and the
configuration file you generated earlier:
If you would rather use a demo project, you can start theFirebase Emulatorand in yourlib/main.dartfile
initialize Firebase usingdemoProjectId(it should start withdemo-):
You access Firebase in your Flutter app through the variousFirebase Flutter plugins, one for each
Firebase product
(for example:Cloud Firestore,Authentication,Analytics, etc.).
Since Flutter is a multi-platform framework, each Firebase plugin is applicable
for Apple, Android, and web platforms. So, if you add any Firebase plugin to
your Flutter app, it will be used by the Apple, Android, and web versions of
your app.
Here's how to add a Firebase Flutter plugin:
From your Flutter project directory, run the following command:
flutter pub addPLUGIN_NAME
From your Flutter project directory, run the following command:
flutterfireconfigure
Running this command ensures that your Flutter app's Firebase configuration
is up-to-date and, forCrashlyticsandPerformance Monitoringon Android, adds the
required Gradle plugins to your app.
Once complete, rebuild your Flutter project:
flutterrun
You're all set! Your Flutter apps are registered and configured to use Firebase.
Special considerations for building web
apps
Trusted Types support
The Firebase SDK for Flutter supports using Trusted Types to help prevent
DOM-based (client-side) XSS attacks. When youenable Trusted Type enforcementfor your app, the Firebase SDK injects its scripts into the DOM using custom
Trusted Type policies, namedflutterfire-firebase_core,flutterfire-firebase_auth, etc.
Disable Firebase JavaScript SDK auto-injection
By default, the Firebase Flutter SDK auto-injects the Firebase JavaScript SDK
when building for the web. If you don't want the Firebase JavaScript SDK to be
auto-injected, you can do the following:
Ignore the auto-injection script by adding the following property inside a<script>tag within theweb/index.htmlfile in your Flutter project:
<!-- Add this property inside a <script> tag within your "web/index.html" file in your Flutter project -->
<!-- Put in the names of all the plugins you wish to ignore: -->
window.flutterfire_ignore_scripts = ['analytics', 'firestore'];
Load the script manually using one of the following options:
Option 1: Add the SDK explicitly to yourweb/index.htmlfile,
inside thewindow.addEventListenercallback:
window.addEventListener('load',asyncfunction(ev){window.firebase_firestore=awaitimport("https://www.gstatic.com/firebasejs/12.14.0/firebase-firestore.js");window.firebase_analytics=awaitimport("https://www.gstatic.com/firebasejs/12.14.0/firebase-analytics.js");_flutter.loader.loadEntrypoint().then(function(engineInitializer){// rest of the code
Option 2: Download the plugin's Firebase JavaScript SDK code from thegstaticdomain, and save them to a JavaScript file to be kept within
your project and loaded in manually:
// "web/my-analytics.js" & "web/my-firestore.js" file loaded as a script into your "web/index.html" file:window.addEventListener('load',asyncfunction(ev){window.firebase_analytics=awaitimport("./my-analytics.js");window.firebase_firestore=awaitimport("./my-firestore.js");_flutter.loader.loadEntrypoint().then(function(engineInitializer){// rest of the code
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-06-10 UTC."],[],[]]