
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
react-youtube
Advanced tools
Simple React component acting as a thin layer over the YouTube IFrame Player API
npm install react-youtube
yarn add react-youtube
pnpm add react-youtube
<YouTube
videoId={string} // defaults -> ''
id={string} // defaults -> ''
className={string} // defaults -> ''
iframeClassName={string} // defaults -> ''
style={object} // defaults -> {}
title={string} // defaults -> ''
loading={string} // defaults -> undefined
opts={obj} // defaults -> {}
onReady={func} // defaults -> noop
onPlay={func} // defaults -> noop
onPause={func} // defaults -> noop
onEnd={func} // defaults -> noop
onError={func} // defaults -> noop
onStateChange={func} // defaults -> noop
onPlaybackRateChange={func} // defaults -> noop
onPlaybackQualityChange={func} // defaults -> noop
/>
For convenience it is also possible to access the PlayerState constants through react-youtube:
YouTube.PlayerState contains the values that are used by the YouTube IFrame Player API.
// js
import React from 'react';
import YouTube from 'react-youtube';
class Example extends React.Component {
render() {
const opts = {
height: '390',
width: '640',
playerVars: {
// https://developers.google.com/youtube/player_parameters
autoplay: 1,
},
};
return <YouTube videoId="2g811Eo7K8U" opts={opts} onReady={this._onReady} />;
}
_onReady(event) {
// access to player in all event handlers via event.target
event.target.pauseVideo();
}
}
// ts
import React from 'react';
import YouTube, { YouTubeProps } from 'react-youtube';
function Example() {
const onPlayerReady: YouTubeProps['onReady'] = (event) => {
// access to player in all event handlers via event.target
event.target.pauseVideo();
}
const opts: YouTubeProps['opts'] = {
height: '390',
width: '640',
playerVars: {
// https://developers.google.com/youtube/player_parameters
autoplay: 1,
},
};
return <YouTube videoId="2g811Eo7K8U" opts={opts} onReady={onPlayerReady} />;
}
You can access & control the player in a way similar to the official api:
The
APIcomponent will pass an event object as the sole argument to each ofthose functionsthe event handler props. The event object has the following properties:
- The event's
targetidentifies the video player that corresponds to the event.- The event's
dataspecifies a value relevant to the event. Note that theonReadyevent does not specify adataproperty.
MIT
react-player is a React component that can play various types of media, including YouTube videos, Vimeo videos, SoundCloud tracks, and more. It offers a broader range of media support compared to react-youtube, which is specifically for YouTube videos.
react-youtube-lite is a lightweight alternative to react-youtube. It focuses on providing a minimalistic and fast-loading YouTube player component for React applications. It is suitable for use cases where performance and simplicity are prioritized over extensive customization options.
FAQs
React.js powered YouTube player component
The npm package react-youtube receives a total of 589,309 weekly downloads. As such, react-youtube popularity was classified as popular.
We found that react-youtube 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.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.