DEV Community

Cover image for Add YouTube Video Player in React-App
Fidal Mathew
Fidal Mathew

Posted on

Add YouTube Video Player in React-App

Hi folks, hope you are doing well. In this post we are going to learn how to add a video link to your React app and play in your React app.

How to Install

This player component can be used by installing react-player
NPM package.

Enter your directory, open your terminal (Ctrl+ J).
Type npm i react-player in your app directory and press enter.
install react-player

How To Use

1. Import -
Now, import the package in the React component file where you want to add the video player.
import ReactPlayer from "react-player";
Import
2. Add the component -
<ReactPlayer url="url-link" controls={true} />
Add the component

Hurray, you added a video-player to your React app!!
At this point, you can stop and enjoy :)

Additional Settings-
If you want to add some extra settings, here are a few-

  1. controls = {true/false} - provides video controls to user
  2. loop = {true/false} - repeat the video if it ends
  3. volume = {0 to 1} - set volume

To check out more, click here

Check out the my Netflix clone, click on any movie to view it's trailer - here
Netflix Clone

If you know of other methods to implement, let me know in the comments. Thanks for reading :)

Discussion (0)