Start
Getting started
Connect your app to stubkit in five minutes. This guide assumes you already have a stubkit account and at least one registered tenant (sign in at dash.stubkit.com and run the onboarding wizard if you do not).
1. Install the SDK
pnpm add @stubkit/sdk
# or
npm install @stubkit/sdk2. Create a client
In a mobile or browser app, authenticate as the end user with your existing auth system. stubkit reads the JWT via the getAuthToken callback on every call.
import { StubkitClient } from '@stubkit/sdk';
export const stubkit = new StubkitClient({
appId: 'your-app',
baseUrl: 'https://api.stubkit.com',
getAuthToken: async () => {
// Return your user's access token from your auth provider
return await getAccessToken();
},
});3. Read an entitlement
const isPro = await stubkit.isActive(userId, 'pro');
if (isPro) {
// unlock premium features
}4. Sync a purchase
After your in-app purchase listener fires, hand the receipt to stubkit:
const entitlements = await stubkit.syncPurchase({
userId: currentUserId,
platform: 'ios',
productId: 'com.example.pro.monthly',
receipt: appleReceiptBase64,
transactionId: appleTransactionId,
});5. Server-side reads
Backend services use the server client with a scoped API key instead of a user JWT:
import { StubkitServerClient } from '@stubkit/sdk/server';
const stubkit = new StubkitServerClient({
apiKey: process.env.STUBKIT_API_KEY!,
appId: 'your-app',
});
const isPro = await stubkit.isActive(userId, 'pro');What's next
- Configure provider webhooks: Apple, Google, Stripe
- Read how stubkit models entitlements
- Understand the state machine