This is an npm module version of the YouTube Player API for IFrame embeds. It automatically adds the iframe_api script to the browser. You can then refer to the YouTube Player API for IFrame API reference.
For the React version you can check out react-youtube-iframe-player.
npm install youtube-iframe-api-module
import { loadScript } from 'youtube-iframe-api-module';
loadScript(() => {
// Player 1
const player = new YT.Player('player-one', {
height: '390',
width: '640',
videoId: 'M7lc1UVf-VE'
});
})
loadScript(() => {
// Player 2
const player = new YT.Player('player-two', {
height: '390',
width: '640',
videoId: 'M7lc1UVf-VE'
});
})