JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://www.youtube.com/iframe_api"></script>
<div id="player"></div>
JavaScript
var onPlayerReady = function(event) {
event.target.playVideo();
};
// The first argument of YT.Player is an HTML element ID. YouTube API will replace my <div id="player"> tag with an iframe containing the youtube video.
var player = new YT.Player('player', {
height: 320,
width: 400,
videoId : '6Dc1C77nra4',
events : {
'onReady' : onPlayerReady
}
});