2022-10-06 09:15:30 +00:00
|
|
|
---
|
|
|
|
title: "useRequestEvent"
|
|
|
|
description: "You can use useRequestEvent to access the incoming request."
|
|
|
|
---
|
2022-06-09 11:07:28 +00:00
|
|
|
|
2022-10-06 09:15:30 +00:00
|
|
|
# `useRequestEvent`
|
2022-06-09 11:07:28 +00:00
|
|
|
|
|
|
|
Within your pages, components, and plugins you can use `useRequestEvent` to access the incoming request.
|
|
|
|
|
|
|
|
```js
|
|
|
|
// Get underlying request event
|
|
|
|
const event = useRequestEvent()
|
|
|
|
|
|
|
|
// Get the URL
|
2022-11-15 14:33:43 +00:00
|
|
|
const url = event.node.req.url
|
2022-06-09 11:07:28 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
::alert{icon=👉}
|
|
|
|
In the browser, `useRequestEvent` will return `undefined`.
|
|
|
|
::
|