Prerequisites
- A project where you can run
npxcommands and serve ES modules. The CLI copies the element source into your project. - A BeyondWords project ID and a source ID (or content ID). The examples below use a public demo project.
Load the player script
The elements expect the BeyondWords player as a globalBeyondWords. Add the
player UMD script to your page so it loads before the provider connects:
Add a component
Add the Play Pause Button. No configuration is needed. The--html flag selects the HTML registry, and the CLI resolves
dependencies automatically, so this also pulls in
Player Provider and
New Event.
components/beyondwords/ by default (it asks
first), or respects your aliases if the project has a components.json. The
examples in these docs import from @/registry/html/. Adjust the paths to
wherever the files landed, and serve them through a bundler or an import map so
the browser can resolve them.
Build your first player
Each module callscustomElements.define, so importing it registers the tag.
Nest your controls inside a <bw-player-provider>, which mounts the player and
shares it with the elements inside. data-show-user-interface="false" hides the
player’s built-in UI so yours is the only one on the page.
BwPlayerConsumer, which resolves the
player instance from the nearest <bw-player-provider>. See
Player Provider for the pattern, and
New Event for emitting player events.
Using the shadcn CLI instead (optional)
The registry also works with the shadcn CLI directly. Add components by full URL:components.json, then use
short names:
components.json
Next steps
Theming
Style the elements to match your brand.
Player Provider
Provide and consume the player.
Examples
Start from a complete, pre-built player.
Troubleshooting
Fix common setup issues.