adblock-detect-react
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • Public • Published

adblock-detect-react

npm version Publish Status

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

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

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

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

Package Sidebar

Install

npm i adblock-detect-react

Weekly Downloads

8,963

Version

1.3.1

License

MIT

Unpacked Size

42.2 kB

Total Files

29

Last publish

Collaborators

  • aruniverse