Skip to main content
This page documents @whop/elements@1.0.0-beta.0 and @whop/elements-react@1.0.0-beta.0.
Whop Elements are hosted, themeable UI components you embed in your own site. Each element renders in an isolated frame served from Whop’s CDN. You install a thin, fully typed package and the element code stays up to date on its own.

Install

Requirements

Elements render in frames served from js.whop.cloud. If your CSP does not allow that origin, you get blank space instead of the element, and the error appears only in the browser console.

Before you start

You need two things:
  1. An accountId. An account ID, prefixed biz_, or a user ID, prefixed user_, for the user’s own data. Payment surfaces take a plan or amount instead, and each element page says which it needs.
  2. A server endpoint that creates an access token, scoped to the elements you mount.
Never put a Whop API key in browser code. It creates tokens, so anyone who opens the browser’s developer tools can read the account. Create the token on your server and send only the token.
Your server calls Create Access Token with the account and the scopes the elements need:

Mount your first element

Prefer npm over the script tag? loadWhop() injects the same hosted script and resolves the global constructor:

Authentication

Pass an accessToken when you create the handle. Use one token for the whole handle, not one per element. The handle sends that token to every element under it, so ask for all the scopes you need on that one token. Each element page lists the scopes it reads.
The token is a value you set, not a callback the SDK calls. Set a new one before it expires:
If you omit accessToken, requests use the viewer’s session cookie instead. This works only on whop.com. The API does not send Access-Control-Allow-Credentials on cross-origin preflights, so a page on your own domain has no session to fall back to and must pass a token.

Global configuration

Everything you pass at construction applies to every element group created from that instance (a handle’s own options can override per group):
Appearance
Visual customization for every element — theme (light/dark + palettes), variables (CSS custom properties), and classes (per-part style declarations). The color scheme is applied before an element’s first paint, so dark pages never flash light. See Appearance.
"en" | "es" | "zh" | "nl" | "pt" | "de" | "it" | "fr" | "ja" | "pl" | "tr"
Locale for element UI text — one of the app’s built locales; any other value falls back to the default locale. Defaults to "en".
"production" | "sandbox"
Which Whop API environment the elements talk to — "sandbox" targets the sandbox API (test data; no real money moves). Choosing an environment is the only way to change where the elements send what a buyer types, and both environments are Whop’s own. The sandbox environment is not yet generally available. Defaults to "production".
boolean
Whether elements may show toast notifications on your page — brief status messages (“Payment method added”, “Payment failed”) rendered in the bottom-right corner. Set false to turn them off entirely. Defaults to true.
In React, the same object rides <WhopElements appearance={…} locale={…}>.The toasts global is live on this page — the button below sends one through the same rail elements use, themed by this page’s appearance:

What the elements handle, and what you own

Each element fetches its own data and renders its own loading, empty, and error states.You handle navigation and storage. Elements report selections and results as events, and never write to your database.The exception is a flow that leaves the page. Where an element takes a returnUrl, it navigates the tab there, so the buyer can end up off your page. Fulfill from webhooks rather than from a browser callback.Elements run in frames, so only serializable values cross the boundary. There is no shared DOM, and object identity is not preserved.

Troubleshooting

Available elements

Payments

Collect a payment from a plan_ ID or inline currency and amount.

Checkout

Drives a full hosted checkout for one plan — price summary, promo codes, the currency the buyer pays in, and the whole payment collection surface (the payments elements, composed inside) — against the Whop checkout sessions API.

Ads

An advertising account.

Tracking

An account’s tracked audience: everyone its pixel has seen, and every event they performed.

Wallet

Drives an account’s money surfaces.

Websites

An account’s websites: every site built on whop.app plus every domain the Whop Pixel reports, with traffic and attributed revenue per domain.

Next