New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

detect-adblock-react

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detect-adblock-react

Adblock detector for React

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
57
increased by307.14%
Maintainers
1
Weekly downloads
 
Created
Source

Detect AdBlock React

npm version npm downloads license

AdBlock detector for React. Live example - detect-adblock-react.ivanadmaers.com

Features

  • ✅ Ease of use
  • 🔧 Well-tested
  • 📦 Lightweight
  • 📝 MIT license
  • 🎉 NextJS, GatsbyJS and RemixJS support

Installation

# Via npm:
npm i detect-adblock-react

# Via yarn:
yarn add detect-adblock-react

Usage

import React from 'react';
import { useDetectAdblock } from 'detect-adblock-react';

const App = () => {
  const { adBlockDetected } = useDetectAdblock();

  return (
    <div>
      {adBlockDetected === null && <p>Defining…</p>}
      {adBlockDetected === false && <p>AdBlock was not detected</p>}
      {adBlockDetected === true && <p>AdBlock was detected</p>}
    </div>
  );
};

export default App;

Hook returns

adBlockDetected - was AdBlock detected or not. Null only when defining for the first time - null | boolean

detect - call this function if you need to check AdBlock one more time - function

const { adBlockDetected, detect } = useDetectAdblock();

useEffect(() => {
  setTimeout(() => {
    // Check AdBlock again after time
    detect();
  }, 5 * 1000);
}, []);

Local development

  1. Clone the project

  2. Run

npm ci i

npm start

The last command runs webpack to compile our package to a dist folder

  1. cd example/

  2. Run

npm ci i

npm start

The last command runs webpack dev server

  1. Enjoy the magic!

License

MIT

Copyright (c) 2022-present, Ivan Admaers

Keywords

FAQs

Package last updated on 03 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc