Browse SDK examples

Gate a feature

Register a server-backed access check and a fallback offer. The JavaScript and React gates open the offer only when access is missing, then give you a chance to refresh the customer's access after checkout. An HTML-only page can show the upgrade checkout, but cannot run the access check for a protected feature by itself.

Have your server render an upgrade button when access is missing. Your server must still check entitlement before serving the protected export, including after checkout.

upgrade.html
<script defer src="https://your-org.plandalf.dev/js/plandalf-sdk.js"></script>
<button data-plandalf-present="upgrade">Unlock export</button>

This is a checkout trigger, not a declarative gate(). Use the JavaScript or React tab when the page needs to check access and refresh it after checkout.

For the JavaScript and React gates, if the customer dismisses the offer, access is false. A failed check or sync returns status: 'error' and access: false. A denied gate has already handled its fallback offer; do not call present() again. The protected server endpoint must make its own access decision.

See GateResult, GateCheck, GateSyncCallback, and useGate() for exact types.

Feature detail