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.
nuxt/routing/no-router-navigation-in-setupsrc/rule-packs/nuxt/rules/nuxt/no-router-navigation-in-setup.ts Upstream docs 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.
Recommended fix
Remove router navigation in setup, or move it to the Nuxt runtime/API that owns that behavior.
Useful links
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>