Skip to main content
Within the Nuxt context you can use useRequestEvent to access the incoming request.
// Get underlying request event
const event = useRequestEvent()

// Get the URL
const url = event?.path
In the browser, useRequestEvent will return undefined.

Parameters

This composable does not take any parameters.

Return Values

event
H3Event | undefined
The h3 event object for the current request. Returns undefined on the client side.
path
string
The URL path of the request.
node
object
Node.js request and response objects.

Type

export function useRequestEvent(): H3Event | undefined