extcharge

Guide

Freemium in a Chrome extension: gate paid features cleanly

1 December 2026

To gate paid features in a Chrome extension, write one access check function that every part of the extension calls, and let the UI and the feature code both ask it. That check decides what users see; it does not prove anyone paid, so anything that costs you money per use must also be checked on a server.

This guide covers the shared check, the difference between hiding a feature and enforcing it, the free experience, the upgrade button, trials, and where client-side checks stop.

Where should the access check live?

In one file. The popup, the options page, content scripts and the service worker all need the same answer to "may this user do X". If each one checks a flag its own way, they drift: the popup shows a feature as unlocked while the background refuses it, or the reverse.

Put the decision in a single function that returns plain booleans per feature. The rest of the code asks for access.canExport, never for plan === "pro". When you change what the free tier includes, you change one file.

// access.js — shared by popup, options page and service worker
const FREE_EXPORTS_PER_DAY = 3;

async function getAccess() {
  const { license, usage } = await chrome.storage.local.get(["license", "usage"]);
  const paid = Boolean(license && license.paid);
  const today = new Date().toISOString().slice(0, 10);
  const used = usage && usage.day === today ? usage.count : 0;
  return {
    paid,
    canExport: paid || used < FREE_EXPORTS_PER_DAY,
    exportsLeft: paid ? null : Math.max(0, FREE_EXPORTS_PER_DAY - used),
    canUseTemplates: paid,
  };
}

Load it as a classic script in popup.html with <script src="access.js"></script> before popup.js, and in the service worker with importScripts("access.js"). The popup then waits for the DOM and asks:

// popup.js
document.addEventListener("DOMContentLoaded", async () => {
  const access = await getAccess();
  const btn = document.querySelector("#export");
  btn.disabled = !access.canExport;
  if (access.exportsLeft !== null) {
    btn.textContent = `Export (${access.exportsLeft} left today)`;
  }
  document.querySelector("#upgrade").hidden = access.paid;
});

Where the license value comes from is a separate concern: your server, a payment service, or a cache of either. See Keep state in a Manifest V3 service worker for the cache with timestamp and max age.

Is hiding a button enough?

No. Hiding is UI gating. It tells honest users what they can use. Enforcement means the code that does the work asks the same function before it runs. A user can open the DevTools, un-hide the button and click it; the handler in the service worker should still check getAccess() and refuse.

Both layers use the same function, so they cannot disagree. Keep the enforcement next to the work: in the message handler that performs the export, not in the popup that sends the message.

Can a client-side check prove that a user paid?

No. Everything in the extension package is readable, and an unpacked copy can be edited. A user who changes getAccess() to return paid: true gets every feature that runs locally. No obfuscation changes that.

Two consequences:

The paid state itself must come from a system the user cannot edit: the payment provider's webhooks and a record a server keeps. A success page after checkout is not proof either, because anyone can open its URL.

What should a free user see?

The free tier should be useful on its own. A user who never pays should still understand what the extension does and why someone would pay for more. Patterns that work:

Avoid nagging. One upgrade prompt at the moment the user hits a limit beats a banner on every popup open.

Where does the upgrade button go?

At the point of need. Put it in three places at most:

  1. Next to the limit message ("You used today's 3 exports. Upgrade for unlimited exports.").
  2. On the locked feature itself, as the click action.
  3. In a fixed spot in the popup or options page, for users who decide on their own.

The button opens the checkout in a new tab. When the payment completes, the extension should refresh its paid state and update the open popup without asking the user to reinstall or restart. Listen for chrome.storage.onChanged in the popup and re-render when the license key changes.

How should a free trial work?

A trial is a start date plus a length. The access check adds one condition: paid || inTrial. Decide the length in code, for example seven days.

Where the start date lives matters. A date stored only in chrome.storage.local resets when the user reinstalls or clears the extension's data, so the trial restarts. A start date kept on a server and bound to something the user confirms, such as an email address, survives a reinstall. For more on trial design, see free trials in a Chrome extension.

Do it with your AI assistant

Paste this into Claude Code, Cursor or a similar coding assistant inside your extension's repository:

Read https://extcharge.com/guides/freemium-chrome-extension.html and apply it to this extension.

Adding payments

The shared access check needs a paid state it can trust. ExtCharge does the server side: Stripe Checkout on your own Stripe account, webhooks for renewals, failed payments, cancellations, and full refunds of one-time purchases, and server-side trials bound to a confirmed email. Your getAccess() reads user.paid and user.trialStartedAt from extcharge.getUser(). The one-prompt setup lets your AI assistant wire it in, and the integration guide covers every call.

Try ExtCharge on your extension

Connect your Stripe account, register your extension and add a plan. The dashboard walks you through it.