Environment
- Operating System: Linux
- Node Version: v18.20.3
- Nuxt Version: 2.17.3
- CLI Version: 3.11.1
- Nitro Version: 2.9.6
- Package Manager: npm@10.2.3
- Builder: webpack
- User Config: head, components, bridge, serverHandlers, devServerHandlers, devServer, typescript, nitro, buildModules
- Runtime Modules: -
- Build Modules: (), @nuxt/bridge@3.2.1
Reproduction
Nuxt Bridge reproduction
https://stackblitz.com/edit/nuxt-bridge-starter-nbqmvf?file=pages%2Findex.vue
Nuxt 3 reproduction
https://stackblitz.com/edit/nuxt-starter-me3k42?file=pages%2Findex.vue
Describe the bug
Utility helper navigateTo does not return a promise, thus cannot be awaited.
The method router.push has the same behaviour. You may notice, that the app crashes on router.push('/').then(() => {}), because there is no .then in undefined
In this Nuxt Bridge reproduction I have tried to add await to the navigateTo, and second alert fires synchronously.
But in Nuxt 3, await makes the difference and second alert fires after navigation complete.
A little bit of code
pages/index.vue
<template>
<div>
<button @click="navigateToTodos">navigateTo</button>
</div>
</template>
<script lang="ts" setup>
const navigateToTodos = async () => {
alert(1);
await navigateTo('/todos');
alert(3)
};
</script>
pages/todos/index.vue
<template>
<div>
Todos
</div>
</template>
<script lang="ts" setup>
if (process.client) {
alert(2);
}
</script>
Additional context
No response
Logs
No response
Environment
Reproduction
Nuxt Bridge reproduction
https://stackblitz.com/edit/nuxt-bridge-starter-nbqmvf?file=pages%2Findex.vue
Nuxt 3 reproduction
https://stackblitz.com/edit/nuxt-starter-me3k42?file=pages%2Findex.vue
Describe the bug
Utility helper
navigateTodoes not return a promise, thus cannot be awaited.The method
router.pushhas the same behaviour. You may notice, that the app crashes onrouter.push('/').then(() => {}), because there is no.theninundefinedIn this Nuxt Bridge reproduction I have tried to add
awaitto thenavigateTo, and second alert fires synchronously.But in Nuxt 3,
awaitmakes the difference and second alert fires after navigation complete.A little bit of code
pages/index.vue
pages/todos/index.vue
Additional context
No response
Logs
No response