{
  "id": 13928686,
  "title": "Create a Video player with react-player which supports mp4, Youtube and Vimeo videos with ReactJS",
  "url": "https://urgent.news/2026/10/12/create-a-video-player-with-react-player-which-supports-mp4-youtube",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-12T10:11:18.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/sanjivsutar/create-a-video-player-with-react-player-which-supports-mp4-youtube-and-vimeo-videos-with-reactjs-2ob9"
  },
  "original_language": "en",
  "account": "To construct a video player utilizing the react-player library that supports playback of MP4, YouTube, and Vimeo videos within a ReactJS framework, you must first install the library using the command npm install react-player. Once installed, commence by crafting a VideoPlayer component. Import React and ReactPlayer, and define the component with a prop named url.\n\nNext, ascertain whether the provided URL points to a YouTube or Vimeo video by examining if the string \"youtube.com\" or \"vimeo.com\" appears within the URL string. If the URL contains \"youtube.com\", employ JavaScript's split method to isolate the video ID, which follows the pattern \"v=VIDEO_ID\". Then, within the ReactPlayer component, assign the constructed URL using the format \"https://www.youtube.com/watch?v=VIDEO_ID\". Apply width and height properties set to 100% to ensure the player occupies the entire container space.\n\nSimilarly, for Vimeo videos, isolate the video ID from the URL using \"vimeo.com/VIDEO_ID\". Once again, insert this URL into the ReactPlayer component, maintaining the 100% width and height for consistent sizing.\n\nIf the URL does not correspond to either YouTube or Vimeo, simply render the ReactPlayer component with the supplied URL and incorporate the controls prop to enable video controls. Additionally, set the width and height properties to 100% to maintain uniform playback dimensions across all video types.\n\nFinally, integrate the VideoPlayer component into your application. Import React and the VideoPlayer component, and utilize it within your App component. Supply diverse video URLs to illustrate the component's capability in playing YouTube, Vimeo, and MP4 videos. These instances can be observed in the provided code snippet, demonstrating the functionality in practice. For a live demonstration, access the code sandbox at https://codesandbox.io/s/reactplayerdemo-mokjcd.",
  "summary": "First, let’s install the library: npm install react - player Next, let’s create our video player component: import React from ' react ' ; import ReactPlayer from ' react-player ' ; const VideoPlayer = ({ url }) => { const isYoutube = url . includes ( ' youtube.com ' ); const isVimeo = url . includes ( ' vimeo.com ' ); if ( isYoutube ) { const videoId = url . split ( ' v= ' )[ 1 ]; return ( <…",
  "key_points": [
    "Install react-player library using npm install react-player",
    "Create VideoPlayer component with url prop",
    "Detect YouTube/Vimeo URLs and construct appropriate video URLs"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}