npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@react5/you-player

v0.4.12

Published

Youtube player React component.

Readme

YouPlayer

YouPlayer is a lightweight React component for embedding and controlling YouTube videos. It wraps the YouTube IFrame Player API, making it straightforward to integrate into your React and Typescript application.

Table of Contents

  1. Features
  2. Installation
  3. Usage
  4. Props
  5. Example
  6. API Reference
  7. Contributing
  8. Support
  9. License

Features

  • Simple and intuitive React component for YouTube video playback
  • Access to the underlying IYouTubePlayer for advanced controls (play, pause, next video, etc.)
  • Callback handlers for player events: onReady, onStateChange, etc.

Installation

Using npm

npm install @react5/you-player

Using yarn

yarn add @react5/you-player

Usage

import { FC, useState } from 'react'
import { YouPlayer, type IYouTubePlayer, type PlayerState } from '@react5/you-player'

const MyComponent: FC = () => {
  const [player, setPlayer] = useState<IYouTubePlayer | null>(null)

  const handleReady = (p: IYouTubePlayer) => {
    console.log('Player ready')
    setPlayer(p)
    p?.playVideo()
  }

  const handleStateChange = (state: PlayerState, player: IYouTubePlayer) => {
    console.log('State change', state)
  }

  return (
    <div>
      <h1>YouPlayer Demo</h1>
      <YouPlayer
        videoId="aKydtOXW8mI"
        onReady={handleReady}
        onStateChange={handleStateChange}
      />
      <div>
        <button onClick={() => player?.pauseVideo()}>Pause</button>
        <button onClick={() => player?.playVideo()}>Play</button>
        <button onClick={() => player?.nextVideo()}>Next</button>
        <button onClick={() => player?.previousVideo()}>Previous</button>
      </div>
    </div>
  )
}

export default MyComponent

Props

| Prop | Type | Default | Required | Description | |----------------|-------------------------------------------|-----------|----------|-----------------------------------------------------------| | videoId | string | - | yes | The YouTube video ID to load. | | onReady | (player: IYouTubePlayer) => void | undefined | no | Called when the player is initialized and ready. Receives the IYouTubePlayer instance. | | onStateChange | (state: PlayerState, player: IYouTubePlayer) => void | undefined | no | Called when the player’s state changes. Receives new state and the player instance. | | height | string | number | 360 | no | The player iframe height (can be px or %). | | width | string | number | 640 | no | The player iframe width (can be px or %). |

Example

Below is a minimal example that loads a YouTube video and starts playback when the player is ready:

import React, { FC } from 'react'
import { YouPlayer } from '@react5/you-player'

const SimpleUsage: FC = () => {
  return (
    <YouPlayer
      videoId="aKydtOXW8mI"
      onReady={(player) => {
        console.log('Player is ready!')
        player.playVideo()
      }}
    />
  )
}

export default SimpleUsage

API Reference

IYouTubePlayer

IYouTubePlayer is the interface representing the underlying YouTube Player instance. It provides methods such as:

  • playVideo()
  • pauseVideo()
  • stopVideo()
  • seekTo(seconds: number, allowSeekAhead: boolean)
  • nextVideo()
  • previousVideo()
  • mute()
  • unMute()
  • isMuted()
  • setVolume(volume: number)
  • getVolume()
  • getPlayerState()

For full details, see the official YouTube IFrame Player API Reference.

PlayerState

PlayerState is an enum representing the player’s current state:

  • UNSTARTED (typically -1)
  • ENDED (0)
  • PLAYING (1)
  • PAUSED (2)
  • BUFFERING (3)
  • CUED (5)

Contributing

Contributions are welcome!

Support

If you have any questions or run into issues:

  • Check the Issues to see if your problem has already been addressed.
  • Create a new issue with details about the bug or feature request.
  • You can also reach out to us via email if you prefer a private channel.

License

YouPlayer is MIT licensed. Feel free to fork, submit pull requests, and use this component in your projects.