Nuxt · Routing

NUXT0047Do not navigate with router.push/replace during setup

Flags router navigation in setup in Nuxt routing code before it leaks into runtime behavior.

Why it happens

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

Fix

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>

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

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