Skip to content
Discussion options

You must be logged in to vote

Use router.resolve() for this. It is the API Vue Router uses to turn a route location object into the final URL/href without navigating.

For example, with a named route:

import { computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'

const route = useRoute('/talks/[talkId]/get-started')
const router = useRouter()

const url = computed(() => {
  const { href } = router.resolve({
    name: '/talks/[talkId]/overview',
    params: { talkId: route.params.talkId },
  })

  return new URL(href, window.location.origin).href
})

router.resolve() gives you the path that Vue Router would use for a <RouterLink>, including the router base if you configured one. new URL(href, window.loc…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@posva
Comment options

posva Feb 6, 2026
Maintainer

@Barbapapazes
Comment options

@posva
Comment options

posva Feb 7, 2026
Maintainer

Comment options

You must be logged in to vote
0 replies
Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants