How to deploy flutter web apps to firebase hosting in 3 mins ๐Ÿš€

Baimam Boukar Jean Jacques
2 min readAug 25, 2021

Outlines

  • Whatโ€™s firebase & firebase hosting ?
  • Tools & Requirements
  • Configure firebase web project
  • Build and Deploy
  • Whatโ€™s firebase & firebase hosting ?

Firebase is a BaaS (Backend as a Service) solution that is actually part of GCP (Google Cloud Platform) services. It helps developers to speed up their backend development process with less efforts by various tools and features. Firebase have many features amongst which Firebase Hosting

With the basic Spark Plan, Firebase hosting allows you to deploy your web apps in one command (Thank to firebase CLI) on SSD storage servers for 24/7 access all over the world with custom domain name and SSL certificate included.

In the next sections of this article, we are going to to setup and deploy a flutter web app on firebase Hosting.

Leeroy Jenkinsโ€ฆโ€ฆ Letโ€™s Go ๐Ÿš€๐Ÿš€๐Ÿš€

Before we start

There are some tools that are required in order to complete this deployment.

  • Active Google Account
  • Node JS: This will help us to install the firebase CLI. You can get it from the node js official website . To make sure it has been well installed, execute the following command $ node --version
  • If everything is Ok, you will be able to see the version of nodejs that you have just installed.
  • Firebase CLI: Install the Firebase CLI tools by executing the following command: $ npm install -g firebase-tools

We are all set ! Letโ€™s move ๐Ÿš€

Configure firebase in the flutter web project

Initialize Firebase Open your main.dart file and modify the void main( ){ } function like so:

  • You will need to login to firebase with your google account. Execute below command to do so
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}

We are all set ! Letโ€™s move ๐Ÿš€

After that you will see this option screen.

Chose the different firebase features you would like to use in your project and continue.

After successful built , you will see a folder called web inside your projects root directory, in the build folder.

Finally, ready to deploy โ˜บ

You will have to run these commands inside the new directory

firebase use --add

You will be required to select the firebase project on which you want to deploy the actual app

To deploy complete the deployment, just run the command below

firebase deploy

๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰ Congratulations, your app has been deployed

Thank for reading ๐Ÿ’ฏ๐Ÿ’ฏ๐Ÿ’ฏ

--

--

Baimam Boukar Jean Jacques

AWS Community Builder | Open Source Enthusiast | Mobile Engineer | Write about Flutter- Go - Bitcoin - AWS severless and Cloud native apps