---
title: useWindowEvent
description: "`useWindowEvent` is a custom hook that assigns an event listener to `window`."
links:
- source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/hooks/use-window-event
- storybook: https://yamada-ui.github.io/yamada-ui?path=/story/hooks-usewindowevent--basic
---
```tsx
const [count, setCount] = useState(0)
useWindowEvent("click", () => {
setCount((prev) => prev + 1)
})
return Click count: {count}
```
## Usage
```tsx
import { useWindowEvent } from "@yamada-ui/react"
```
```tsx
import { useWindowEvent } from "@/components/ui"
```
```tsx
import { useWindowEvent } from "@workspaces/ui"
```
```tsx
const [count, setCount] = useState(0)
useWindowEvent("click", () => {
setCount((prev) => prev + 1)
})
```
## Used By Components & Hooks