Docs
Player ReactAPI reference

API reference

Provider, hooks, component, error boundary, and the imperative MoviiePlayerHandle.

Everything below is exported from @moviie/player-react. The data layer (MoviieClient, playback types, typed errors, telemetry) is re-exported from @moviie/player-sdk, and the contract constants come from @moviie/player-types: this package never re-declares the contract.

<MoviieProvider>

Place at the root of the subtree that renders players. Provides the Moviie client and the viewer-token store.

PropTypeRequiredDescription
publishableKeystringPublishable key (mvi_pub_*). Secret keys are rejected by the playback API.
clientInfoPartial<MoviieClientInfo>Optional client info for analytics. platform defaults to "web".
viewerTokenStoreViewerTokenStorePersisted viewer / telemetry token store. Defaults to in-memory (SSR-safe).
childrenReactNodeYour app tree.

useMoviieContext() reads the provider value from within the tree.


useMoviiePlayback(args)

Low-level hook that fetches playback metadata for an embed. useMoviiePlayer wraps it; use this directly when you only need the data, not the component.

Arguments

FieldTypeDescription
embedIdstringRequired. UUID of the embed from the dashboard.
dubbingLanguagestring | nullRequest a specific dubbing language for the audio track.

Return value

FieldTypeDescription
dataMoviiePlaybackData | nullFull playback metadata. null while loading or on error.
isLoadingbooleantrue while the initial fetch is in flight.
errorError | nullTyped error when the fetch fails. See Error handling.
retry() => voidRe-triggers the playback fetch.

useMoviiePlayer(options)

The main hook. Fetches playback metadata and returns it ready to spread onto <MoviieVideo>. The Vidstack player instance is created by <MoviieVideo> itself and exposed through the imperative handle (see below).

Options

OptionTypeDefaultDescription
embedIdstringRequired. UUID of the embed.
autoplaybooleandashboardOverride the embed's autoplay setting (within browser policy).
pictureInPicturebooleandashboardOverride the embed's Picture-in-Picture setting.
rememberPositionbooleandashboardOverride the embed's remember-position setting.
dubbingLanguagestring | nullInitial dubbing language.

Return value

FieldTypeDescription
playbackMoviiePlaybackData | nullFull playback metadata. null while loading or on error.
isLoadingbooleantrue while the initial fetch is in flight.
errorError | nullTyped error when the fetch fails.
retry() => voidRe-triggers the playback fetch.
optionsUseMoviiePlayerOptionsThe override options you passed. Spread onto <MoviieVideo> with the rest.
const moviie = useMoviiePlayer({ embedId })
return <MoviieVideo {...moviie} aspectRatio={16 / 9} />

useMoviieEvent(handle, event, listener)

Subscribe to a single contract event from React. Pass the handle you received from <MoviieVideo>'s onReady (or a ref's .current); the subscription re-binds when the handle changes and cleans up on unmount.

ArgumentTypeDescription
handleMoviiePlayerHandle | null | undefinedThe player handle. The hook is a no-op while it is null.
eventPlayerAPIEventThe contract event name (for example "ended").
listener(detail: unknown) => voidCalled when the event fires.
useMoviieEvent(handle, "timeupdate", ({ currentTime }) => {
  // ...
})

For multiple events, use the onEvent prop on <MoviieVideo> instead.


<MoviieVideo>

The player component. Spread the return value of useMoviiePlayer onto it, plus any presentation overrides.

Playback props

PropTypeDescription
playbackMoviiePlaybackData | nullPlayback metadata from useMoviiePlayer. null while loading or on error.
isLoadingbooleanFrom useMoviiePlayer. Shows the loading surface.
errorError | nullFrom useMoviiePlayer. Renders the inline unavailable surface.
retry() => voidFrom useMoviiePlayer. Wired to the retry button on retryable errors.
optionsUseMoviiePlayerOptionsOverride options forwarded from useMoviiePlayer.

Presentation props

PropTypeDefaultDescription
aspectRationumberintrinsicWidth ÷ height ratio, e.g. 16 / 9.
accentColorstringembed brandingAccent color applied as --media-brand.
posterstringembed posterOverride the poster image URL.
autoplaybooleandashboardOverride autoplay.
brandingbooleandashboardShow or hide Moviie branding.
controlsPartial<MoviiePlaybackControls>dashboardPer-control overrides on top of the API-delivered flags.
classNamestringExtra class name on the player root.

See Configuration for the API-config-vs-prop rule and the full controls flag list.

Callbacks

PropTypeDescription
onReady(handle: MoviiePlayerHandle) => voidCalled once the player is ready, with the imperative handle.
onEvent(event: PlayerAPIEvent, detail: unknown) => voidCalled for every contract event. Use useMoviieEvent for a single event.
onError(error: Error, info: ErrorInfo) => voidForward unexpected render crashes to your reporter (for example Sentry.captureException).

<MoviieVideo> also accepts a ref of type MoviiePlayerHandle.


<MoviieErrorBoundary>

React error boundary that catches crashes inside the player and keeps them from taking down the host app. <MoviieVideo> already wraps itself in one; use this directly to protect a larger tree or to supply a custom fallback.

PropTypeDefaultDescription
childrenReactNodeComponent tree to protect.
fallback({ error, reset }) => ReactNodeminimal defaultCustom fallback rendered on crash. Call reset() to clear the error and re-render.
onError(error: Error, info: ErrorInfo) => voidCalled on each caught error. Wire your own reporter here.

See Error handling.


MoviiePlayerHandle

The imperative control surface exposed through the <MoviieVideo> ref (or onReady). It mirrors the window.Moviie JavaScript API and the Expo player: the same methods, events, and properties.

One contract, three surfaces

Methods, events, and properties below are the same contract as the JavaScript Player API. Rather than duplicate the full tables, see the shared Reference for every signature, payload, and property shape. The names are sourced from @moviie/player-types (PLAYER_API_METHODS, PLAYER_API_PROPERTIES).

Methods

Grouped by purpose (full signatures in the Methods reference):

GroupMethods
Playbackplay, pause, togglePlay, stop
Seekingseek, seekForward, seekBackward
Volumemute, unmute, toggleMute, setVolume
FullscreenenterFullscreen, exitFullscreen, toggleFullscreen
Picture-in-PictureenterPip, exitPip, togglePip
Playback ratesetPlaybackRate
AI surfacesopenSearch, closeSearch, openAiMenu, closeAiMenu, openQuiz, closeQuiz, openSummary, closeSummary, openEbook, closeEbook, openTutor, closeTutor, sendTutorMessage
VariantsselectVariant
Eventson, once, off
StategetState
Lifecycledestroy
handle.play()
handle.seek(30)
handle.openSummary()
const state = handle.getState() // PlayerState (contract shape)

Events

Subscribe with useMoviieEvent(handle, event, listener), the onEvent prop, or handle.on(event, listener). The full event set and payloads are in the Events reference: lifecycle (ready, play, pause, ended, timeupdate, seeking, seeked, volumechange, fullscreenenter, fullscreenexit, pipenter, pipexit, qualitychange, error), CTAs (ctashow, ctahide, ctaclick), and the AI surfaces (searchopen, searchclose, aimenuopen, aimenuclose, quizopen, quizclose, quizcomplete, summaryopen, summaryclose, ebookopen, ebookclose, variantchange).

Properties

Read individual properties off the handle, or call getState() for a coherent snapshot. The full list and types are in the Properties reference: for example currentTime, duration, paused, ended, volume, muted, fullscreen, pip, playbackRate, availableQualities, plus the feature flags searchable, quizzable, summarizable, ebookable, mindMappable, and version.


Contract constants

Re-exported from @moviie/player-types so you can reference contract names without string literals:

import {
  PLAYER_API_METHODS,
  PLAYER_API_PROPERTIES,
  PLAYER_API_VERSION,
} from "@moviie/player-react"

Versioning

@moviie/player-react follows strict semver. It tracks the PLAYER_API_VERSION contract: a breaking change to the contract (a contract MAJOR bump in @moviie/player-types) ships as a corresponding MAJOR bump here. The package never forks or extends the contract locally.

On this page