# @bro95-hooks/use-before-leave

> React Hook to execute a function when the mouse leaves the page. Useful to show a popup or for analytics.

Latest version **1.0.0** (published 2022-06-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bro95-hooks/use-before-leave
pnpm add @bro95-hooks/use-before-leave
yarn add @bro95-hooks/use-before-leave
bun add @bro95-hooks/use-before-leave
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-06-16 |
| First published | 2022-06-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | kimbro95 |
| Maintainers | kimbro95 |
| Keywords | react, hooks, leave, beforeleave, unload, mouseleave |

## Links

- npm: https://www.npmjs.com/package/@bro95-hooks/use-before-leave
- Repository: https://github.com/kimbro95/React-Hooks.git#main
- Homepage: https://github.com/kimbro95/React-Hooks/tree/main/hooks/useBeforeLeave#readme
- Issues: https://github.com/kimbro95/React-Hooks/tree/main/hooks/useBeforeLeave/issues
- npm.io page: https://npm.io/package/@bro95-hooks/use-before-leave

## 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

- 1.0.0 (latest) — 2022-06-16

## README

# @bro95-hooks/use-before-leave

📌React Hook to execute a function when the mouse leaves the page. Useful to show a popup or for analytics.

## Installation

#### npm

`npm i @bro95-hooks/use-before-leave`

## Usage

```js
import React from "react";
import useBeforeLeave from "@bro95-hooks/use-before-leave";

function App() {
  const beforeLeave = () => console.log("User is leaving...");
  useBeforeLeave(beforeLeave);
  return <h1>Hello Nooks</h1>;
}
```

### Arguments

| Argument      | Type     | Description                                              | Required |
| ------------- | -------- | -------------------------------------------------------- | -------- |
| onBeforeLeave | function | Function to be called when the mouse leaves the document | yes      |

---
_Source: https://npm.io/package/@bro95-hooks/use-before-leave · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
