UNPKG

react-devtools-blocker

Version:

[![npm version](https://img.shields.io/npm/v/react-devtools-blocker.svg?style=flat-square)](https://www.npmjs.com/package/react-devtools-blocker) [![license](https://img.shields.io/npm/l/react-devtools-blocker.svg?style=flat-square)](https://github.com/y

143 lines (101 loc) โ€ข 3.85 kB
# ๐Ÿ›ก๏ธ DevTools Guard [![npm version](https://img.shields.io/npm/v/react-devtools-blocker.svg?style=flat-square)](https://www.npmjs.com/package/react-devtools-blocker) [![license](https://img.shields.io/npm/l/react-devtools-blocker.svg?style=flat-square)](https://github.com/yourusername/react-devtools-blocker/blob/main/LICENSE) A React/Next.js component to detect and block browser DevTools access, with instant redirection to a safe page. > Developed with โค๏ธ by [Pressbuddy Software Solutions](https://pressbuddy.in) --- ## ๐Ÿš€ Grow Your Business with Us We offer end-to-end digital services to grow your business: - ๐Ÿ’ป Website & Web App Development - ๐Ÿ“ฑ Mobile App Development (React Native / Flutter) - ๐Ÿ›’ E-commerce Solutions - ๐Ÿง  Custom Software & Automation Tools - ๐ŸŽจ UI/UX Design - โ˜๏ธ Cloud Hosting & DevOps - ๐Ÿงพ Billing & Inventory Software ๐Ÿ“ž **Contact us for your next project:** [pressbuddy.in/contact](https://pressbuddy.in/contact) | +91 9922852793 --- ## ๐Ÿ“‘ Table of Contents - [Grow Your Business with Us](#-grow-your-business-with-us) - [Features](#-features) - [Installation](#-installation) - [Usage](#-usage) - [Props](#-props) - [Use Cases](#-use-cases) - [Limitations](#-limitations) - [Contributing](#-contributing) - [License](#-license) --- ## ๐Ÿš€ Features - Detects browser DevTools using multiple methods (window dimensions, debugger traps) - Instant redirect to custom URL when DevTools is detected - Lightweight and framework compatible (React, Next.js, etc.) - Simple plug-and-play implementation - TypeScript support included ## ๐Ÿ“ฆ Installation ### Using npm ```bash npm install react-devtools-blocker ``` ### Using yarn ```bash yarn add react-devtools-blocker ``` ## ๐Ÿง  Usage > **Note for Next.js 13+** > This package must be used inside a [Client Component](https://nextjs.org/docs/getting-started/react-essentials#the-use-client-directive). > Add `"use client"` at the top of your component file. ### Basic Implementation ```jsx import DevToolsGuard from 'react-devtools-blocker'; function App() { return ( <> <DevToolsGuard redirectUrl="/blocked-page" /> {/* Your app content */} </> ); } ``` ### Next.js App Router (Client Component) ```jsx "use client"; import DevToolsGuard from 'react-devtools-blocker'; export default function Layout({ children }) { return ( <> <DevToolsGuard /> {children} </> ); } ``` ## โš™๏ธ Props | Prop | Type | Required | Default | Description | |----------------|---------|----------|------------------------------|---------------------------------------------| | `redirectUrl` | string | No | "https://www.google.com" | URL to redirect when DevTools are detected | | `debug` | boolean | No | false | Enables console logs for debugging | ## ๐Ÿ” Use Cases Protect sensitive applications like: - Online exams/testing platforms - Digital product access - Game logic protection - Client-side business logic - Anti-cheat mechanisms ## โš ๏ธ Limitations - Not 100% foolproof (no client-side solution can be) - May trigger on mobile devices with unusual screen ratios - Can be bypassed by determined users <!-- ## ๐Ÿง‘โ€๐Ÿ’ป Development ```bash # Clone repository git clone https://github.com/yourusername/react-devtools-blocker.git # Install dependencies npm install # Run dev server npm run dev ``` --> ## ๐Ÿค Contributing Pull requests are welcome! Please open an issue first to discuss changes. ## ๐Ÿ“ƒ License MIT ยฉ [Pressbuddy Software Solutions](https://pressbuddy.in)