Skip to main content
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.
Whop Elements are themeable UI components you can import in your iOS app. They ship as a single Swift SPM package. Each one is a plain SwiftUI view that fetches its own data and manages its own state, so a balance screen is a couple of views in a VStack instead of a networking layer and a view model. Add the package, tell the SDK how to fetch an access token, and put the elements in your view hierarchy.

Install

Add the package to your Package.swift (or File → Add Package Dependencies in Xcode):

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:

Requirements

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 balance.
  2. A server endpoint that creates an access token for the account. Never ship a Whop API key in the app. It creates tokens, so anyone who extracts it can read the account. Create the token on your server and return only that.
A user_… tag reads the viewer’s own data, so it uses viewer OAuth (WhopSDK.configureWithOAuth) instead of a token. The chat views too.Your server calls Create Access Token with the account and the scope the elements need:

Mount your first element

A complete app. configure runs once at launch, and the elements render a spinner until it lands, so nothing races it:
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

Authentication

getToken() is your only integration point, and the SDK calls it again before the token expires, so return a fresh token each time rather than caching one:
Configure once, anywhere above the elements. WhopSDK is process-wide, so a second call is only needed when the account changes:
Chat and DMs authenticate the viewer instead of an account, through OAuth: WhopSDK.configureWithOAuth(appId:).

Theming

.whopTheme(_:) propagates through the SwiftUI environment, so one call themes every element beneath it. Six roles, each a WhopTint:
Defaults are accent: .blue, neutral: .gray, danger: .red, info: .sky, success: .green, warning: .amber. WhopTheme.default is all six. Views follow the system light/dark appearance on their own.

What the elements handle, and what you own

Each view fetches its own data and renders its own loading, empty and error states, including a retry. You own navigation: the selection callbacks hand you a value and never push a screen.

Troubleshooting

Available on iOS

The wallet views, each with a live simulator on its page:WhopChatView and WhopDMsListView ship in the same package for viewer-authenticated chat. See the README.