# @pacote/react-use-outside

> React hook to capture mouse or touch events outside a component.

Latest version **3.0.0** (published 2026-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install @pacote/react-use-outside
pnpm add @pacote/react-use-outside
yarn add @pacote/react-use-outside
bun add @pacote/react-use-outside
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2026-03-31 |
| First published | 2019-03-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Luís Rodrigues |
| Maintainers | goblindegook |
| Keywords | react, components, hoc, props |

## Links

- npm: https://www.npmjs.com/package/@pacote/react-use-outside
- Repository: https://github.com/PacoteJS/pacote
- Homepage: https://github.com/PacoteJS/pacote#readme
- Issues: https://github.com/PacoteJS/pacote/issues
- npm.io page: https://npm.io/package/@pacote/react-use-outside

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2026-03-31
- 2.0.6 — 2025-10-24
- 2.0.4 — 2025-02-25
- 2.0.3 — 2024-10-05
- 2.0.2 — 2023-08-25
- 2.0.1 — 2023-04-22
- 2.0.0 — 2023-04-13
- 1.1.11 — 2022-09-02
- 1.1.9 — 2021-08-13
- 1.1.8 — 2021-04-15
- 1.1.7 — 2020-11-27
- 1.1.6 — 2020-11-14
- 1.1.5 — 2020-09-05
- 1.1.4 — 2020-06-03
- 1.1.3 — 2020-05-21
- … 10 more at https://npm.io/package/@pacote/react-use-outside/versions

## README

# @pacote/react-use-outside

![version](https://badgen.net/npm/v/@pacote/react-use-outside)
![minified](https://badgen.net/bundlephobia/min/@pacote/react-use-outside)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/react-use-outside)

Hook to handle events outside React components.

## Installation

```bash
yarn add @pacote/react-use-outside
```

## Usage

### `useOutside<T>(type: Array<keyof DocumentEventMap> | keyof DocumentEventMap, listener: EventListener): React.RefObject<T>`

Takes one or more event types to listen and an event listener function and returns a reference which can be applied to a DOM element. The provided function will be called for all listened events triggered outside the component.

```tsx
import React from 'react'
import { useOutside } from '@pacote/react-use-outside'

const Modal = () => {
  const ref = useOutside('click', () => {
    console.log('Clicked outside!')
  })

  return <div ref={ref}>Click outside to show console message.</div>
}
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).

---
_Source: https://npm.io/package/@pacote/react-use-outside · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
