Skip to content

Commit 4f46453

Browse files
committed
docs: deployment instructions with routeRules
1 parent 0ae4539 commit 4f46453

File tree

2 files changed

+53
-41
lines changed

2 files changed

+53
-41
lines changed

docs/nuxt/deployment.md

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,50 @@
22

33
> This section is a work in progress.
44
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
66

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:
88

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({
1237
nitro: {
13-
prerender: {
14-
routes: ['/', '/products'],
15-
},
38+
preset: 'firebase',
1639
},
17-
//
40+
// ...
1841
})
1942
```
2043

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:
2249

2350
```ts
2451
// nuxt.config.ts
@@ -37,21 +64,7 @@ defineNuxtConfig({
3764
})
3865
```
3966

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
5568

5669
To customize the Firebase functions configuration, it's recommended to create your own _nitro preset_ instead of using the `firebase` preset.
5770

@@ -100,19 +113,3 @@ export default defineNuxtConfig({
100113
```
101114

102115
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.

firestore.rules

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ service cloud.firestore {
44
match /__tests/{document=**} {
55
allow read, write;
66
}
7+
8+
match /todos/{todoId} {
9+
allow read, write;
10+
}
11+
match /tweets/{todoId} {
12+
allow read, write;
13+
}
14+
match /users/{todoId} {
15+
allow read: if request.auth.uid != null;
16+
allow write: if false;
17+
}
18+
match /configs/jORwjIykFo2NmkdzTkhU {
19+
allow read, write;
20+
}
21+
722
match /{document=**} {
823
allow read, write: if false;
924
}

0 commit comments

Comments
 (0)