twitch-video-element is a custom web component designed to embed Twitch player functionality into web applications, presenting an API that closely mirrors the standard HTML `<video>` element. Currently at version 0.1.6, this package is part of the larger @mux/media-elements monorepo. While the monorepo sees regular updates, this specific package is in an early pre-1.0.0 stage, indicating its API may evolve towards stability. Its primary differentiation lies in providing a familiar HTMLMediaElement interface for Twitch content, simplifying integration with other web components like Media Chrome, and abstracting the underlying complexities of the official Twitch embedded player SDK.
npm install twitch-video-elementVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to embed a Twitch video (VOD) and a live stream using the `<twitch-video>` custom element in an HTML page. It includes essential attributes like `controls`, `autoplay`, `muted`, and the critical `parent` attribute for security. It also shows programmatic interaction via JavaScript.
Always include the `parent` attribute on the `<twitch-video>` element, listing the hostname(s) where the element is hosted. For multiple domains, use a space-separated string: `parent="domain1.com domain2.com"`.
Add the `muted` attribute to the `<twitch-video>` element: `<twitch-video autoplay muted src="..."></twitch-video>`.
Ensure the `src` attribute points to a valid Twitch VOD URL (containing `videos/ID`) or a Twitch channel URL (`twitch.tv/CHANNEL_NAME`). For clips, use the designated Twitch clip embed URL structure if available or integrate via the Twitch API directly if custom interaction is needed.
Ensure that the `<twitch-video>` element, or its containing parent, is styled to be at least 400px wide and 300px tall. For example: `<twitch-video style="width: 640px; height: 360px;" src="..."></twitch-video>`.
Pin to exact patch versions (`~0.1.6` instead of `^0.1.6`) or perform thorough testing when updating this package until it reaches a stable 1.0.0 release.
Verify that your WebView or browser environment has JavaScript and MSE fully enabled. For WebViews, ensure proper client settings are configured. Debugging in the target environment with browser developer tools can help pinpoint the exact cause.
Check your internet connection stability. Disable browser extensions (especially ad blockers or privacy tools) one by one to identify conflicts. Try loading the Twitch player in an incognito/private browser window.
Update your web browser to the latest version. Try a different browser to rule out compatibility issues. If persistent, check if the content is accessible in your region directly on Twitch.tv.
Ensure your browser is updated. Try disabling hardware acceleration in your browser settings (often under System or Advanced settings). Temporarily disable browser extensions.
For interactive embeds, ensure you are using a Twitch VOD ID (e.g., `v123456789`) or a channel name for live content. If you specifically need to embed a clip interactively, you might need to use the dedicated Twitch Clips embed iframe structure rather than the general player API, or wrap it in a non-interactive iframe.
No dependency data recorded yet.