Nuxt · NUXT0047

Do not navigate with router.push/replace during setup

Flags router navigation in setup in Nuxt routing code before it leaks into runtime behavior.
NUXT0047vite-doctor/nuxtroutingwarnSuggestion

Run this rule

pnpm nuxt doctor --rules nuxt/routing/no-router-navigation-in-setup

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 router navigation in setup, or move it to the Nuxt runtime/API that owns that behavior.

Example

Move navigation out of setup render

Before

<script setup lang="ts">
const router = useRouter()
router.push('/login')
</script>

After

<script setup lang="ts">
const router = useRouter()
function goToLogin() {
  return router.push('/login')
}
</script>
Copyright © 2026