crxpay

TypeScript SDK

Three lines, typed, and Pro is live.

Install @crxpay/sdk, paste your key, ask hasEntitlement('pro'). The SDK is MV3-native, typed all the way down, and reads a signed cache so checks work offline.

Bundle
18 kB gz
MV3
native
Types
first-class
background.ts · crxpay
1import { CrxPay } from '@crxpay/sdk';
2 
3const pay = await CrxPay.initialize({
4 apiKey: 'pk_live_…',
5 testMode: 'auto',
6});
7 
8if (pay.hasEntitlement('pro')) {
9 unlockPro();
10}
tsc · 0 errors18.2 kB gzip
Live preview · code types itself

TypeScript SDK

The gritty stuff, handled.

Offline caching, service-worker routing, state machines, type safety. You write three lines, we run the engine.

// chrome.storage.local
crxpay:sub ={
"entitlements": ["pro"],
"expires": 1746201600,
"sig": "hmac-sha256…"
}
Signature verified · works offline
1

Offline-first, signed cache

Every subscription state is HMAC-signed and cached locally. The SDK reads it in under 1ms so Pro stays on even when the user is on a plane or their Wi-Fi hiccups.

MV3-native, no CORS drama

All network calls route through the background service worker. You can call the SDK from popup, options, sidepanel, or content script — same API, no CORS errors.

2
popup.tsWorks
options.tsxWorks
sidepanel.tsxWorks
content.tsWorks
background.tsWorks
idle
loading
active
past_due
cancelled
active"CANCEL"cancelled
// cannot jump to any other state
3

XState under the hood

Subscription state is a finite state machine. Invalid transitions are impossible. No more "user is active but also cancelled" ghost bugs at 2am.

Typed, never throws

Every public method returns a Result. No unchecked exceptions, full inference in your editor, and every error code in the union so switch exhaustiveness catches mistakes.

4
// types.ts
typeResult<T> =
| { ok: true; data: T }
| { ok: false; error: CrxPayError }
const r = await pay.purchase(id);
if (!r.ok) handle(r.error.code);

Why devs install crxpay

Small SDK, big leverage.

0 kB
Gzipped bundle
under half of the closest rival
0
Lines to install
import, init, hasEntitlement
0 throws
From the SDK
all errors typed as Result
0%
TypeScript coverage
types shipped in the package

Ready to grow?

Our entire suite of features comes standard — and your first $2,500 in tracked revenue is free.