You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This preset will deploy to firebase functions 1st gen by default. If you want to deploy to firebase functions 2nd gen, see the [instructions below](#using-2nd-generation-firebase-functions).
15
47
::
16
48
17
-
## Project Setup
49
+
###Project Setup
18
50
19
-
### Using firebase CLI (recommended)
51
+
####Using firebase CLI (recommended)
20
52
21
53
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).
22
54
23
-
#### 1. Install firebase CLI globally
55
+
1. Install firebase CLI globally
24
56
25
57
Always try to use the latest version of the Firebase CLI.
**Note**: You need to be on [^11.18.0](https://github.com/firebase/firebase-tools/releases/tag/v11.18.0) to deploy a `nodejs18` function.
32
64
33
-
#### 2. Initialize your firebase project
65
+
2. Initialize your firebase project
34
66
35
67
```bash
36
68
firebase login
@@ -57,11 +89,11 @@ Once complete, add the following to your `firebase.json` to enable server render
57
89
58
90
You can find more details in the [Firebase documentation](https://firebase.google.com/docs/hosting/quickstart).
59
91
60
-
### Alternative method
92
+
####Alternative method
61
93
62
94
If you don't already have a `firebase.json` in your root directory, Nitro will create one the first time you run it. In this file, you will need to replace `<your_project_id>` with the ID of your Firebase project. This file should then be committed to the git.
63
95
64
-
#### 1. Create a `.firebaserc` file
96
+
1. Create a `.firebaserc` file
65
97
66
98
It is recommended to create a `.firebaserc` file so you don't need to manually pass your project ID to your `firebase` commands (with `--project <your_project_id>`):
67
99
@@ -75,19 +107,19 @@ It is recommended to create a `.firebaserc` file so you don't need to manually p
75
107
76
108
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.
Make sure you are authenticated with the firebase cli. Run this command and follow the prompts:
87
119
88
120
:pm-x{command="firebase-tools login"}
89
121
90
-
## Local preview
122
+
###Local preview
91
123
92
124
You can preview a local version of your site if you need to test things out without deploying.
93
125
@@ -96,7 +128,7 @@ NITRO_PRESET=firebase npm run build
96
128
firebase emulators:start
97
129
```
98
130
99
-
## Build and deploy
131
+
###Build and deploy
100
132
101
133
Deploy to Firebase Hosting by running a Nitro build and then running the `firebase deploy` command.
102
134
@@ -112,7 +144,7 @@ If you installed the Firebase CLI globally, you can also run:
112
144
firebase deploy
113
145
```
114
146
115
-
## Using 2nd generation firebase functions
147
+
###Using 2nd generation firebase functions
116
148
117
149
-[Comparison between 1st and 2nd generation functions](https://firebase.google.com/docs/functions/version-comparison)
118
150
@@ -148,7 +180,7 @@ If you cannot use configuration for any reason, alternatively you can use `NITRO
148
180
149
181
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.
150
182
151
-
## Options
183
+
###Options
152
184
153
185
You can set options for the firebase functions in your `nitro.config.ts` file:
You can also set options for 1st generation Cloud Functions if the `gen` option is set to `1`. Note these are different from the options for 2nd generation Cloud Functions.
186
218
187
-
### Runtime Node.js version
219
+
####Runtime Node.js version
188
220
189
221
You can set custom Node.js version in configuration:
190
222
@@ -225,17 +257,17 @@ You might also need to add a runtime key to your `firebase.json` file:
225
257
226
258
You can read more about this in [Firebase Docs](https://firebase.google.com/docs/functions/manage-functions?gen=2nd#set_nodejs_version).
227
259
228
-
## If your firebase project has other cloud functions
260
+
###If your firebase project has other cloud functions
229
261
230
262
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:
231
263
232
264
```bash
233
265
firebase deploy --only functions:server,hosting
234
266
```
235
267
236
-
## Advanced
268
+
###Advanced
237
269
238
-
### Renaming function
270
+
####Renaming function
239
271
240
272
When deploying multiple apps within the same Firebase project, you must give your server a unique name in order to avoid overwriting
"Neither `firebase.gen` or `NITRO_FIREBASE_GEN` is set. Nitro will default to Cloud Functions 1st generation. It is recommended to set this to the latest generation (currently `2`). Set the version to remove this warning. See https://nitro.build/deploy/providers/firebase for more information."
0 commit comments