Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/main' into docs/fix-docs-link
Browse files Browse the repository at this point in the history
  • Loading branch information
clemcode committed Oct 19, 2022
2 parents c670c50 + 3ef014a commit 29f14ae
Show file tree
Hide file tree
Showing 60 changed files with 273 additions and 176 deletions.
3 changes: 3 additions & 0 deletions .stackblitz/config.json
@@ -0,0 +1,3 @@
{
"startCommand": "pnpm build:stub && pnpm play"
}
1 change: 1 addition & 0 deletions docs/content/1.getting-started/10.deployment.md
Expand Up @@ -139,6 +139,7 @@ Nuxt 3 can be deployed to several cloud providers with a minimal amount of confi

- :IconCloud{class="h-5 w-4 inline mb-2"} [AWS](https://nitro.unjs.io/deploy/providers/aws)
- :LogoAzure{class="h-5 w-4 inline mb-2"} [Azure](https://nitro.unjs.io/deploy/providers/azure)
- :IconCloud{class="h-5 w-4 inline mb-2"} [Cleavr](https://nitro.unjs.io/deploy/providers/cleavr)
- :LogoCloudFlare{class="h-5 w-4 inline mb-2"} [CloudFlare](https://nitro.unjs.io/deploy/providers/cloudflare)
- :IconCloud{class="h-5 w-4 inline mb-2"} [Digital Ocean](https://nitro.unjs.io/deploy/providers/digitalocean)
- :LogoFirebase{class="h-5 w-4 inline mb-2"} [Firebase](https://nitro.unjs.io/deploy/providers/firebase)
Expand Down
2 changes: 1 addition & 1 deletion docs/content/2.guide/1.concepts/2.vuejs-development.md
Expand Up @@ -31,7 +31,7 @@ Most applications need multiple pages and a way to navigate between them. This i

### Example

:button-link[Open on StackBlitz]{href="https://stackblitz.com/edit/github-9hzuns?file=app.vue" blank}
:button-link[Open on StackBlitz]{href="https://stackblitz.com/edit/github-9hzuns?file=app.vue" blank .mr-2}
:button-link[Open on CodeSandbox]{href="https://codesandbox.io/s/nuxt-3-components-auto-import-2xq9z?file=/app.vue" blank}

The `app.vue` file is the entry point, which represents the page displayed in the browser window.
Expand Down
42 changes: 37 additions & 5 deletions docs/content/2.guide/1.concepts/3.rendering.md
Expand Up @@ -69,14 +69,46 @@ In most cases, universal rendering as performed in Nuxt 2 offers a good user and

### Hybrid Rendering

Hybrid rendering allows different caching rules per route and decides how the Server should respond to a new request on a given URL.

At the moment, every page (or **route**) of a Nuxt application must use the same rendering mode, client-side or universal. But in various cases, some pages could be generated at build time, while others should be client-side rendered. For example, think of a content website with an admin section. Every content page should be primarily static and generated once, but the admin section requires registration and behaves more like a dynamic application.

[Read the open RFC discussing implementation and gathering community feedback.](https://github.com/nuxt/framework/discussions/560)
Hybrid rendering allows different caching rules per route using **Route Rules** and decides how the Server should respond to a new request on a given URL.

### Rendering on CDN Edge Workers

Traditionally, server-side and universal rendering was only possible using Node.js. Nuxt 3 takes it to another level by directly rendering code in CDN edge workers, reducing latency and costs.

Nitro is the new [server engine](/guide/concepts/server-engine) that powers Nuxt 3. It offers cross-platform support for Node.js, Deno, Workers, and more. Nitro's design is platform-agnostic and allows rendering a Nuxt application at the edge, closer to your users, allowing replication and further optimizations.

### Route Rules

> 🧪 Route rules are still under active development, and subject to change.
Previously every route/page of a Nuxt application and server must use the same rendering mode, client-side or universal. But in various cases, some pages could be generated at build time, while others should be client-side rendered. For example, think of a content website with an admin section. Every content page should be primarily static and generated once, but the admin section requires registration and behaves more like a dynamic application.

Nuxt 3 starting from rc.12 comes with the public beta for route rules and hybrid rendering support. Using route rules you can define rules for a group of nuxt routes, change rendering mode or assign a cache strategy based on route! Nuxt server will automatically register corresponding middleware and wrap routes with cache handlers using [nitro caching layer](https://nitro.unjs.io/guide/introduction/cache). Whenever possible, route rules will be automatically applied to the deployment platform's native rules (currently Netlify and Vercel are supported).

- `redirect` - Define server-side redirects.
- `ssr` - Disables server-side rendering for sections of your app and make them SPA-only with `ssr: false`
- `cors` - Automatically adds cors headers with `cors: true` - you can customize the output by overriding with `headers`
- `headers` - Add specific headers to sections of your site - for example, your assets
- `static` and `swr` - `static` enables a single (on-demand) build; `swr` enables a static build, that lasts for a configurable TTL. (currently enables full incremental static generation on Netlify, with Vercel coming soon)

**Examples:**

```ts
export default defineNuxtConfig({
routeRules: {
// Static page generated on-demand, revalidates in background
'/blog/**': { swr: true },
// Static page generated on-demand once
'/articles/**': { static: true },
// Set custom headers matching paths
'/_nuxt/**': { headers: { 'cache-control': 's-maxage=0' } },
// Render these routes with SPA
'/admin/**': { ssr: false },
// Add cors headers
'/api/v1/**': { cors: true },
// Add redirect headers
'/old-page': { redirect: '/new-page' },
'/old-page2': { redirect: { to: '/new-page', statusCode: 302 } }
}
})
```
6 changes: 3 additions & 3 deletions docs/content/2.guide/2.directory-structure/1.server.md
Expand Up @@ -141,15 +141,15 @@ export default defineEventHandler(() => `Default api handler`)

```ts [server/api/submit.post.ts]
export default defineEventHandler(async (event) => {
const body = await useBody(event)
const body = await readBody(event)
return { body }
})
```

You can now universally call this API using `$fetch('/api/submit', { method: 'post', body: { test: 123 } })`.

::alert{type=warning title=Attention}
We are using `submit.post.ts` in the filename only to match requests with `POST` method that can accept the request body. When using `useBody` within a GET request, `useBody` will throw a `405 Method Not Allowed` HTTP error.
We are using `submit.post.ts` in the filename only to match requests with `POST` method that can accept the request body. When using `readBody` within a GET request, `readBody` will throw a `405 Method Not Allowed` HTTP error.
::

### Handling Requests With Query Parameters
Expand Down Expand Up @@ -275,7 +275,7 @@ Create a new file in `server/api/test.post.ts`:

```ts [server/api/test.post.ts]
export default defineEventHandler(async (event) => {
const body = await useBody(event)
const body = await readBody(event)
await useStorage().setItem('redis:test', body)
return 'Data is set'
})
Expand Down
6 changes: 3 additions & 3 deletions docs/content/3.api/1.composables/use-runtime-config.md
Expand Up @@ -40,7 +40,7 @@ export default defineNuxtConfig({
Variables that need to be accessible on the server are added directly inside `runtimeConfig`. Variables that need to be accessible on both the client and the server are defined in `runtimeConfig.public`.
::

::ReadMore{link="/guide/features/runtime-config"}
::ReadMore{link="/guide/going-further/runtime-config"}
::

## Acess Runtime Config
Expand Down Expand Up @@ -69,7 +69,7 @@ In this example, since `apiBase` is defined within the `public` namespace, it is

It is possible to update runtime config values using a matching environment variable name prefixed with `NUXT_`.

::ReadMore{link="/guide/features/runtime-config"}
::ReadMore{link="/guide/going-further/runtime-config"}
::

### Using the `.env` File
Expand Down Expand Up @@ -135,5 +135,5 @@ export default defineEventHandler((event) => {
})
```

::ReadMore{link="/guide/features/runtime-config"}
::ReadMore{link="/guide/going-further/runtime-config"}
::
6 changes: 3 additions & 3 deletions docs/content/5.community/2.reporting-bugs.md
Expand Up @@ -32,7 +32,7 @@ If your issue concerns Vue 3 or Vite, please try to reproduce it first with the

**Nuxt 3**:

:button-link[Nuxt 3 on StackBlitz]{href="https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz" blank}
:button-link[Nuxt 3 on StackBlitz]{href="https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz" blank .mr-2}
:button-link[Nuxt 3 on CodeSandbox]{href="https://codesandbox.io/p/github/nuxt/starter/v3-codesandbox" blank}

**Nuxt Bridge**:
Expand All @@ -41,8 +41,8 @@ If your issue concerns Vue 3 or Vite, please try to reproduce it first with the

**Vue 3**:

:button-link[Vue 3 SSR on StackBlitz]{href="https://stackblitz.com/github/nuxt-contrib/vue3-ssr-starter/tree/main?terminal=dev" blank}
:button-link[Vue 3 SSR on CodeSandbox]{href="https://codesandbox.io/p/github/nuxt-contrib/vue3-ssr-starter/main" blank}
:button-link[Vue 3 SSR on StackBlitz]{href="https://stackblitz.com/github/nuxt-contrib/vue3-ssr-starter/tree/main?terminal=dev" blank .mr-2}
:button-link[Vue 3 SSR on CodeSandbox]{href="https://codesandbox.io/p/github/nuxt-contrib/vue3-ssr-starter/main" blank .mr-2}
:button-link[Vue 3 SSR Template]{href="https://github.com/nuxt-contrib/vue3-ssr-starter/generate" blank}

Once you've reproduced the issue, remove as much code from your reproduction as you can (while still recreating the bug). The time spent making the reproduction as minimal as possible will make a huge difference to whoever sets out to fix the issue.
Expand Down
1 change: 1 addition & 0 deletions docs/public/_redirects
Expand Up @@ -74,4 +74,5 @@
/guide/deploy/providers/render https://nitro.unjs.io/deploy/providers/render 302!
/guide/deploy/providers/stormkit https://nitro.unjs.io/deploy/providers/stormkit 302!
/guide/deploy/providers/vercel https://nitro.unjs.io/deploy/providers/vercel 302!
/guide/deploy/providers/cleavr https://nitro.unjs.io/deploy/providers/cleavr 302!

2 changes: 1 addition & 1 deletion examples/advanced/config-extends/package.json
Expand Up @@ -3,7 +3,7 @@
"private": true,
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
},
"scripts": {
"dev": "nuxi dev",
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/jsx/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/advanced/module-extend-pages/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/advanced/testing/package.json
Expand Up @@ -7,6 +7,6 @@
"start": "nuxi preview"
},
"devDependencies": {
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/app-config/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/app/error-handling/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/app/plugins/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/app/teleport/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/auto-imports/components/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/auto-imports/composables/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/composables/use-async-data/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/composables/use-cookie/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/composables/use-fetch/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/composables/use-head/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/composables/use-state/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/essentials/hello-world/package.json
Expand Up @@ -7,6 +7,6 @@
"start": "nuxi preview"
},
"devDependencies": {
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/experimental/reactivity-transform/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/experimental/vite-node/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/experimental/wasm/package.json
Expand Up @@ -3,7 +3,7 @@
"private": true,
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
},
"scripts": {
"dev": "nuxi dev",
Expand Down
2 changes: 1 addition & 1 deletion examples/other/locale/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/routing/layouts/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/routing/middleware/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/routing/nuxt-link/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/routing/pages/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/routing/universal-router/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
2 changes: 1 addition & 1 deletion examples/server/routes/package.json
Expand Up @@ -8,6 +8,6 @@
},
"devDependencies": {
"@nuxt/ui": "^0.3.3",
"nuxt": "^3.0.0-rc.11"
"nuxt": "^3.0.0-rc.12"
}
}
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -48,23 +48,23 @@
"@nuxt/webpack-builder": "workspace:*",
"@nuxtjs/eslint-config-typescript": "^11.0.0",
"@types/crawler": "^1.2.2",
"@types/node": "^16.11.66",
"@types/node": "^16.11.68",
"@types/rimraf": "^3",
"@types/semver": "^7",
"@unocss/reset": "^0.45.29",
"@unocss/reset": "^0.45.30",
"case-police": "^0.5.10",
"changelogen": "^0.3.5",
"crawler": "^1.3.0",
"eslint": "^8.25.0",
"eslint-plugin-jsdoc": "^39.3.6",
"eslint-plugin-jsdoc": "^39.3.14",
"execa": "^6.1.0",
"expect-type": "^0.14.2",
"globby": "^13.1.2",
"jiti": "^1.16.0",
"markdownlint-cli": "^0.32.2",
"nuxi": "workspace:*",
"nuxt": "workspace:*",
"ohmyfetch": "^0.4.19",
"ohmyfetch": "^0.4.20",
"pathe": "^0.3.9",
"rimraf": "^3.0.2",
"semver": "^7.3.8",
Expand Down

0 comments on commit 29f14ae

Please sign in to comment.