christophe77 / react-adblock-checker

React hook in typescript that detects if browser is using an adblocker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-adblock-checker

Check if browser has any adblocker enabled.

Installation

yarn add react-adblock-checker
or
npm i react-adblock-checker

Usage

Import the package in any js / jsx / ts / tsx file

import useAdBlockChecker from 'react-adblock-checker';

Get the adblocker status like this :

const { isAdBlockActive } = useAdBlockChecker();

isAdBlockActive is a boolean giving you the adblocker status. No need to use a useEffect hook, the variable changes by itself.

Example :

const Example = () => {
    const { isAdBlockActive } = useAdBlockChecker()

    return <h1>Adblocker enabled : {isAdBlockActive.toString()}</h1>
}
export default Example

About

React hook in typescript that detects if browser is using an adblocker

License:MIT License


Languages

Language:TypeScript 81.0%Language:JavaScript 19.0%