#Correct way to use navigateTo

1 messages · Page 1 of 1 (latest)

versed sail
#

According to the documentation, a return or await needs to be used on navigateTo. When I do this in <script setup> of a page (using await), it doesn't work. But when I remove the await, it works fine. Am I using navigateTo correctly?

Nuxt

navigateTo is a helper function that programmatically navigates users.

#

Here is a code sample:

<template>
  <div>
    Sending you to the other page
  </div>
</template>

<script lang="ts" setup>
await navigateTo('/')
</script>

In this case, the address in the browser bar changes, but the page itself doesn't change. But when using navigateTo without a await, it works as expected.

cerulean swan
#

Works fine in my Nuxt 3. The only way I can make it fail is to add the await navigateTo('/') to the page displayed on the "/" route (which creates an infinite loop)

tawny thistle
#

do you happen to be using supabase

versed sail
versed sail
tropic onyx