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
Copy file name to clipboardExpand all lines: docs/nuxt/deployment.md
+38-41Lines changed: 38 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,23 +2,50 @@
2
2
3
3
> This section is a work in progress.
4
4
5
-
It is recommended not to SSR every route in your application. Instead, you should only SSR or SSG (generate at build) the routes that are critical for SEO and performance. For example, you can SSG the homepage and the product pages, but not the cart page or profile pages.
5
+
## Spark plan
6
6
7
-
You can achieve this by combining the [`prerender` option for nitro](https://nuxt.com/docs/getting-started/deployment#selective-pre-rendering):
7
+
The Spark plan is a free plan that enable most of firebase services. With this plan, you want to **prerender your app and deploy it as a static site**. In order to do this, make sure **not to apply the Firebase preset** when bundling your app and to use the `generate` command:
8
8
9
-
```ts
10
-
// nuxt.config.ts
11
-
defineNuxtConfig({
9
+
```sh
10
+
nuxt generate
11
+
```
12
+
13
+
You can then let your CI deploy your app to Firebase or do it manually:
14
+
15
+
```sh
16
+
firebase deploy
17
+
```
18
+
19
+
Note that this requires `ssr: true` in your `nuxt.config.ts` but you can also use `ssr: false` and deploy your Nuxt app as a Single Page Application to Firebase Hosting. In that case you should run `nuxt build` instead of `nuxt generate` as the latter requires SSR.
20
+
21
+
## Blaze plan
22
+
23
+
::: warning
24
+
The Firebase preset is still experimental. It is not recommended to use it in production.
25
+
:::
26
+
27
+
The Blaze plan is a pay-as-you-go that allows you to run Firebase Functions. **It is free up to a certain amount of requests**. With this plan, you can either do the same as with the [Spark plan](#spark-plan) (cheaper) or build with the Firebase preset and deploy your app as a serverless function:
28
+
29
+
```sh
30
+
NITRO_PRESET=firebase nuxt build
31
+
```
32
+
33
+
alternatively, you can use the `nitro.preset` option in your `nuxt.config.ts`, which will only be applied during builds.
34
+
35
+
```ts{3}
36
+
export default defineNuxtConfig({
12
37
nitro: {
13
-
prerender: {
14
-
routes: ['/', '/products'],
15
-
},
38
+
preset: 'firebase',
16
39
},
17
-
//
40
+
// ...
18
41
})
19
42
```
20
43
21
-
and the [`routeRules` option](https://nuxt.com/docs/guide/concepts/rendering#hybrid-rendering) to enable Hybrid rendering:
44
+
### Route Rules
45
+
46
+
On top of prerendering any routes, you can also use [the `routeRules` option](https://nuxt.com/docs/guide/concepts/rendering#hybrid-rendering) to apply any headers like cache options, redirects or even static rendering.
47
+
48
+
It is recommended **not to SSR** every route in your application. Instead, you should only SSR or SSG (generate at build) the routes that are critical for SEO and performance. For example, you can SSG the homepage and the product pages, but not the cart page or the admin dashboard. Here is an example of a `routeRules` configuration:
22
49
23
50
```ts
24
51
// nuxt.config.ts
@@ -37,21 +64,7 @@ defineNuxtConfig({
37
64
})
38
65
```
39
66
40
-
## Spark plan
41
-
42
-
The Spark plan is a free plan that enable most of firebase functions. With this plan, you want to **prerender your app and deploy it as a static site**. In order to do this, make sure **not to apply the Firebase preset** when bundling your app and to use the `generate` command:
43
-
44
-
```sh
45
-
nuxt generate
46
-
```
47
-
48
-
You can then let your CI deploy your app to Firebase or do it manually:
49
-
50
-
```sh
51
-
firebase deploy
52
-
```
53
-
54
-
### Nitro Preset
67
+
### Custom Nitro Preset
55
68
56
69
To customize the Firebase functions configuration, it's recommended to create your own _nitro preset_ instead of using the `firebase` preset.
Make sure you **don't have** a `nitro.preset` option set in your `nuxt.config.ts` file.
103
-
104
-
## Blaze plan
105
-
106
-
::: warning
107
-
The Firebase preset is still experimental. It is not recommended to use it in production.
108
-
:::
109
-
110
-
The Blaze plan is a pay-as-you-go that allows you to run Firebase Functions. It's free up to a certain amount of requests. With this plan, you can either do the same as with the [Spark plan](#spark-plan) (cheaper) or build with the Firebase preset and deploy your app as a serverless function:
111
-
112
-
```sh
113
-
NITRO_PRESET=firebase nuxt build
114
-
```
115
-
116
-
### Route Rules
117
-
118
-
On top of prerendering any routes, you can also use [the `routeRules` option](https://nuxt.com/docs/api/configuration/nuxt-config#routerules-1) to apply any headers like cache options, redirects or even static rendering.
0 commit comments