Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-anticapture

dimszy4220.1.5TypeScript support: included

A lightweight React component that helps prevent users from capturing (copying, selecting, printing, or screenshotting) sensitive information rendered on your website. Perfect for privacy, security, and content protection in React applications.

react, react-anticapture, anticapture, anti-capture, privacy, security, copy-protection, content-protection, prevent-copy, prevent-screenshot, screenshot, screenshot-prevention, screenshot-block, screenshot-protection, no-screenshot, no-copy, screen-capture, screen-recording, clipboard, clipboard-protection, clipboard-prevent, disable-copy, disable-screenshot, disable-print, context-menu, no-context-menu, devtools, react-component, ui-security, data-protection, prevent-selection, prevent-print, sensitive-data, user-select, secure-component, web-security, frontend-security, library, component

readme

React Anticapture

npm version CI Storybook deploy

NPM: react-anticapture
A lightweight React component that helps prevent users from capturing (copying, selecting, or screenshotting) sensitive information rendered on your website.

demo


✨ Overview

React Anticapture provides a drop-in <AntiCapture> component that you can wrap around any part of your React app to strongly discourage or block screen capture, selection, and copying of sensitive content.
It’s designed for scenarios where you want to provide an extra layer of deterrence for confidential UI sections.


🚀 Features

  • Block Text Selection & Copying: Prevents text selection and copying inside wrapped content.
  • Screenshot Deterrence: Applies CSS and event-based tricks to discourage screenshots (e.g., blur overlays, keyboard shortcut interception).
  • Block Context Menu: Disables right-click/context menu to make copying harder.
  • Clipboard Protection: Optionally blocks clipboard copy/paste.
  • Devtools Detection: (Optional) Can attempt to block/alert on devtools opening.
  • Lightweight: Zero dependencies, works with any React project (TypeScript & JavaScript).
  • Highly Configurable: Use props to customize behavior per use-case.

📦 Installation

pnpm add react-anticapture
# or
npm install react-anticapture
# or
yarn add react-anticapture

🛡 Usage

Simply import and wrap any sensitive page or component within <AntiCapture>:

import { AntiCapture } from 'react-anticapture';

function ConfidentialSection() {
  return (
    <AntiCapture>
      <h2>Confidential Information</h2>
      <p>
        This section contains sensitive information. Copying, selecting, and screenshots are discouraged.
      </p>
    </AntiCapture>
  );
}

You can also combine props to fine-tune the deterrence:

<AntiCapture
  screenshotPrevent={true}
  clipboardPrevent={true}
  devtoolsPrevent={true}
  userSelect={false}
>
  <SecretStuff />
</AntiCapture>

⚙️ Props

Prop Type Default Description
screenshotPrevent boolean true Prevents common screenshot and screen recording keyboard shortcuts (PrintScreen, Cmd+Shift+4, etc).
userSelect boolean true If true, allows user text selection. Set to false to block selection via CSS.
targetClick HTMLElement | null null Optional target element for dismissing blur overlay. Defaults to component's internal wrapper.
clipboardPrevent boolean false If true, prevents clipboard copy/paste actions and context menu inside the component.
devtoolsPrevent boolean false If true, detects and attempts to prevent developer tools from being open.

⚠️ Limitations & Caveats

  • No client-side solution can provide 100% protection against screenshots or determined users with advanced tools. This library is a deterrent, not a guarantee.
  • Some techniques may not work in all browsers or may be bypassed by browser extensions, accessibility tools, or OS-level features.
  • Use with consideration for user experience; some users dislike aggressive anti-capture measures.

🖥 Demo

Try it out instantly via Storybook:
Live Demo



📄 License

MIT


Inspired by modern needs for client-side data privacy and protection.