Nuxe exposes four server-aware composables for reading the incoming HTTP request during SSR. All four are safe to call in isomorphic code: on the client they return empty values (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/dvlkit/nuxe/llms.txt
Use this file to discover all available pages before exploring further.
undefined, {}, the current location, or the plain $fetch client) rather than throwing. This lets you write a single composable that works on both the server and the client without conditional guards.
These composables return meaningful data only on the server during an SSR render. Calling them from a client-side event handler or lifecycle hook after hydration will return the documented fallback values.
useRequestEvent
Returns the raw incoming Request object for the current SSR render. This is the standard Fetch API Request, giving you access to .url, .method, .headers, and the full request body.
Signature
Return value
The incoming
Request on the server, or undefined on the client.useRequestHeaders
Returns a plain object containing all incoming request headers. Header names are lowercased (as per the Fetch API Headers normalization).
Signature
Return value
A
{ [headerName]: value } map on the server, or an empty object ({}) on the client.useRequestURL
Constructs and returns a URL object for the current request. On the server it parses the incoming request URL, optionally using X-Forwarded-Host and X-Forwarded-Proto headers to reconstruct the public-facing origin when Nuxe runs behind a reverse proxy.
Signature
When
true (the default), the X-Forwarded-Host request header is used as the hostname component of the URL. Set to false to always use the Host header regardless of proxy headers.When
true (the default), the X-Forwarded-Proto header is used to determine the protocol (http or https). Set to false to fall back to X-Real-Proto or http.Return value
A standard
URL instance. On the server this reflects the incoming request URL (with proxy header resolution applied). On the client this is new URL(globalThis.location.href).useRequestFetch
Returns a $Fetch instance that forwards the incoming server request’s headers (cookies, authorization, etc.) to outgoing fetch calls. Use this when you need to proxy authenticated requests to an upstream API during SSR.
Signature
An optional object supplying a custom request context. When omitted,
useRequestFetch reads headers and URL from the current SSR context automatically via useNuxeApp(). Pass an explicit event when you need to forward headers from a different request (e.g. inside a Nuxe server plugin).Return value
On the server: a
$Fetch instance pre-configured with the incoming request headers and a baseURL derived from the incoming request origin. Relative URLs are automatically resolved against that base. Absolute URLs are sent as-is without a base.On the client: the plain global $fetch instance (no special headers are injected).