new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Nuxt · Getting started · all subjects

migration/middleware

3 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Nuxt 3 route middleware format and defineNuxtRouteMiddleware

Nuxt 3 route middleware must use the defineNuxtRouteMiddleware helper function and accept two arguments: to and from (the routes). Instead of injecting store and redirect via context, use useState for state access and navigateTo() for navigation.

Nuxt 3 route middleware registration

Route middleware placed in the ~/middleware folder is automatically registered by name. Specify middleware in a component using definePageMeta rather than as a component option. Global middleware (like middleware that was in nuxt.config) should be placed in ~/middleware with a .global extension, for example ~/middleware/auth.global.ts.

Example: Nuxt 2 to Nuxt 3 route middleware migration

Nuxt 2 route middleware: export default function ({ store, redirect }) { if (!store.state.authenticated) { return redirect('/login') } } Nuxt 3 equivalent: export default defineNuxtRouteMiddleware((to, from) => { const auth = useState('auth'); if (!auth.value.authenticated) { return navigateTo('/login') } })

Give your agent this brain