mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 15:42:09 +00:00
959 B
959 B
title | description | links | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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.
::code-group
<script setup lang="ts">
const url = useRequestURL()
</script>
<template>
<p>URL is: {{ url }}</p>
<p>Path is: {{ url.pathname }}</p>
</template>
<p>URL is: http://localhost:3000/about</p>
<p>Path is: /about</p>
::
::tip{icon="i-simple-icons-mdnwebdocs" color="gray" to="https://developer.mozilla.org/en-US/docs/Web/API/URL#instance_properties" target="_blank"} Read about the URL instance properties on the MDN documentation. ::