Getting started
This guide adds licensing to an Electron app with @keygrant/electron. The same flow
works over the raw REST API — the SDK just handles device fingerprinting, lease storage, offline
grace and retries for you.
1. Install the SDK
npm install @keygrant/electron 2. Activate & verify
Create a License with your product slug, the API base URL, and the product's public
key (used to verify leases offline). Then activate the key your customer entered:
import { License } from "@keygrant/electron";
const license = new License({
product: "my-product",
apiBaseUrl: "https://api.keygrant.dev",
publicJwk: PRODUCT_PUBLIC_JWK,
});
const result = await license.activate(userEnteredKey);
if (!result.valid) showActivationWindow();
That's the whole integration. activate validates the key with KeyGrant, binds this
device, and caches a signed lease — a standard JWT you can verify offline.
3. Check status on launch
On subsequent launches, verify the cached lease offline first. It stays valid through the grace window you configured, so an outage or a flight never locks a paying customer out:
// On every launch, verify the cached lease offline first.
const state = await license.status();
if (!state.valid) showActivationWindow(); SDK reference
The full @keygrant/electron surface:
Create a client. Options: product (your product slug), apiBaseUrl (the KeyGrant API), and publicJwk (the product public key used to verify leases offline).
Activate a license key on this device. Returns the validity result and caches the signed lease. Enforces the product's device limit.
Verify the cached lease offline and report current validity — the fast path to run on startup. No network call while the lease is inside its grace window.
Begin a time-limited trial for this device, where the product allows it. Tamper-resistant so a trial cannot be trivially reset.
Release this device from the license so the seat can be reused on another machine.
Renew the lease with KeyGrant before it expires, extending the offline grace window.
Next steps
- Prefer no dependency? Verify the lease JWT with any standard library and your public key.
- Wire purchases to issue licenses automatically with Stripe, Paddle or Lemon Squeezy.
- Questions? Email [email protected].