
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-twitch-embed
Advanced tools
A collection of components to embed Twitch.
For more information, visit the Embedding Twitch documentation page.
Make sure to check out the Demo and Documentation page for more information on the usage of the components, alongside a description on all the supported props for each component.
npm install react-twitch-embed
This package includes some typings for the Embed and Player constructors that are downloaded automatically
into the browser's window object. These are unofficial typings that I made empirically, some of them might not be accurate.
The documentation on Twitch's official page is incomplete in various aspects, and a lot of the functionality included in this package was found by arbitrarily and through trial and error.
If you find any inconsistency with the typings provided by this package, feel free to open a Pull Request.
parent PropTwitch requires that any embeds include the URL of the parent site that embeds their content. These components will get this
parent URL through window.location.hostname for non-interactive components (those components that are essentially just an iframe),
while the interactive ones get the parent automatically (possible through the same property) by their respective constructor.
As such, you shouldn't need to specify this prop for any of the components, unless you run a particular setup with multiple domains.
TwitchEmbed, TwitchPlayer and TwitchPlayerNonInteractive, which component should I choose?Out of these components,
TwitchEmbedandTwitchPlayerare both interactive components, meaning that they expose the internal instance through their respective events. Both of these components support streams, VODs and collections, and they both react efficiently when theirchannel,video, orcollectionprops change by using the internal API instead of recreating the embed when they change. The key difference is thatTwitchEmbedcan include the live chat on streams. At the end of the day, it depends on which one you prefer.As for
TwitchPlayerNonInteractive, this component can embed streams, VODs and collections too, but it does not include an internal API. This means that channel, video or collection switching is not "smooth" and will recreate the embed. However, this component does not download anything extra, it does not create any additional nodes on the body document, so it is probably less resource heavy.
TwitchClip and TwitchPlayer?
TwitchClipwill only work for clips whereasTwitchPlayerwill work for VODs, collections and streams.
In the case of
TwichEmbedandTwitchPlayer, these components need anidprop to work because the internal API mounts its respectiveiframeinside adivqueried by itsid. These components will use a defaultidif it's not provided in their props. If you're displaying multiple embeds simultaneously then you should provide a staticid. Try not to use the name of the channel as anidbecause in the case that this prop changes, the embed will be recreated and the internal API won't be used for the channel switching.
For the
TwitchEmbedandTwitchPlayercomponents, when updating theirchannel,videoand/orcollectionprops, the player will not be recreated and instead the internal API will be used to update this data.
You can run the tests for this package by running:
npm test
Or leave the watcher running with:
npm run test:watch
When developing, you can use Storybook as a way to check the components and test them. You can run the Storybook server with:
npm run storybook:serve
Also, make sure that your code is linter properly with:
npm run lint
This component package was made by moonstar-x.
FAQs
A collection of components to embed Twitch.
The npm package react-twitch-embed receives a total of 1,807 weekly downloads. As such, react-twitch-embed popularity was classified as popular.
We found that react-twitch-embed demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.