A metered paywall that counts in the browser can be reset by any reader
"You have 2 free articles left this month." Metered paywalls are common on news sites, newsletters, course platforms, and documentation portals. Many of them do the counting in the browser: a cookie or localStorage entry
"You have 2 free articles left this month." Metered paywalls are common on news sites, newsletters, course platforms, and documentation portals. Many of them do the counting in the browser: a cookie or localStorage entry holds the number of articles read, and a script decides whether to show the overlay.
That design is popular because it is cheap and works with aggressive CDN caching. It also means the reader controls the counter, and often the full article is already in the HTML under the overlay.
How client-side meters usually work
export function shouldBlock(meter, article) {
if (article.free || meter.subscriber) return false;
const seen = meter.read.includes(article.id);
return !seen && meter.read.length >= METER_LIMIT;
}
meter comes from localStorage or a cookie. The full article body is rendered server-side for SEO, and an overlay plus overflow: hidden hides it when shouldBlock returns true.
A reader can get past this by:
- Clearing site data, opening a private window, or switching browsers.
- Editing the localStorage entry in DevTools.
- Disabling JavaScript or using reader mode, since the text is already in the HTML.
- Overriding
shouldBlockwith DevTools Local Overrides or a userscript.
None of this requires skill, and protecting the script does nothing about the first three.
Decide what you are actually trying to do
Metered paywalls are a funnel, not a vault. Many publishers knowingly accept some leakage because the goal is to convert regular readers, not to stop every determined one. That is a legitimate choice. The problem is when a team believes the meter is enforcement and builds pricing or partner deals on that assumption.
Ask two questions:
- Is it acceptable that a motivated reader sees the content for free? If yes, a client meter is fine.
- Is the content itself the product (premium research, paid courses, licensed data)? If yes, it must not be in the HTML for non-subscribers at all.
What belongs on the server
- The full body of premium content, served only after an entitlement check.
- The authoritative meter for logged-in readers, keyed to the account rather than the browser.
- Subscriber status, read from a session, not from a flag in localStorage.
For anonymous readers you can still meter on the server with a signed cookie, edge middleware, or a lightweight counter keyed to a session ID. It is not perfect either, but clearing localStorage no longer resets it, and the article text is not shipped to readers who should not get it.
Where protection helps a little
If you keep a client meter as a soft funnel, protection is mostly about discouraging copy-paste bypass scripts that target your exact function and storage keys:
- Do not name the storage key
articlesRead; encrypt key names and limit constants so they are not searchable. - Keep the meter logic in its own small module and protect it with VM-based obfuscation so a one-line override is harder to write.
- Turn off public source maps.
That raises the effort for casual bypasses. It does not protect content that is already in the HTML, and it should not be sold internally as if it did.
VEILVM is a browser-based JSVMP tool (disclosure: I work on it). It is useful for a small client-side function like a meter or a pricing preview, not as a replacement for server-side entitlement.
Checklist
- [ ] Premium content is not in the HTML for readers without an entitlement.
- [ ] Logged-in meters are stored server-side per account.
- [ ] Subscriber status comes from the session, not localStorage.
- [ ] The client meter, if any, is treated as a funnel with expected leakage.
- [ ] Storage keys and meter logic are not trivially searchable; source maps are off.
- [ ] You tested reader mode and disabled JavaScript on a premium article.
If you want to try VM protection on a single extracted function, VEILVM runs in the browser with no sign-up: 3 free runs a day, up to 5 KB per file (resets at 00:00 UTC). A free account raises the input limit to 30 KB. Pro is $9/month or $79/year and adds an API so the protection step can run in CI. Standard requests are processed in memory and are not written to logs. Start at https://vm.ldvmp.com.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.