adblock-detect-react

July 29, 2020

A lightweight npm package that detects if a client is using an adblocker.

stats

Fetching stats...

demo

live demo site

example usage

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>;
};