# @loyhooks/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 2019-06-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @loyhooks/use-before-leave
pnpm add @loyhooks/use-before-leave
yarn add @loyhooks/use-before-leave
bun add @loyhooks/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 | 2019-06-06 |
| First published | 2019-06-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | LEE ON YOU |
| Maintainers | loy124 |
| Keywords | hooks, react, before, leave |

## Links

- npm: https://www.npmjs.com/package/@loyhooks/use-before-leave
- Repository: https://github.com/loy124/LoyHooks
- Homepage: https://github.com/loy124/LoyHooks#readme
- Issues: https://github.com/loy124/LoyHooks/issues
- npm.io page: https://npm.io/package/@loyhooks/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) — 2019-06-06

## README

# @loyhooks/use-before-leave

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

## Installation

#### yarn

`yarn add @loyhooks/use-before-leave`

#### npm

`npm i @loyhooks/use-before-leave`

## Usage

```js
import React from "react";
import useBeforeLeave from "@loyhooks/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/@loyhooks/use-before-leave · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
