---
title: "useRequestEvent"
description: "使用 useRequestEvent 组合函数访问传入的请求事件。"
canonical_url: "https://nuxt.zhcndoc.com/docs/3.x/api/composables/use-request-event"
---
# useRequestEvent

> 使用 useRequestEvent 组合函数访问传入的请求事件。

在 [Nuxt context](https://nuxt.zhcndoc.com/docs/3.x/guide/going-further/nuxt-app#the-nuxt-context) 中，你可以使用 `useRequestEvent` 访问传入的请求。

```ts
// 获取底层请求事件
const event = useRequestEvent()

// 获取 URL
const url = event?.path
```

::tip
在浏览器中，`useRequestEvent` 会返回 `undefined`。
::

---

- [源码](https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/composables/ssr.ts)


## Sitemap

See the full [sitemap](https://nuxt.zhcndoc.com/sitemap.md) for all pages.
