From 1ee704c18439d97e8ba4a17338c6b2336b8fc0d9 Mon Sep 17 00:00:00 2001 From: Ryota Watanabe <43837308+wattanx@users.noreply.github.com> Date: Fri, 23 Jun 2023 23:47:21 +0900 Subject: [PATCH] docs: add `defineNuxtRouteMiddleware` migration (#21718) --- docs/6.bridge/1.overview.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/6.bridge/1.overview.md b/docs/6.bridge/1.overview.md index fda6665233..88aef297c9 100644 --- a/docs/6.bridge/1.overview.md +++ b/docs/6.bridge/1.overview.md @@ -233,6 +233,28 @@ If you want to use the new Nuxt composables (such as `useNuxtApp` or `useRuntime Although a compatibility interface is provided via `nuxtApp.vueApp` you should avoid registering plugins, directives, mixins or components this way without adding your own logic to ensure they are not installed more than once, or this may cause a memory leak. :: +## New Middleware Format (Optional) + +You can now migrate to the Nuxt 3 middleware API, which is slightly different in format from Nuxt 2. + +Middleware now take only two argument (`to`, `from`). You can find out more in [the docs](/docs/guide/directory-structure/middleware). + +```js +export default defineNuxtRouteMiddleware((to) => { + if (to.path !== '/') { + return navigateTo('/') + } +}) +``` + +::alert{type=warning} +Use of `defineNuxtRouteMiddleware` is not supported outside of the middleware directory. +:: + +::alert{type=warning} +Nuxt Bridge does not support `definePageMeta`. +:: + ## New `useHead` (Optional) Nuxt Bridge provides a new Nuxt 3 meta API that can be accessed with a new `useHead` composable.