Configuration
The full config object passed to init — placement, avatar style, features, callbacks, and persistence
The second argument to init is a NapsterCompanionApiConfig object. Every field is optional — the SDK applies sensible defaults. This page is the full reference, grouped by concern.
Placement & layout
position, layout, mountContainer
Appearance
avatarStyle, style, className
Features
The features object
Callbacks
Lifecycle and event callbacks
Persistence
Cross-page session options — own page
Debug
Verbose SDK logging
All options
Every top-level field on NapsterCompanionApiConfig. All are optional; jump to a section for the details.
| Option | Type | Default | Description |
|---|---|---|---|
mountContainer | HTMLElement | string | null | document.body | Where to mount the SDK. See Placement and layout. |
position | Position | "bottom-right" | Corner the floating widget anchors to. See Placement and layout. |
layout | "fixed" | "inline" | "fixed" | Float as a corner widget, or fill mountContainer. See Placement and layout. |
avatarStyle | avatarStyleConfig | { view: "round" } | Avatar shape and border. See Appearance. |
style | StyleObject | — | Inline styles on the SDK root container. See Appearance. |
className | string | — | CSS class(es) on the SDK root container. See Appearance. |
features | FeatureConfig | — | Toggle and tune built-in features. See Features. |
persistence | PersistenceOptions | — | Keep one session alive across page navigation. See Persistence. |
debug | boolean | false | Verbose SDK logging to the console. See Debug. |
| Callbacks | functions | — | onReady, onError, onData, onAvatarReady, onInactivityStatusChange, onDestroy, onFeaturesUpdate, onScreenShareStateChange. See Callbacks. |
Placement and layout
| Option | Type | Default | Description |
|---|---|---|---|
mountContainer | HTMLElement | string | null | document.body | Where to mount the SDK. A CSS selector or an element. |
position | Position | "bottom-right" | Where the floating widget anchors to the viewport. Ignored when layout is "inline". |
layout | "fixed" | "inline" | "fixed" | "fixed" floats the avatar as a corner widget; "inline" renders it inside mountContainer and fills it. |
Position values
position accepts any value from the Position enum:
"bottom-right"(default)"bottom-center""bottom-left""top-right""top-center""top-left""center"
await NapsterCompanionApiSdk.init(token, {
mountContainer: "#my-container",
position: "bottom-right",
});Inline layout
By default the avatar is a floating corner widget (layout: "fixed"). Set layout: "inline" to render the avatar inside your own container and fill it — you control placement, size, and shape by styling that container. position is ignored in inline mode.
// <div id="avatar-box" style="width: 320px; height: 480px"></div>
await NapsterCompanionApiSdk.init(token, {
mountContainer: "#avatar-box",
layout: "inline",
avatarStyle: { view: "rectangle" },
});Sizing rules in inline mode:
- The avatar fills your container's width and height.
- If your container has no explicit height, an internal 4:5 ratio is used (matching the floating widget's proportions) so the avatar is never invisible.
view: "round"always renders a circle that fits the smaller side and centers, regardless of the container's aspect ratio.- Video is cropped to cover — never stretched or distorted.
Appearance
| Option | Type | Default | Description |
|---|---|---|---|
avatarStyle | avatarStyleConfig | { view: "round" } | Avatar shape and border. |
style | StyleObject | — | Inline styles applied to the SDK root container. A partial CSSStyleDeclaration. |
className | string | — | CSS class name(s) added to the SDK root container. Useful for theming. |
avatarStyle
| Field | Type | Default | Description |
|---|---|---|---|
view | "round" | "rectangle" | "silhouette" | "round" | Avatar shape. Use "rectangle" for custom styling that needs a rectangular container; use "silhouette" to chroma-key a green-screen stream (see green screen). |
borderWidth | string | — | Border width, as a CSS value. |
borderColor | string | — | Border color, as a CSS color string. |
borderStyle | string | — | Border style, e.g. "solid", "dashed". |
Custom position with styles
You can override placement with style and className on the root container:
await NapsterCompanionApiSdk.init(token, {
mountContainer: "#my-container",
position: "bottom-right",
style: {
top: "20px",
left: "20px",
zIndex: "1000",
},
className: "my-custom-class",
});Features
The features object toggles built-in behaviors. Each feature is a small object with its own enabled flag plus optional tuning values.
Every feature — what it does, its defaults, and its per-feature options — is documented on the Features page.
Callbacks
All callbacks are optional. They are covered in full on the Events page.
| Callback | Signature | Fires when |
|---|---|---|
onReady | () => void | The SDK has finished initialization and is ready to render. |
onError | (error: Error) => void | A runtime or network error occurs. |
onData | (data: EventMessage) => void | Data arrives over the SDK's connection. |
onAvatarReady | (isReady?: boolean) => void | The visual avatar is fully prepared and rendering. |
onInactivityStatusChange | (isInactive: boolean) => void | The inactivity status changes. |
onDestroy | () => void | The SDK is destroyed. |
onFeaturesUpdate | (features: FeatureConfig) => void | Feature configuration changes at runtime. |
onScreenShareStateChange | (isSharing: boolean) => void | Screen sharing starts or stops. |
Persistence
The persistence object keeps one session alive across page navigation on a multi-page site:
NapsterCompanionApiSdk.init(token, {
persistence: { enabled: true },
});It has its own page — the behavior (iframe wrap, break-out rules, deferred wrap, programmatic navigation) and the full option table are covered in Persistence.
Debug
| Option | Type | Default | Description |
|---|---|---|---|
debug | boolean | false | Enable verbose SDK logging to the console. Warnings and errors always print; the detailed channel logs appear only with debug: true. See Troubleshooting → Debug mode. |