Skip to content

Commit bd7965c

Browse files
committed
docs: uncomment docs for firebase-app-hosting
1 parent 0fedd3a commit bd7965c

File tree

2 files changed

+7
-278
lines changed

2 files changed

+7
-278
lines changed

docs/2.deploy/0.index.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ When deploying to production using CI/CD, Nitro tries to automatically detect th
2222
- [aws amplify](/deploy/providers/aws-amplify)
2323
- [azure](/deploy/providers/azure)
2424
- [cloudflare pages](/deploy/providers/cloudflare#cloudflare-pages)
25+
- [firebase app hosting](/deploy/providers/firebase#firebase-app-hosting)
2526
- [netlify](/deploy/providers/netlify)
2627
- [stormkit](/deploy/providers/stormkit)
2728
- [vercel](/deploy/providers/vercel)
+6-278
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
1-
# Firebase
1+
# Firebase App Hosting
22

3-
> Deploy Nitro apps to Firebase hosting.
3+
> Deploy Nitro apps to Firebase App Hosting.
44
55
::note
66
You will need to be on the [**Blaze plan**](https://firebase.google.com/pricing) (Pay as you go) to get started.
77
::
88

9-
<!--
10-
11-
## Firebase app hosting <sup>(beta)</sup>
12-
139
Preset: `firebase_app_hosting`
1410

1511
:read-more{title="Firebase App Hosting" to="https://firebase.google.com/docs/app-hosting"}
1612

17-
::important
18-
Firebase app hosting support is currently available in the Nitro [nightly release channel](/guide/nightly).
19-
::
20-
2113
::tip
2214
You can integrate with this provider using [zero configuration](/deploy/#zero-config-providers).
2315
::
2416

25-
### Project setup
17+
## Project setup
2618

2719
1. Go to the Firebase [console](https://console.firebase.google.com/) and set up a new project.
2820
2. Select **Build > App Hosting** from the sidebar.
@@ -31,271 +23,7 @@ You can integrate with this provider using [zero configuration](/deploy/#zero-co
3123
- Choose a region.
3224
- Import a GitHub repository (you’ll need to link your GitHub account).
3325
- Configure deployment settings (project root directory and branch), and enable automatic rollouts.
34-
- Choose a unique ID for deployment.
35-
4. Wait for the first release to complete.
36-
37-
-->
38-
39-
## Firebase hosting
40-
41-
**Preset:** `firebase`
42-
43-
:read-more{title="Firebase Hosting" to="https://firebase.google.com/docs/hosting"}
44-
45-
::important
46-
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).
47-
::
48-
49-
### Project Setup
50-
51-
#### Using firebase CLI (recommended)
52-
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).
54-
55-
1. Install firebase CLI globally
56-
57-
Always try to use the latest version of the Firebase CLI.
58-
59-
```bash
60-
npm install -g firebase-tools@latest
61-
```
62-
63-
**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.
64-
65-
2. Initialize your firebase project
66-
67-
```bash
68-
firebase login
69-
firebase init hosting
70-
```
71-
72-
When prompted, you can enter `.output/public` as the public directory. In the next step, **do not** configure your project as a single-page app.
73-
74-
Once complete, add the following to your `firebase.json` to enable server rendering in Cloud Functions:
75-
76-
```json [firebase.json]
77-
{
78-
"functions": { "source": ".output/server" },
79-
"hosting": [
80-
{
81-
"site": "<your_project_id>",
82-
"public": ".output/public",
83-
"cleanUrls": true,
84-
"rewrites": [{ "source": "**", "function": "server" }]
85-
}
86-
]
87-
}
88-
```
89-
90-
You can find more details in the [Firebase documentation](https://firebase.google.com/docs/hosting/quickstart).
91-
92-
#### Alternative method
93-
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.
95-
96-
1. Create a `.firebaserc` file
97-
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>`):
99-
100-
```json [.firebaserc]
101-
{
102-
"projects": {
103-
"default": "<your_project_id>"
104-
}
105-
}
106-
```
107-
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.
109-
110-
2. Install firebase dependencies
111-
112-
Then, add Firebase dependencies to your project:
113-
114-
:pm-install{name="firebase-admin firebase-functions firebase-functions-test" dev}
115-
116-
3. Log into the firebase CLI
117-
118-
Make sure you are authenticated with the firebase cli. Run this command and follow the prompts:
119-
120-
:pm-x{command="firebase-tools login"}
121-
122-
### Local preview
123-
124-
You can preview a local version of your site if you need to test things out without deploying.
125-
126-
```bash
127-
NITRO_PRESET=firebase npm run build
128-
firebase emulators:start
129-
```
130-
131-
### Build and deploy
132-
133-
Deploy to Firebase Hosting by running a Nitro build and then running the `firebase deploy` command.
134-
135-
```bash
136-
NITRO_PRESET=firebase npm run build
137-
```
138-
139-
:pm-x{command="firebase-tools deploy"}
140-
141-
If you installed the Firebase CLI globally, you can also run:
142-
143-
```bash
144-
firebase deploy
145-
```
26+
- Choose a unique ID for your backend.
27+
4. Click Finish & Deploy to create your first rollout.
14628

147-
### Using 2nd generation firebase functions
148-
149-
- [Comparison between 1st and 2nd generation functions](https://firebase.google.com/docs/functions/version-comparison)
150-
151-
To switch to the more recent and, recommended generation of firebase functions, set the `firebase.gen` option to `2`:
152-
153-
::code-group
154-
155-
```ts{3} [nitro.config.ts]
156-
export default defineNitroConfig({
157-
firebase: {
158-
gen: 2
159-
// ...
160-
}
161-
})
162-
```
163-
164-
```ts{4} [nuxt.config.ts]
165-
export default defineNuxtConfig({
166-
nitro: {
167-
firebase: {
168-
gen: 2
169-
// ...
170-
}
171-
}
172-
})
173-
```
174-
175-
::
176-
177-
::note
178-
If you cannot use configuration for any reason, alternatively you can use `NITRO_FIREBASE_GEN` environment variable.
179-
::
180-
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.
182-
183-
### Options
184-
185-
You can set options for the firebase functions in your `nitro.config.ts` file:
186-
187-
::code-group
188-
189-
```ts [nitro.config.ts]
190-
export default defineNitroConfig({
191-
firebase: {
192-
gen: 2,
193-
httpsOptions: {
194-
region: 'europe-west1',
195-
maxInstances: 3,
196-
},
197-
},
198-
});
199-
```
200-
201-
```ts [nuxt.config.ts]
202-
export default defineNuxtConfig({
203-
nitro: {
204-
firebase: {
205-
gen: 2,
206-
httpsOptions: {
207-
region: 'europe-west1',
208-
maxInstances: 3,
209-
},
210-
},
211-
},
212-
});
213-
```
214-
215-
::
216-
217-
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.
218-
219-
#### Runtime Node.js version
220-
221-
You can set custom Node.js version in configuration:
222-
223-
::code-group
224-
225-
```ts [nitro.config.ts]
226-
export default defineNitroConfig({
227-
firebase: {
228-
nodeVersion: "20" // Can be "16", "18", "20" or "22"
229-
},
230-
});
231-
```
232-
233-
```ts [nuxt.config.ts]
234-
export default defineNuxtConfig({
235-
nitro: {
236-
firebase: {
237-
nodeVersion: "20" // Can be "16", "18", "20" or "22"
238-
},
239-
},
240-
});
241-
```
242-
243-
::
244-
245-
Firebase tools use the `engines.node` version in `package.json` to determine which node version to use for your functions. Nitro automatically writes to the `.output/server/package.json` with configured Node.js version.
246-
247-
You might also need to add a runtime key to your `firebase.json` file:
248-
249-
```json [firebase.json]
250-
{
251-
"functions": {
252-
"source": ".output/server",
253-
"runtime": "nodejs20"
254-
}
255-
}
256-
```
257-
258-
You can read more about this in [Firebase Docs](https://firebase.google.com/docs/functions/manage-functions?gen=2nd#set_nodejs_version).
259-
260-
### If your firebase project has other cloud functions
261-
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:
263-
264-
```bash
265-
firebase deploy --only functions:server,hosting
266-
```
267-
268-
### Advanced
269-
270-
#### Renaming function
271-
272-
When deploying multiple apps within the same Firebase project, you must give your server a unique name in order to avoid overwriting
273-
your functions.
274-
275-
You can specify a new name for the deployed Firebase function in your configuration:
276-
277-
::code-group
278-
279-
```ts [nitro.config.ts]
280-
export default defineNitroConfig({
281-
firebase: {
282-
serverFunctionName: "<new_function_name>"
283-
}
284-
})
285-
```
286-
287-
```ts [nuxt.config.ts]
288-
export default defineNuxtConfig({
289-
nitro: {
290-
firebase: {
291-
serverFunctionName: "<new_function_name>"
292-
}
293-
}
294-
})
295-
```
296-
297-
::
298-
299-
::important
300-
`firebase.serverFunctionName` must be a valid JS variable name and cannot include dashes (`-`).
301-
::
29+
When you deploy with Firebase App Hosting, the App Hosting preset will be run automatically at build time.

0 commit comments

Comments
 (0)