Plugins now have a different format, and take only one argument (nuxtApp).
export default (ctx, inject) => {
inject('injected', () => 'my injected function')
})
Read more about the format of nuxtApp.
defineNuxtPlugin helper function.nuxt.config plugins array that are located in your plugins/ folder. All files in this directory at the top level (and any index files in any subdirectories) will be automatically registered. Instead of setting mode to client or server, you can indicate this in the file name. For example, ~/plugins/my-plugin.client.ts will only be loaded on client-side.Route middleware has a different format.
export default function ({ store, redirect }) {
// If the user is not authenticated
if (!store.state.authenticated) {
return redirect('/login')
}
}
Much like Nuxt 2, route middleware placed in your ~/middleware folder is automatically registered. You can then specify it by name in a component. However, this is done with definePageMeta rather than as a component option.
navigateTo is one of a number of route helper functions.
defineNuxtRouteMiddleware helper function.nuxt.config) can be placed in your ~/middleware folder with a .global extension, for example ~/middleware/auth.global.ts.[
{
"title": "Meta Tags",
"path": "/nuxt/migration/meta",
"stem": "nuxt/7.migration/4.meta",
"description": "Manage your meta tags, from Nuxt 2 to Nuxt 3."
},
{
"title": "Pages and Layouts",
"path": "/nuxt/migration/pages-and-layouts",
"stem": "nuxt/7.migration/6.pages-and-layouts",
"description": "Learn how to migrate from Nuxt 2 to Nuxt 3 pages and layouts."
}
]