Crossdeck University
Watch — one check that unlocks the right features Film in production
0:00 / 0:00
Lesson 5 of 6 · Get started

Gate your features

Ask whether a customer has the access, and unlock exactly the right features. Two moves: warm the answer once, then check it instantly anywhere in your app.

2 min Web · Swift

When you're done: paid customers see the feature; everyone else doesn't.

1 What this is & why it matters

Your app asks one question: does this customer have it?

You named the access (pro) and pointed a product at it. Now the last piece: your app asks the question — "does this customer have pro?" — and shows or hides the feature accordingly. You never look at subscriptions, rails, or payment dates. You ask for the name, and Crossdeck answers true or false.

It's two moves: warm the answer once (a quick fetch), then check it instantly, as many times as you like, anywhere in your code.

2 How to implement it

Warm once, then check

Call getEntitlements() once — after you identify the user, or as the app loads. Then check isEntitled() wherever a feature should be gated.

// once — after identify(), or on app load
await Crossdeck.getEntitlements();

// then, anywhere, instantly:
if (Crossdeck.isEntitled("pro")) {
  showProFeatures();
}

In React, skip the boilerplate — the hook re-renders your component the moment access changes:

import { useEntitlement } from "@cross-deck/web/react";

function ProPanel() {
  const isPro = useEntitlement("pro");   // re-renders when access changes
  return isPro ? <ProUI /> : <UpgradePrompt />;
}
3 How the code works, piece by piece

Warm fetches; check reads the cache instantly

getEntitlements() asks the server for this customer's access and caches it on the device. isEntitled() reads that cache and answers immediately — it's a plain true/false, so never await it. Re-warm after a fresh login so a new person gets their own access, not the last user's.

Where you put the gate matters. A simple rule of thumb from the docs: if someone slipping past would cost you money or expose customer data, check it on your server too (your backend asks Crossdeck the same question). If it would just embarrass the UI — a button that shouldn't be there — the client check is plenty. Most apps do both: the client gate for a clean experience, the server gate as the real lock.

4 The green result in your dashboard

Paid unlocks, free stays locked

Sign in as a paying account and the feature appears; sign in as a free one and it doesn't. That single check is the whole gate. In the last lesson, you'll prove it both ways in under a minute.

your app · gated feature
pro · unlocked

The paid account sees the Pro feature; the free account gets the upgrade prompt — from one isEntitled("pro").

You warmed the cache with getEntitlements() and gated features with isEntitled("pro") — instant, on every platform, plus the React hook. Check it on the server too for anything that costs money or exposes data.