CrovverProvider initializes the SDK, fetches the tenant’s subscription status, and makes it available to all child components via context.
Props
config
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
publicKey | string | ✅ | — | Your public API key (pk_live_...) |
tenantId | string | ✅ | — | The current user/workspace ID from your app |
userId | string | — | The logged-in user’s ID. Used to deduplicate tenant owner records across checkout sessions. Recommended. | |
apiUrl | string | SDK default | Override the Crovver API base URL | |
portalUrl | string | SDK default | Override the billing portal URL | |
pollInterval | number | 0 | Auto-refresh interval in ms. 0 = disabled | |
debug | boolean | false | Log SDK activity to the console | |
onUnauthenticated | () => void | — | Called when subscription is inactive | |
metadata.userEmail | string | — | User’s email, passed to checkout/portal token requests | |
metadata.userName | string | — | User’s display name, passed to checkout/portal token requests |
Example
Dynamic tenantId
If your user can switch between workspaces, you can change tenantId dynamically. The provider will re-fetch the subscription for the new tenant when the value changes:
Server Components (Next.js)
CrovverProvider is a client component. If your root layout is a server component, wrap the provider in a "use client" file: