r/reactjs • u/Kratos_Rango • Sep 13 '26
Show /r/reactjs I made a small React package for protecting text from casual copying
I recently built react-text-protect, mostly as an experiment to see how far you can go with client-side content protection in React.
You wrap your content like this:
<ProtectedText userId="student_123">
What is the capital of France?
</ProtectedText>It currently has a few things:
• Intercepts copying and replaces the copied text with Vigenère-encrypted text
• Adds a user ID and timestamp watermark over the content
• Detects DevTools being opened and hides the content
• Obfuscates the text stored in the DOM
I originally made it with things like online exams and educational content in mind, where you might want to make copying or sharing a little more annoying.
Obviously, this is not real security. If someone is determined enough, they can get around basically everything happening on the client side. You can disable JavaScript, use another device to photograph the screen, inspect the application differently, etc.
The goal is really just adding friction, not pretending you can make browser content impossible to extract.
It's on npm if anyone wants to try it:
npm install react-text-protect
I'd genuinely like feedback from people who know React better than me, especially around the implementation and whether some of the approaches I'm using are problematic or could be improved.
9
u/Agreeable-Yogurt-487 Sep 13 '26
user-select: none;done4
u/doilyuser Sep 13 '26
Copied with Android Gemini Overlay
1
u/Strange_Lecture_ Sep 13 '26
The best developer tool is the one that gets out of your way and does not require a 40-page manual just to configure webhooks.
5
u/Merry-Lane Sep 13 '26
At the time where everyone screenshots everything into a LLM, yeah, your package is near useless.
1
u/AggressiveYam811 Sep 13 '26
Anyone taking a picture of a screen with a phone kills everything this package does. you shipped vigenere and devtools detection for people who read text
-7
u/Kratos_Rango Sep 13 '26
For the people with 100+ iqs and the inability to read.
"Obviously, this is not real security. If someone is determined enough, they can get around basically everything happening on the client side. You can disable JavaScript, use another device to photograph the screen, inspect the application differently, etc."
"The goal is really just adding friction, not pretending you can make browser content impossible to extract."
dont be a smartass