Host SDK
Show a PanelWave work in any web page or app with PanelWave.mount(): one frame, typed events, reading positions, privacy mode and a purchase UI policy for app stores.
The host SDK puts a PanelWave work into any page or app, whatever framework it uses. It creates the frame, speaks the embed protocol with it and hands you typed events. It is the loader panelwave-embed.js 2.0 — MIT, no dependencies, about 5.7 KB gzipped — and ships with @panelwave/player 2.4.0.
| Where | Use |
|---|---|
https://read.panelwave.org/embed.js | Script tag for works on read.panelwave.org. Sets window.PanelWave |
player/panelwave-embed.js | The same script inside a standalone package |
import { mount } from '@panelwave/player/embed' | ES module with typings for bundlers. Nothing from Angular is loaded |
Building an Angular 21 or 22 app and want the player inside your own page, without a frame? Use the <pw-player-shell> component instead — see Quickstart: Embed. The host SDK is for every other host: plain pages, React, Vue, content management systems, mobile apps.
Mount a work
<div id="comic"></div>
<script src="https://read.panelwave.org/embed.js"></script>
<script>
const frame = PanelWave.mount(document.getElementById('comic'), {
src: 'https://read.panelwave.org/studio-x/night-city', // or a package's index.html
loading: 'click', // 'eager' (default) | 'lazy' | 'click'
poster: { image: coverUrl, title: 'Night City', label: 'Read here' },
privacy: { tracking: false }, // nothing is sent until you call setPrivacy
purchaseUi: 'in_place', // 'in_place' | 'link_out' | 'hidden'
resume: savedPosition, // { panelId, variables } from an earlier `progress`
});
frame.on('progress', (p) =>
localStorage.setItem('nc-pos', JSON.stringify({ panelId: p.panelId, variables: p.variables })));
frame.on('paywallAction', (a) => console.log('the reader wants to buy', a));
</script>
PanelWave.mount(element, options) returns a handle. Calling it again on the same element replaces the frame.
Options
| Option | Meaning |
|---|---|
src | The reader address of a work, or a package's index.html (relative addresses resolve against the page). Required |
chapter | Show one chapter (CMS chapter id or manifest chapter id). Without it, the whole work |
channel | Your channel key, if you are a PanelWave channel. read.panelwave.org counts reads for your channel only while the work is live on it |
locale | Start language, e.g. de-DE |
theme | light or dark, sent once the player is ready |
loading | eager mounts at once; lazy when the box nears the viewport; click shows a poster built only from what you passed — no request reaches PanelWave before the tap |
poster | { image, title, label } for click, and while a lazy frame loads |
privacy | { tracking: false } starts in privacy mode: no analytics leave the frame until you call setPrivacy({ tracking: true }). Absent: the work's own consent setting |
purchaseUi | What the paywall shows: in_place (prices and options), link_out (one neutral link to the work on its reader site) or hidden (Not available in this app). See Apps and stores |
resume | { panelId, variables? }: continue there once the player is ready |
autoplay, toolbar, cover, secondsPerPanel | Player options, as in the declarative form |
aspect | Box shape until the player reports its own (resize), e.g. 3/4 |
frame | { sandbox?, allow? }: iframe attributes your platform must enforce, set before the frame loads. The player needs at least allow-scripts allow-same-origin; allow defaults to autoplay; fullscreen. Malformed values are dropped |
The handle
| Member | What it does |
|---|---|
on(name, fn) | Listen to an event; returns a function that stops listening |
off(name, fn) | Stop listening |
navigate(panelId) | Jump to a panel |
setLocale(locale) | Change the language, live |
setTheme(theme) | 'light', 'dark' or a theme object (UITheme); null clears it |
setPrivacy({ tracking }) | Analytics on or off, e.g. after your consent banner |
restore({ panelId, variables }) | Continue at a position |
setOptions({ … }) | Live player options: autoplay, muted, showToolbar, purchaseUi, … |
purchaseHandled(productId?) | You took over a purchase after paywallAction |
getState() | Promise of the player's state snapshot |
frame | The iframe element, once mounted |
transport | 'port', 'window' or 'none' yet — how the SDK talks to the frame |
destroy() | Remove the frame and the poster |
Events
hello (protocol and capabilities), ready, mount, unmount, panelChange, chapterChange, chapterComplete, locationChange, variableChange, localeChange, paywallAction, ageVerified, likeChange, bookmarkChange, widgetEvent, progress, resize, fullscreenRequest and error.
Every event is also dispatched on your element as a DOM event named panelwave: plus the event name in lower case, for example panelwave:panelchange.
The SDK handles two events itself: resize sets the box's aspect ratio and minimum height, and fullscreenRequest — sent where the browser cannot go fullscreen, as in many WebViews — makes the box fill the window.
Keep the reading position
progress arrives at most every two seconds while the reader moves, and once more when the page is hidden:
{ chapterId, chapterUuid, panelId, pageId, percent, variables, completed }
percent is the share (0–100) of the chapter's reachable panels the reader has seen on this visit. A branching work has no single length, so the share follows the reader's own path; reaching the chapter's end counts as 100. Store panelId and variables and pass them back as resume (or call restore) to continue where the reader stopped — for readers without an account, this is your job.
Privacy and analytics
With privacy: { tracking: false } the frame starts in privacy mode: no event is queued and no request leaves it. The session start is held in memory only; setPrivacy({ tracking: true }) sends it, with the time of the opt-in. Events from before are not recovered. Without privacy the work's own consent setting applies.
Some channels leave analytics to the host page — roadbeat does. Frames on such a channel start in privacy mode unless you pass privacy, and analytics begin only when you call setPrivacy({ tracking: true }) after your own consent step.
Apps and stores
Inside a mobile app, use the SDK in the app's web view as above:
- Messages reach the app. The SDK hands the frame a
MessagePort, so it works for app pages whose originpostMessagecannot address (capacitor://localhost,ionic://localhost). - Purchases follow the store rules. Pass
purchaseUi: 'hidden'on iOS and'link_out'on Android: the paywall then shows Not available in this app, or Available at … with one neutral link to the work's reader page — no prices, no buttons. - Fullscreen works in WebViews. Where the web view has no Fullscreen API, the player's fullscreen button sends
fullscreenRequestand the SDK makes the frame fill the window.
Framework examples
import { Component, ElementRef, OnDestroy, afterNextRender, input, viewChild } from '@angular/core';
import { mount, type PanelWaveFrame } from '@panelwave/player/embed';
@Component({ selector: 'app-comic', template: '<div #box></div>' })
export class ComicComponent implements OnDestroy {
readonly src = input.required<string>();
private readonly box = viewChild.required<ElementRef<HTMLElement>>('box');
private frame?: PanelWaveFrame;
constructor() {
afterNextRender(() => {
this.frame = mount(this.box().nativeElement, { src: this.src(), loading: 'lazy' });
this.frame.on('progress', (p) => console.log(p));
});
}
ngOnDestroy(): void {
this.frame?.destroy();
}
}
import { useEffect, useRef } from 'react';
import { mount } from '@panelwave/player/embed';
export function Comic({ src, onProgress }: { src: string; onProgress?: (p: unknown) => void }) {
const box = useRef<HTMLDivElement>(null);
useEffect(() => {
const frame = mount(box.current!, { src, loading: 'lazy' });
const stop = onProgress ? frame.on('progress', onProgress) : undefined;
return () => {
stop?.();
frame.destroy();
};
}, [src]);
return <div ref={box} />;
}
Declarative markup
Pages that cannot run their own script keep using placeholders — the loader turns every <div class="panelwave-embed" data-src="…"> into a frame. Loader 2.0 makes data-chapter optional (without it the frame shows the whole work) and adds data-channel, data-track (0 = privacy mode), data-purchase-ui, data-theme, data-sandbox and data-allow. See Embed Chapters on Your Page.
How the SDK talks to the frame
Every frame gets a random bridge nonce in its address. After the frame loads, the SDK offers it a MessagePort with that nonce; a page that speaks protocol 4 accepts the first matching offer and from then on talks only over the port. Older pages (protocol 1–3) ignore the offer and keep the origin-checked postMessage path; frame.transport tells you which one is in use. The details are in Embed protocol → Port handshake.
Frame attributes the SDK sets: allow="autoplay; fullscreen" (or your frame.allow), allowfullscreen and referrerpolicy="strict-origin-when-cross-origin".
Content Security Policy on your page:
frame-src https://read.panelwave.org; # plus your package's origin, if you self-host
script-src https://read.panelwave.org; # only when you load embed.js from there
Creators decide who may show their reader. If a creator allows only the channels they listed, read.panelwave.org opens the work only inside pages from those channels' origins. See Work details → Your terms for channels.
Not in this version yet
Reader tokens, sign-in from the frame and the return from checkout come with PanelWave reader accounts. Until then, purchaseHandled is passed to the player but nothing follows from it.