Skip to content

Commit 4980c83

Browse files
committed
docs: deployment and ssr
1 parent 91d1102 commit 4980c83

File tree

2 files changed

+72
-6
lines changed

2 files changed

+72
-6
lines changed

docs/guide/ssr.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Server Side Rendering (SSR)
22

3-
<!-- NOTE: hide until it works -->
4-
<!-- ::: tip
5-
If you are using Nuxt.js, read the [Nuxt guide](/nuxt/getting-started.md) instead, most of the things are already configured for you.
6-
::: -->
3+
> Manually doing Server Side Rendering can get really complex, it is recommended to use Nuxt. Read the [Nuxt guide](/nuxt/getting-started.md), most of the things are already configured for you.
74
85
::: warning
96
SSR support is still experimental. Please report any issues you find.

docs/nuxt/deployment.md

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Deployment
22

3+
> This section is a work in progress.
4+
35
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.
46

5-
You can achieve this by combining the [`prerender` option for nitro](https://nuxt.com/docs/getting-started/deployment#manual-pre-rendering):
7+
You can achieve this by combining the [`prerender` option for nitro](https://nuxt.com/docs/getting-started/deployment#selective-pre-rendering):
68

7-
```ts{4-6}
9+
```ts
810
// nuxt.config.ts
911
defineNuxtConfig({
1012
nitro: {
@@ -16,6 +18,25 @@ defineNuxtConfig({
1618
})
1719
```
1820

21+
and the [`routeRules` option](https://nuxt.com/docs/guide/concepts/rendering#hybrid-rendering) to enable Hybrid rendering:
22+
23+
```ts
24+
// nuxt.config.ts
25+
defineNuxtConfig({
26+
routeRules: {
27+
// Homepage pre-rendered at build time
28+
'/': { prerender: true },
29+
// Product page generated on-demand, revalidates in background
30+
'/products/**': { swr: true },
31+
// Blog post generated on-demand once until next deploy
32+
'/blog/**': { isr: true },
33+
// Admin dashboard renders only on client-side
34+
'/admin/**': { ssr: false },
35+
},
36+
// ...
37+
})
38+
```
39+
1940
## Spark plan
2041

2142
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:
@@ -30,6 +51,54 @@ You can then let your CI deploy your app to Firebase or do it manually:
3051
firebase deploy
3152
```
3253

54+
### Nitro Preset
55+
56+
To customize the Firebase functions configuration, it's recommended to create your own _nitro preset_ instead of using the `firebase` preset.
57+
58+
Create a `preset` folder with two files:
59+
60+
::: code-group
61+
62+
```ts [preset/entry.ts]
63+
import '#internal/nitro/virtual/polyfill'
64+
import { onRequest } from 'firebase-functions/v2/https'
65+
66+
const nitroApp = useNitroApp()
67+
const config = useRuntimeConfig()
68+
69+
// you might need to name this function differently
70+
// if you have other functions deployed
71+
export const server = onRequest(
72+
{
73+
// You can set the region and other options here
74+
},
75+
toNodeListener(nitroApp.h3App)
76+
)
77+
```
78+
79+
```ts [preset/nitro.config.ts]
80+
import { fileURLToPath } from 'node:url'
81+
import type { NitroPreset } from 'nitropack'
82+
83+
export default {
84+
extends: 'firebase',
85+
entry: fileURLToPath(new URL('./entry.ts', import.meta.url)),
86+
} satisfies NitroPreset
87+
```
88+
89+
:::
90+
91+
Then set the `nitro.preset` in your `nuxt.config.ts`, this will only be used during the build process:
92+
93+
```ts{3}
94+
export default defineNuxtConfig({
95+
nitro: {
96+
preset: './preset',
97+
},
98+
// ...
99+
})
100+
```
101+
33102
Make sure you **don't have** a `nitro.preset` option set in your `nuxt.config.ts` file.
34103

35104
## Blaze plan

0 commit comments

Comments
 (0)