Skip to content

Instantly share code, notes, and snippets.

@hazadus
Last active July 28, 2023 05:19
Show Gist options
  • Save hazadus/3fcfe32dd8840d4f8061d4124c2cc210 to your computer and use it in GitHub Desktop.
Save hazadus/3fcfe32dd8840d4f8061d4124c2cc210 to your computer and use it in GitHub Desktop.
Reactive Routes in Nuxt 3/Vue
<script setup>
// Doesn't change when route changes
const route = useRoute();
// Changes when route changes
const path = useRoute().path;
// If we need the full route object in a reactive way, we can do this:
//
// Doesn't change when route changes
const route = useRoute();
// Changes when route changes
const route = useRouter().currentRoute.value;
</script>
<template>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment