@superwall/studio
v2.7.2
Published
The Superwall studio: paywall browsing, device preview, and editing surfaces. Shared between `superwall dev` (local studio) and the hosted dashboard.
Readme
Install
npm install @superwall/studioYou will not usually install this directly: the
superwall framework depends on
it and superwall dev serves it. It is a standalone vite + React + Tailwind
app that is also a component library — one codebase, two hosts:
superwall devserves the BUILT app (dist/, assets under/__studio/) plus the data endpoint and preview mounts — the local studio.- The hosted studio in the dashboard imports the component library
(
dist/lib/, the package's.export, plus the compiled@superwall/studio/studio.css) and rendersSurfaceEditorover published snapshots and platform data. See Hosting.
Package layout
packages/studio/
├── index.html the app shell (fonts, favicon)
├── vite.config.ts vite + react + tailwind; /__studio/ base for builds
├── vite.lib.config.ts the library build: dist/lib/index.js + studio.css
├── tsconfig.lib.json declarations for the library build
├── src/
│ ├── main.tsx entry: fetch /__studio/project.json → <StudioApp/>
│ ├── index.ts the component-library barrel a hosted studio imports
│ ├── StudioApp.tsx URL-driven router (list ⇄ editor)
│ ├── screens/ SurfaceList, SurfaceEditor
│ ├── components/ StudioShell, TopBar, Toolbar, DeviceFrame, VariablesPanel,
│ │ ActionMenu, CompareMenu, SidePanel, controls, icons, …
│ ├── lib/ project.ts (wire-format parser, untrusted JSON,
│ │ cast-free), preview.ts (preview URL builder),
│ │ devices.ts (viewport + mock-device catalog),
│ │ actions.ts (the dev server's shipping seam),
│ │ promotion.ts (promote vs roll back), steps.ts,
│ │ events.ts, time.ts, types.ts
│ └── styles.css tailwind @theme tokens + stateful primitives
└── dist/ built by the workspace postinstall: the app, and
the library under dist/lib/Data seam
Everything renders from a StudioSource — { title, surfaces, diagnostics?,
samples?, previewUrl, actions? }. Locally that's
/__studio/project.json (the dev server evaluates configs server-side and
ships sample device/user/params/product data alongside) plus
devServerActions, the /__studio/action, /__studio/status and
/__studio/samples/<project>/<kind>/<id>?platform= implementation of the
shipping seam. SurfaceEditor asks actions.samples(surface, platform) for
the open surface and the selected device's platform (ios, android, none
for Responsive and Desktop) and asks again when the device changes, so the
catalogue comes from the app that surface ships to on that platform. Until
the answer arrives the samples stay empty and pending, never another app's.
A host without samples passes them in StudioSource.samples instead. A hosted studio swaps the fetch and the
seam, nothing else. previewUrl(surface) decides what the preview
iframes load: /preview/<kind>/<id> mounts locally, published snapshot URLs
in the dashboard. Both carry ?transport=editor, which makes the paywall
talk to its parent window, and the studio is that parent.
The studio is a paywall host in the SDK's sense, through @superwall/host.
Each DeviceFrame answers its paywall's ping with the same burst the web
host sends (template_variables, experiment, products,
template_substitutions_prefix, paywall_open), built from the host state
SurfaceEditor assembles: the API's device and user samples (or the host
package's defaults), the selected device frame's platform/deviceModel/
osVersion, the theme as interfaceStyle, the chosen locale as
deviceLocale, one product per slot with the catalogue's variables (or the
visual editor's example prices for a slot the catalogue cannot price), and
whatever the Variables panel edits on top. Every edit re-sends only what
changed; nothing reloads. Purchases, restores, permissions and callbacks come
back as prompts in the toasts and are answered with the messages the iOS SDK
sends. Nothing about this is specific to the studio: the paywall cannot tell
it from a device.
Hosting
The dashboard opens a code-first paywall in this studio instead of the visual editor. What the library gives a host:
snapshotPreviewUrl(urlOf)— apreviewUrlthat resolves each surface to its published snapshot URL and addstransport=editor. SetpaywallId,paywallIdentifier,productsandlocaleson eachStudioSurfacefrom the paywall and version records; the studio hosts the snapshot from them.hostStateForandhostPatchare exported for a host that wants to drive aDeviceFrameitself.- One
StudioSurfaceper version, told apart bylabel("v12 · Live") and carrying itsversion;StudioSource.compareHintnames what the compare menu offers, andSurfaceEditor'sactionsslot takes the host's own controls (a version switcher, say). StudioSource.actionsis the shipping seam:offerednames the actions the host can run (push,promote,publish),run(surface, { action, version? }, onStep)performs one and streams its steps,status(surface)lists the pushed versions with the live one marked. With none, there is no push/promote UI. The pushed versions sit in a picker at the start of the action button group, and the studio labels the button Promote or Roll back by where the picked version sits against the live one (promotionDirection). A host that can only promote (the dashboard, which has no project on disk) offers["promote"]and apickthat switches the surface, so the menu collapses to the picker and one button; the local studio keeps its own pick and sends aversiononly when one was chosen.Canvasis the zoomable stage the studio previews on, withuseCanvasScalefor what it draws and aCanvasHandleref (fit,actualSize,zoomStep,zoomTo,zoom(),pan,hold).insetsets the fit margin (48px by default).containedis for a stage inside a page that scrolls, such as a chat: a plain wheel scrolls the page, a pinch or ctrl-wheel zooms, a finger scrolls the page until the stage is zoomed in, and the zoom keys and Space reach it only while it is hovered or focused. Resizing the stage refits it, or re-centres it at the zoom it was left at.percentformats a scale for a zoom readout.chromeFor,deviceVariablesFor,isWebOnlyandwebViewportForare the device rules the studio draws with: the frame chrome for a device (none on web), thedevicevariables a paywall reads, whether a paywall targets only web, and the viewport a browser leaves on a device.StudioShell(position="absolute"when the host owns the viewport) is the ink stage every screen expects, and it carries thesw-studioclass the stylesheet scopes its base rules to.@superwall/studio/studio.cssis compiled Tailwind v4 output including a preflight. Mount it in a shadow root (or an iframe) rather than beside another design system — the dashboard does exactly that, and re-registers the sheet's@propertyrules at document level, where browsers expect them.@superwall/studio/productsis the pure mapping from a dashboard product (the v2 API shape) to the variables a paywall reads (price,periodly,trialPeriodDays,trialPeriodPrice, …), with amounts in the currency's own minor units.superwall devuses it; the dashboard builds its samples with its own pricing engine, so the two must be kept in step by hand.@superwall/studio/contractis a types-only entry: the action, status, per-surface samples and app-scheme shapes the CLI implements for the framework's preview server, importable from node without DOM types.@superwall/studio/styles.cssis the Tailwind source for hosts that run their own v4 pipeline.
Screens
- SurfaceList — every paywall and funnel as a card with a live, non-interactive miniature (a real preview at 393×852, scaled).
- SurfaceEditor — the paywall alone on an ink stage in one plain device
frame, with a single bottom toolbar: device switching (
STUDIO_DEVICES: nine devices, iPhone SE to iPad Pro to Pixel to Desktop — each switch also flips the mock SDK's platform/model/OS), light/dark simulation, locale switching, and a Variables button that slides in a right-hand panel of controls for the User, Device, Params and Products groups the SDK reports. Override changes hot-swap: the next frame loads hidden and crossfades, so nothing ever flashes white. Shipping happens here too: an action menu runs Push, Publish and Promote beside a picker of the pushed versions, reading Roll back when the picked one is older than what is live, and a Compare menu splits the stage against any pushed version of the paywall (the live one marked) or another local one.
Design
The Application register of the Superwall design system (superwall.com/design.md): ink-dark chrome always (the preview carries light/dark, not the studio), hairline seams, mono chips, Manrope 500/400/600 with Roboto Mono micro-labels, teal accent, and paper-flat square geometry — switches are the only carved-out rounded shape, device frames are plain rectangles.
Tailwind v4 (src/styles.css): design tokens as @theme variables (so
bg-ink, text-cream/55, border-cream/10 are utilities), layout inline in
components, and only stateful primitives (.sw-btn, .sw-chip,
.sw-select, .sw-segmented, .sw-switch, .sw-input) as component
classes. Runtime dependencies are React (a peer) and sonner for toasts —
icons are inlined Lucide-geometry SVGs.
Develop
This package lives in the superwall/superwall
monorepo. Read AGENTS.md
first - the conventions in it are decided, not suggested.
bun install
bun dev # the studio alone on port 6200, proxied to a running
# `superwall dev` (port 6100) in any project — HMR against
# real paywalls
bun run build # dist/ (what `superwall dev` serves) and dist/lib/ (the library)
bun run test
bun run typecheckThe workspace postinstall builds dist/, so a fresh clone of the monorepo
has a studio to serve from the first superwall dev.
License
Functional Source License (FSL-1.1-ALv2): use it, modify it, embed it, ship it — anything except building a competing product with it — and every release becomes Apache 2.0 two years after publication.
