Feature gate
Content shown only when the active organization's plan includes a feature, read from the session's features claim and updated when the session refreshes. Web and native call useFeatureGate from @/hooks/use-entitlements.

Add the components
terminal npx shadcn add button skeletonInstall the glue
Install the block with
npx better-supabase add entitlements. The glue items are copied into your app, so edit them as you need.terminal npx shadcn add @better-supabase/use-entitlementsWrite the component
React and shadcn
View in the examplefeature-gate.tsx "use client"; import type { ReactNode } from "react"; import { LockIcon } from "lucide-react"; import { useExtracted } from "next-intl"; import type { Entitlement } from "@/lib/claims"; import { buttonVariants } from "@/components/ui/button"; import { Skeleton } from "@/components/ui/skeleton"; import { useFeatureGate } from "@/hooks/use-entitlements"; import { Link } from "@/i18n/navigation"; /** * Renders `children` only when the active organization's plan includes * `feature`, read from the session's `features` claim; otherwise a link to the * plans. UX only: RLS and the route behind it check the feature too. */ export function FeatureGate({ feature, children, }: { feature: Entitlement; children: ReactNode; }) { const t = useExtracted("billing"); const { allowed } = useFeatureGate(feature); if (allowed === undefined) { return <Skeleton className="h-8 w-28" aria-busy="true" />; } if (allowed) { return children; } return ( <Link href="/settings/billing" className={buttonVariants({ variant: "outline", size: "sm" })} data-testid={`upgrade-${feature}`} > <LockIcon /> {t("Upgrade to unlock")} </Link> ); }