# 5. Upload to Firebase Hosting

## Install the firebase-tools CLI <a href="#d31b" id="d31b"></a>

Skip this step if you already have firebase tools installed. If you do not have this, you must install that first.

> npm download link: <https://nodejs.org/> (Download and install it)

{% hint style="info" %}
If you are not sure whether `npm` is installed on your machine, run `$ npm -v` , and see if it lists a version number. If it does, then you already have `npm`. If it says “command not found”, you need to install it.
{% endhint %}

Once `npm` is installed, run the following command:

```
npm install -g firebase-tools
```

`firebase-tools` is now installed!

## Install the required command line tools <a href="#install-cli-tools" id="install-cli-tools"></a>

* Log into Firebase using your Google account by running the following command:

```
firebase login
```

<figure><img src="https://3767936052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fcv8FlmekAQLXUn7f8PbK%2Fuploads%2FKNevUECwJzG0l3e6SttC%2FScreenshot%202022-12-17%20at%201.06.41%20PM.png?alt=media&#x26;token=79ae9960-815a-44ab-a717-49c5856764e5" alt=""><figcaption></figcaption></figure>

* Type Y and you will be redirected to your browser.

* Follow the command prompt and the link in your browser. Accept the permissions by clicking **Ok**. When you return to your terminal you should see that you are now logged in.

* Now you have to initialize the firebase. Run the following command:

```
firebase init
```

<figure><img src="https://lh5.googleusercontent.com/gmQTg_qE7UUhxmflNhNDI8UHT67Y6E16sIFUjH_gXWoNVUqODbCXBSE4v_YnBXlxu4AyZi20GfLVCVdLUahzASmKyUzPH2W9MMSQWlqAHduLDQ78GdAm3hpKEK7kjBVqfR5MNtgfzdGpa8XlM9uY0WZu5fHwXZ3wqbUXN_TttvZJoMr9jmpV37HfpS2M" alt=""><figcaption></figcaption></figure>

* Use the arrow keys to navigate the cursor to **Hosting** and hit the spacebar to select it, then press enter. Now you will see this screen:

<figure><img src="https://lh3.googleusercontent.com/PAlC0Ta4gYhgJ6EBOLkGnGbtiYgM5EwPfzZ7Pl-2FHZBsrB-pf-phgGz8QYx3pUVJT4CI8LzcXyQYD2pm0JXR3E_ai1r6q8Gzzpb6KnPSiVcgx66EkBmsCdzpQHjpUyBUR-KXBhJwrKstlmm63wNxDGKD9d3595NXeZNg3AsMbOTLjO27qa4ydDuIyRO" alt=""><figcaption></figcaption></figure>

* Select an existing project by pressing Enter. Use the arrow keys to select the project you have made in the firebase console.
* Next, enter **build/web** as the public directory and press enter, then enter **y** (for yes) to select the single page app option.
* Enter **n** (for no) to Set up automatic builds and deploys with the GitHub option.

<figure><img src="https://3767936052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fcv8FlmekAQLXUn7f8PbK%2Fuploads%2FKUjsKYVdU9PLmSbloCaR%2FScreenshot%202022-12-17%20at%202.09.40%20PM.png?alt=media&#x26;token=561f4e11-2f88-4bad-9080-74e690157ef7" alt=""><figcaption></figcaption></figure>

## Build The Web App

Run the following command to build the app for the web:

```
flutter build web --release
```

## Upload to Hosting

Run the following command to upload the admin app to the Firebase hosting:

```
firebase deploy
```

<figure><img src="https://3767936052-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fcv8FlmekAQLXUn7f8PbK%2Fuploads%2F2Gmmqy4w4J6dUK9046pF%2FScreenshot%202022-12-17%20at%202.14.10%20PM.png?alt=media&#x26;token=baf28a92-31ac-49a1-b8d8-1bf1b6c29e32" alt=""><figcaption></figcaption></figure>

After this command, you will get a **Hosting URL** from Firebase which will be your **Admin URL**.
