# adblock-detect-react

> Provides utilities to check if ad block is enabled on a page via both a React hook and a wrapper component.

Latest version **1.3.1** (published 2024-01-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install adblock-detect-react
pnpm add adblock-detect-react
yarn add adblock-detect-react
bun add adblock-detect-react
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2024-01-03 |
| First published | 2020-07-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 41.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 66 |
| Author | https://github.com/aruniverse |
| Maintainers | aruniverse |
| Keywords | react, hooks, adblock, ad, block, detect |

## Links

- npm: https://www.npmjs.com/package/adblock-detect-react
- Repository: https://github.com/aruniverse/adblock-detect-react
- Homepage: https://github.com/aruniverse/adblock-detect-react#readme
- Issues: https://github.com/aruniverse/adblock-detect-react/issues
- npm.io page: https://npm.io/package/adblock-detect-react

## 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.3.1 (latest) — 2024-01-03
- 1.3.0 — 2023-12-29
- 1.2.0 — 2023-12-29
- 1.1.0 — 2022-09-16
- 1.0.5 — 2021-11-29
- 1.0.4 — 2021-03-02
- 1.0.3 — 2021-02-11
- 1.0.2 — 2020-10-08
- 1.0.1 — 2020-09-30
- 1.0.0 — 2020-08-03
- 1.0.0-beta.2 — 2020-07-30
- 1.0.0-beta.1 — 2020-07-30
- 1.0.0-beta.0 — 2020-07-30

## README

# adblock-detect-react

[![npm version](https://badge.fury.io/js/adblock-detect-react.svg)](https://www.npmjs.com/package/adblock-detect-react)
![Publish Status](https://github.com/aruniverse/adblock-detect-react/workflows/Publish%20Package%20Pipeline/badge.svg)

## Description

Provides utilities to check if ad block is enabled on a page via either a React hook or a wrapper component.

## Example Usage

### useDetectAdBlock hook

```tsx
import React from "react";
import { useDetectAdBlock } from "adblock-detect-react";

const SomeFunctionalComponent = () => {
  const adBlockDetected = useDetectAdBlock();

  React.useEffect(() => {
    if (adBlockDetected) {
      window.alert("ad block detected");
    }
  }, []);

  return <div>{adBlockDetected && "Hello Ad Blocked Page"}</div>;
};
```

### AdBlockDetectedWrapper component

```tsx
import React from "react";
import { AdBlockDetectedWrapper } from "adblock-detect-react";

const SomeFunctionalComponent = () => {
  return (
    <AdBlockDetectedWrapper>
      <div>{"Hello Ad Blocked Page"}</div>
    </AdBlockDetectedWrapper>
  );
};
```

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