BuildBaseBuildBase

API Reference

Full SDK reference — all hooks, components, types, and server methods.

The complete API reference with every parameter, return type, and code example lives in the SDK README on npm. This page summarizes what's available and when to use each part.

React SDK (@buildbase/sdk/react)

Hooks

HookWhen to use
useSaaSAuth()Sign in/out, get current user, check auth status, open settings
useSessions()List and revoke the signed-in user's active sessions
useDevices()List, rename, sign out, or forget the user's devices
useConnectedAgents()List and disconnect AI agents connected to the user's account
useMcpConnection()Read the MCP connection config for building a custom connect guide
useSaaSWorkspaces()List, create, switch, update, delete workspaces
useSubscription()Get current plan, status, billing interval
useTrialStatus()Check trial state — isTrialing, daysRemaining, isTrialEnding
useSeatStatus()Check seat limits — memberCount, canInvite, inviteBlockReason
useCreditBalance()Get credit balance — available, totalConsumed, totalGranted
useConsumeCredits()Deduct credits with idempotency
usePurchaseCredits()Open Stripe checkout for credit packages
useExpiringCredits()Get credits expiring within N days
useQuotaUsageStatus()Get one quota's usage — consumed, included, available
useAllQuotaUsage()Get all quotas at once
useRecordUsage()Record usage against a quota
usePermissions()Check permissions — can(), isOwner, role
useTranslation()i18n — t(), locale, dir, fmtCents(), fmtNum()
usePushNotifications()Subscribe/unsubscribe to browser push
useUserAttributes()Get/update custom user attributes
useUserFeatures()Check user-level feature flags
usePublicPlans()Fetch plans without authentication (for public pricing pages)
useCreateCheckoutSession()Create a Stripe Checkout session
useInvoices()Paginated invoice history
useBillingPortal()Get Stripe billing portal URL

40+ hooks total. See the full hook reference for parameters and return types.

Conditional components

Wrap UI in these — the SDK shows or hides children based on state. No if-statements needed.

ComponentShows children when...
WhenAuthenticated / WhenUnauthenticatedUser is / isn't signed in
WhenRoles / WhenWorkspaceRolesUser has specific role(s)
WhenPermissionUser has specific permission(s)
WhenSubscription / WhenNoSubscriptionWorkspace has / lacks a subscription
WhenSubscriptionToPlansSubscribed to specific plan slug(s)
WhenTrialing / WhenNotTrialing / WhenTrialEndingTrial state matches
WhenQuotaAvailable / WhenQuotaExhausted / WhenQuotaOverage / WhenQuotaThresholdQuota usage matches condition
WhenCreditsAvailable / WhenCreditsExhausted / WhenCreditsLowCredit balance matches condition
WhenWorkspaceFeatureEnabled / WhenWorkspaceFeatureDisabledWorkspace feature flag state
WhenUserFeatureEnabled / WhenUserFeatureDisabledUser feature flag state

20+ components total.

Pre-built pages and screens

ComponentWhat it renders
PricingPageFull pricing page with plan cards, interval toggle, Stripe checkout
CreditStorePageCredit package store with pricing and purchase
WorkspaceSwitcherDropdown with search, create, and switch
BetaFormBeta signup/waitlist form
Workspace settings dialog13 screens: profile, security, devices, connected-agents, general, users, subscription, usage, credits, features, notifications, permissions, danger

The settings dialog is not a standalone component — open it with openWorkspaceSettings(section), returned by useSaaSAuth(). Pass a SettingsScreen value (e.g. SettingsScreen.Devices) to open a specific screen.

Server SDK (@buildbase/sdk)

See Server SDK for method signatures and examples. Key namespaces:

NamespaceWhat it does
bb.subscriptionGet, checkout, update, cancel, resume subscriptions
bb.creditsBalance, consume, purchase, packages, transactions
bb.usageRecord usage, batch recording, quota status
bb.workspaceCRUD workspaces
bb.usersList, invite, remove, update roles, profile
bb.notificationSend email + push notifications
bb.plansGet plan groups and versions
bb.invoicesList and get invoices
bb.featuresList and toggle feature flags
bb.permissionsCheck and resolve permissions for any user — both methods take an explicit userId

Data exports (@buildbase/sdk/data)

Reference data with no React dependency:

  • countries — country list with codes and flags
  • currencies — currency codes, symbols, and names
  • languages — language codes and names
  • timezones — IANA timezone list

MCP toolkit (@buildbase/sdk/mcp)

Server-side, framework-agnostic toolkit that turns your app into an MCP (Model Context Protocol) server, so AI agents can operate its BuildBase capabilities. Key exports: createMcpHandler() (stateless Streamable HTTP handler), defineMcpTool() / defineMcpResource() / defineMcpPrompt() (custom capabilities), builtinMcpTools and selectBuiltinTools() (ready-made BuildBase tools), buildbaseAuth() (Bearer-token verification for agent requests), and createAgentStack() (MCP server plus agent-discovery routes from one config).

Utilities (re-exported from core)

CategoryKey exports
Billing mathcalculateTotalSubscriptionCents(), getBasePriceCents(), getPerSeatPriceCents(), getSeatPricing()
CurrencyformatCents(), getCurrencySymbol(), getCurrencyFlag(), getPricingVariant()
PermissionsPermission.* constants, hasPermission(), resolvePermissions()
WebhooksparseWebhookEvent(), verifyWebhookSignature()
Auth intentsaveAuthIntent(), consumeAuthIntent() — preserve redirect across auth flow
EventseventEmitter — SDK event bus for cross-component communication
ValidationvalidateInvite() — check seat limits before inviting

Full reference

For complete parameters, return types, TypeScript interfaces, and code examples for every export, see the SDK README on npm.