Nuxt · NUXT0048

Use middleware to/from arguments instead of useRoute

Flags useRoute in middleware in Nuxt routing code before it leaks into runtime behavior.
NUXT0048vite-doctor/nuxtroutingerrorSuggestion

Run this rule

pnpm nuxt doctor --rules nuxt/routing/no-useroute-in-middleware

Why it matters

Navigation helpers only work correctly in the runtime they were designed for. Returning the navigation result keeps redirects and aborts observable to Nuxt.

Remove useRoute in middleware, or move it to the Nuxt runtime/API that owns that behavior.

Example

Use middleware arguments

Before

export default defineNuxtRouteMiddleware(() => {
  const route = useRoute()
  if (!route.meta.auth) return
})

After

export default defineNuxtRouteMiddleware((to) => {
  if (!to.meta.auth) return
})
Copyright © 2026