Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-youtube

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-youtube

React.js powered YouTube player component

  • 10.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is react-youtube?

The react-youtube npm package is a React component for embedding YouTube videos. It provides a simple way to integrate YouTube videos into your React applications with various customization options and event handling capabilities.

What are react-youtube's main functionalities?

Embedding a YouTube Video

This feature allows you to embed a YouTube video in your React application. The `opts` object is used to customize the player, such as setting the height, width, and player variables like autoplay.

import React from 'react';
import YouTube from 'react-youtube';

const MyComponent = () => {
  const opts = {
    height: '390',
    width: '640',
    playerVars: {
      autoplay: 1,
    },
  };

  return <YouTube videoId="2g811Eo7K8U" opts={opts} />;
};

export default MyComponent;

Handling Events

This feature allows you to handle various events from the YouTube player. In this example, the `onReady` event is used to pause the video as soon as it is ready.

import React from 'react';
import YouTube from 'react-youtube';

const MyComponent = () => {
  const onReady = (event) => {
    event.target.pauseVideo();
  };

  return <YouTube videoId="2g811Eo7K8U" onReady={onReady} />;
};

export default MyComponent;

Customizing Player Options

This feature allows you to customize various player options such as autoplay, controls, and related videos. The `playerVars` object is used to set these options.

import React from 'react';
import YouTube from 'react-youtube';

const MyComponent = () => {
  const opts = {
    height: '390',
    width: '640',
    playerVars: {
      autoplay: 1,
      controls: 0,
      rel: 0,
    },
  };

  return <YouTube videoId="2g811Eo7K8U" opts={opts} />;
};

export default MyComponent;

Other packages similar to react-youtube

Keywords

FAQs

Package last updated on 22 Nov 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc