Building a free reading gate that users can't trivially bypass
How I designed a two-layer daily reading quota — localStorage for UX, server-side for enforcement — and what I learned about where each layer should sit.
Free-tier gates on AI products have a fundamental tension: you want to show the user an accurate count of how many readings they have left (good UX), but you also need that count to be enforceable (security). These two requirements push toward different implementations.
Accurate counts need to be fast and local — nobody wants a network round-trip just to display "2 readings remaining." Enforcement needs to be server-side — anything that lives only in the browser can be cleared, modified, or bypassed.
The design for Magical Chart uses both layers explicitly, with each doing what it's suited for.
Layer 1: localStorage for display
The client-side state is a simple object stored in localStorage:
{
"dailyCount": 2,
"lastResetDate": "2026-05-14",
"sessionCount": 1
}
lastResetDate is compared to today's date on every page load. If they differ, dailyCount resets to 0. This is the display layer — it drives the UI: showing remaining count, greying out the draw button when the quota is reached, displaying the upgrade prompt.
It is not the enforcement layer. A user who opens DevTools and deletes their localStorage will see their count reset to 0 — the UI will show "readings remaining." But when they make the API call, the server checks independently.
Layer 2: server-side enforcement
Every reading request goes through a serverless function. That function checks usage against two signals:
For authenticated users (logged in): the check is against their usage record in the database. The counter is incremented on each successful generation and reset on a scheduled basis. If the count is at or above the free-tier limit, the API returns 429 regardless of what the client-side state claims.
For anonymous users (no account): the check is against a request fingerprint. No IP logging (privacy). The fingerprint is derived from request signals and a session token set at first visit. The goal isn't to make bypass impossible; it's to make casual bypass annoying enough that the legitimate upgrade path looks attractive by comparison.
// server-side check (simplified)
async function checkReadingQuota(req) {
const user = await getUser(req);
if (user) {
const count = await db.getUserDailyCount(user.id);
if (count >= FREE_TIER_DAILY_LIMIT) {
return { allowed: false, reason: 'daily_limit' };
}
} else {
const fingerprint = getAnonymousFingerprint(req);
const count = await db.getAnonymousCount(fingerprint);
if (count >= ANONYMOUS_DAILY_LIMIT) {
return { allowed: false, reason: 'daily_limit' };
}
}
return { allowed: true };
}
Two separate quotas, not one
There are actually two distinct daily quotas in the product, served by different pages with different user intents:
The homepage quota is higher. Users arriving at the homepage are likely new — they're evaluating whether the product is worth their time. A tighter quota here means they bounce before getting hooked. The goal is to let them experience enough that the upgrade case becomes obvious on its own.
The tool/article quotas are tighter. Users arriving through search to a specific reading type (Celtic cross spread, single card pull) are further in the funnel. They've already decided they want this kind of experience — the quota is a nudge toward the upgrade, not a gate that prevents discovery.
These quotas live in a config object, not hardcoded. Changing the homepage quota doesn't require touching the tool pages, and vice versa. When testing whether a looser quota improves conversion, you change one number, deploy, and compare the data.
The UX principle: don't lie to the user
The worst implementation pattern for a free-tier gate is showing the user a count that doesn't match what the server will actually do. If the UI shows "1 reading remaining" but the server rejects the next request because a previous session was counted separately, the user experience is confusing and trust-eroding.
The sync between client and server state needs to be tight. Every time the server confirms a successful generation, the client increments its own count. If the server rejects a request, the client updates its display to reflect the real remaining count — not what it thought it was. The localStorage state is a cache of the server's truth, not an independent source.
// After each API response:
if (response.ok) {
incrementLocalCount();
} else if (response.status === 429) {
// Don't trust local count — sync from server response
const { remaining } = await response.json();
setLocalCount(FREE_TIER_DAILY_LIMIT - remaining);
}
The design principle: client-side state should be treated as a display cache, not authoritative truth. Anything you don't want to enforce with server-side logic shouldn't be enforced at all. The flip side: anything you enforce server-side should be reflected client-side promptly, or users will face confusing rejections.
What I didn't build: account-required gates
An alternative design: require an account before any reading, eliminating the anonymous user problem entirely. This is simpler to implement and easier to enforce.
I decided against it. The funnel data was clear: users who experienced at least one reading before being asked to register converted to accounts at a significantly higher rate than users who hit a registration wall first. The free experience before friction is load-bearing. Making it account-only would have simplified the gate implementation but hurt the acquisition funnel.
The two-layer design is more complex precisely because the product decision required it. The complexity isn't accidental — it's the cost of maintaining a good free experience while still having a real gate.