Basic Usage

Create a player

import { YoutubeView, useYouTubePlayer } from 'react-native-youtube-bridge';

function App() {
  const player = useYouTubePlayer('AbZH7XWDW_k');

  return <YoutubeView player={player} />;
}

Source input forms

useYouTubePlayer accepts:

useYouTubePlayer('AbZH7XWDW_k');
useYouTubePlayer({ videoId: 'AbZH7XWDW_k' });
useYouTubePlayer({ url: 'https://www.youtube.com/watch?v=AbZH7XWDW_k' });

If the source is invalid, the player emits an error event.

Player lifecycle

The hook owns the underlying player instance for you.

  • create the player once in component scope
  • pass it to YoutubeView
  • reuse the same instance for events and controls

Minimal configured example

const player = useYouTubePlayer('AbZH7XWDW_k', {
  autoplay: true,
  controls: true,
  playsinline: true,
  rel: false,
});

return <YoutubeView player={player} />;