Skip to main content
The CarHub Player SDK renders an interactive 360° vehicle player directly in your page. It accepts the same report data as the legacy Carviz player, but gives you typed events, imperative controls, custom theming and framework bindings. It does not use an iframe.

Install

Install the framework-independent package:
The SDK supports modern evergreen browsers. It uses Shadow DOM, ResizeObserver, pointer events and AbortController.

Create a player

Give the player a container. It fills the container width and derives its height from the displayed media.
apiKey is visible to everyone who loads your page. Use only a publishable, read-only key scoped to report reads. Never place a secret API key in browser code.

Load report data

Choose one data-loading route. report takes precedence over token, and fetchReport takes precedence over the built-in request.
You can also supply jwt for reports that require a JWT. The built-in loader sends it as X-JWT and retries anonymously if the request returns 401.

Configure the player

Pass configuration when you create the player. These defaults match the Player 360 embed contract. The available TabId values are 360, exterior, interior, interior360, others and damages.

Use iframe-compatible query parameters

Query parameters are off by default. Enable them when you want the SDK to follow the iframe embed contract. Query values then take precedence over supplied options, which take precedence over defaults.
For example, ?tabview=360&hotspot=false&excludeTab=interior,damages overrides the corresponding options.

Control the player

The instance exposes methods for navigation and playback.
showSlide() uses one global slide list, ordered exterior, interior, interior 360°, others and damages. The player automatically switches to the matching view. Read the active state with player.currentView, player.tabs, player.frame and player.currentReport.

Subscribe to events

Attach listeners immediately after creating the player. Initial events are emitted in a microtask, so the listener receives ready.
on, off and once are chainable. framechange can fire about 30 times a second during autoplay, so sample it before rendering UI from it. To replace sharing entirely, prevent the default behaviour:

Use a framework binding

The core player has bindings for React, Vue and Angular. They all expose the same options and events as @carhub/player.
You can also use the custom element without a framework:
Its attributes mirror player options in kebab case. A bare boolean attribute is true; set attribute="false" to disable it.

Theme and translate labels

Set CSS custom properties on the host element. They cross the Shadow DOM boundary.
Set data-theme="light" or data-theme="dark" on the host element to fix the theme. Without it, the player follows the user’s colour-scheme preference. The player humanises damage and vehicle-part keys by default. Install the optional i18n export for the complete five-language dictionary:

Add interior panoramas

RICOH THETA equirectangular images use Photo Sphere Viewer. Install its optional peer dependencies to render them as interactive panoramas:
Without these packages, a panorama falls back to a flat image.

Migrate from the iframe

Replace the iframe with a container and SDK instance. Configuration names and defaults are compatible. Enable readQueryParams if you want existing URL query parameters to continue controlling the player.