License your React apps.
One provider. One assertion. Done.
Written in TypeScript, with full type definitions. Install from npm, wrap your app in a provider, gate features with one assertion.
npm install @sidub-inc/licensing-clientWhy licensing React apps is hard
A React app needs to check entitlements without a round trip on every render, and ride out a short outage. That takes a real SDK.
Monaiq's SDK ships a React provider and checks signatures in the browser: a provider at the top, plain calls wherever a component needs an answer.
Built for the React ecosystem
A real client behind a React provider.
One Shared Client
useLicensingContext hands any component the shared client: getAuthorization, assertLicense, performOperation.
Context Provider
LicensingProvider wraps your app once. Every component below gets the client.
Full Type Safety
Full type definitions, so your editor knows what is valid.
Cryptographic Verification
Signatures are checked in the browser with the Web Crypto API.
Rides Out Outages
Assertions run locally against the cached authorization. A short outage is covered by a grace window.
Framework Agnostic
React 16.8 or later. The same npm package runs in Node, with PurchaseClient for in-app purchase.
From npm to a feature gate
Wrap your app in a provider. Gate a feature with an assertion.
import { LicensingProvider } from '@sidub-inc/licensing-client';
// 1. Wrap your app with the provider
<LicensingProvider config={{
licenseServiceUri: 'https://api.monaiq.com/licensing',
issuerClientId: '<your account client id>',
productId: '<your product id>',
encodedCredential: 'SIDUB_LIC_...'
}}>
<App />
</LicensingProvider>import { useEffect, useState } from 'react';
import {
useLicensingContext,
ServiceAccessAssertion,
ServiceAccessLevel
} from '@sidub-inc/licensing-client';
// 2. Check authorization in any component
function PremiumFeature() {
const client = useLicensingContext();
const [hasAccess, setHasAccess] = useState(false);
useEffect(() => {
client.getAuthorization().then((authorization) =>
setHasAccess(client.assertLicense(
ServiceAccessAssertion.create('premium-feature', ServiceAccessLevel.Allowed),
authorization)));
}, [client]);
return hasAccess ? <PremiumDashboard /> : <UpgradePrompt />;
}Works with your React stack
One npm package, every React setup.