Core Concepts
Components
In this section, we'll go through the basics of using Vidstack Player components with React.
Importing Components
You can import all components from the path @vidstack/react
. Component names mirror the element tag name except they're in PascalCase without the vds
prefix.
vds-media
->Media
vds-video
->Video
vds-play-button
->PlayButton
Keep in mind that you're implicitly registering the underlying custom element by importing a React component.
Element References
All components forward the underlying custom element reference, so you can use the familiar useRef
hook to get a hold of it.
Properties
We expose all custom element properties on the React wrapper, which gets forwarded to the element itself; therefore, you can pass in complex data types such as objects and arrays without any issues.
Events
All custom events are forwarded to a callback whose name mirrors the original event name but in PascalCase:
Element Types
All element types are classes named using PascalCase and suffixed with the word Element
(e.g., MediaElement
).
Provider Types
The following utilities can be useful for narrowing the type of a media provider element: