SDKsWeb SDK

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.

All options

Every top-level field on NapsterCompanionApiConfig. All are optional; jump to a section for the details.

OptionTypeDefaultDescription
mountContainerHTMLElement | string | nulldocument.bodyWhere to mount the SDK. See Placement and layout.
positionPosition"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.
avatarStyleavatarStyleConfig{ view: "round" }Avatar shape and border. See Appearance.
styleStyleObjectInline styles on the SDK root container. See Appearance.
classNamestringCSS class(es) on the SDK root container. See Appearance.
featuresFeatureConfigToggle and tune built-in features. See Features.
persistencePersistenceOptionsKeep one session alive across page navigation. See Persistence.
debugbooleanfalseVerbose SDK logging to the console. See Debug.
CallbacksfunctionsonReady, onError, onData, onAvatarReady, onInactivityStatusChange, onDestroy, onFeaturesUpdate, onScreenShareStateChange. See Callbacks.

Placement and layout

OptionTypeDefaultDescription
mountContainerHTMLElement | string | nulldocument.bodyWhere to mount the SDK. A CSS selector or an element.
positionPosition"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

OptionTypeDefaultDescription
avatarStyleavatarStyleConfig{ view: "round" }Avatar shape and border.
styleStyleObjectInline styles applied to the SDK root container. A partial CSSStyleDeclaration.
classNamestringCSS class name(s) added to the SDK root container. Useful for theming.

avatarStyle

FieldTypeDefaultDescription
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).
borderWidthstringBorder width, as a CSS value.
borderColorstringBorder color, as a CSS color string.
borderStylestringBorder 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.

CallbackSignatureFires when
onReady() => voidThe SDK has finished initialization and is ready to render.
onError(error: Error) => voidA runtime or network error occurs.
onData(data: EventMessage) => voidData arrives over the SDK's connection.
onAvatarReady(isReady?: boolean) => voidThe visual avatar is fully prepared and rendering.
onInactivityStatusChange(isInactive: boolean) => voidThe inactivity status changes.
onDestroy() => voidThe SDK is destroyed.
onFeaturesUpdate(features: FeatureConfig) => voidFeature configuration changes at runtime.
onScreenShareStateChange(isSharing: boolean) => voidScreen 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

OptionTypeDefaultDescription
debugbooleanfalseEnable verbose SDK logging to the console. Warnings and errors always print; the detailed channel logs appear only with debug: true. See Troubleshooting → Debug mode.

Next steps

On this page