Skip to content

Commit

Permalink
docs: updates
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Jul 31, 2023
1 parent 7a590a6 commit b70180b
Showing 1 changed file with 39 additions and 22 deletions.
61 changes: 39 additions & 22 deletions docs/content/2.deploy/providers/firebase.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,21 @@ It is also recommended to create a `.firebaserc` file so you don't need to manua
}
```

#### Install Firebase dependencies
This file is usually generated when you initialize your project with the Firebase CLI. But if you don't have one, you can create it manually.

### Install Firebase dependencies

Then, add Firebase dependencies to your project:

::code-group
```bash [npm]
npm install -D firebase-admin firebase-functions firebase-functions-test firebase-tools
npm install -D firebase-admin firebase-functions firebase-functions-test
```
```bash [yarn]
yarn add --dev firebase-admin firebase-functions firebase-functions-test firebase-tools
yarn add --dev firebase-admin firebase-functions firebase-functions-test
```
```bash [pnpm]
pnpm install -D firebase-admin firebase-functions firebase-functions-test firebase-tools
pnpm install -D firebase-admin firebase-functions firebase-functions-test
```
::

Expand All @@ -47,10 +49,10 @@ pnpm install -D firebase-admin firebase-functions firebase-functions-test fireba
Make sure you are authenticated with the firebase cli. Run this command and follow the prompts:

```bash
npx firebase-tools login
npx login
```

## Alternative Setup Using Firebase CLI
## Alternative Setup Using Firebase CLI (Recommended)

You may instead prefer to set up your project with the Firebase CLI, which will fetch your project ID for you, add required dependencies (see above) and even set up automated deployments via GitHub Actions (for hosting only). [Learn about installing the firebase CLI](https://firebase.google.com/docs/cli#windows-npm).

Expand Down Expand Up @@ -112,7 +114,7 @@ NITRO_PRESET=firebase npm run build
npx firebase-tools deploy
```

If you chose the alternative setup using the Firebase CLI, you can also run:
If you installed the Firebase CLI globally, you can also run:

```bash
firebase deploy
Expand All @@ -122,11 +124,28 @@ firebase deploy

- [Comparison between 1st and 2nd generation functions](https://firebase.google.com/docs/functions/version-comparison)

To switch to the more recent and, recommended generation of firebase functions, set the `FIREBASE_FUNCTIONS_GEN` to `2` when building:
To switch to the more recent and, recommended generation of firebase functions, set the `firebase.gen` option to `2`:

```bash
FIREBASE_FUNCTIONS_GEN=2 NITRO_PRESET=firebase npm run build
::code-group
```ts{3} [nitro.config.ts]
export default defineNitroConfig({
firebase: {
gen: 2
// ...
}
})
```
```ts{4} [nuxt.config.ts]
export default defineNuxtConfig({
nitro: {
firebase: {
gen: 2
// ...
}
}
})
```
::

If you already have a deployed version of your website and want to upgrade to 2nd gen, [see the Migration process on Firebase docs](https://firebase.google.com/docs/functions/2nd-gen-upgrade). Namely, the CLI will ask you to delete your existing functions before deploying the new ones.

Expand All @@ -138,11 +157,9 @@ You can set options for the firebase functions in your `nitro.config.ts` file:
```ts [nitro.config.ts]
export default defineNitroConfig({
firebase: {
gen2: {
httpOptions: {
region: 'europe-west1',
maxInstances: 3
}
httpOptions: {
region: 'europe-west1',
maxInstances: 3
}
}
})
Expand All @@ -151,19 +168,17 @@ export default defineNitroConfig({
export default defineNuxtConfig({
nitro: {
firebase: {
gen2: {
httpOptions: {
region: 'europe-west1',
maxInstances: 3
}
httpOptions: {
region: 'europe-west1',
maxInstances: 3
}
}
}
})
```
::

You can also set 1st gen options in the `gen1` key.
You can also set 1st gen options in the `gen` is set to `1`.

## Runtime

Expand All @@ -177,7 +192,7 @@ Firebase uses the `engines.node` version in your `package.json` to determine whi
}
```

For some node versions you will also need to add a runtime key to your firebase.json file:
For some node versions you might also need to add a runtime key to your firebase.json file:

```json [firebase.json]
{
Expand All @@ -188,6 +203,8 @@ For some node versions you will also need to add a runtime key to your firebase.
}
```

You can read more about this in [Firebase Docs](https://firebase.google.com/docs/functions/manage-functions?gen=2nd#set_nodejs_version).

## If your firebase project has other cloud functions

You may be warned that other cloud functions will be deleted when you deploy your nitro project. This is because nitro will deploy your entire project to firebase functions. If you want to deploy only your nitro project, you can use the `--only` flag:
Expand Down

0 comments on commit b70180b

Please sign in to comment.