useRequestURL

Access the incoming request URL with the useRequestURL composable.

useRequestURL is a helper function that returns an URL object working on both server-side and client-side.

<script setup lang="ts">
const url = useRequestURL()
</script>

<template>
  <p>URL is: {{ url }}</p>
  <p>Path is: {{ url.pathname }}</p>
</template>
Read about the URL instance properties on the MDN documentation.