Private, performant YouTube embeds for React. Under 5KB gzipped.
Complete guides, live examples, and API reference
YouTube's standard iframe embed adds over 500KB and makes dozens of network requests before the user even clicks play. This component fixes that:
- β Tiny β Under 5KB gzipped (JS + CSS)
- β Fast β Loads only a thumbnail until user clicks
- β Private β No YouTube cookies or tracking by default
- β SEO-Friendly β Structured data for search engines
- β Accessible β Full keyboard navigation and screen readers
- β TypeScript β Complete type definitions
npm install react-lite-youtube-embedimport LiteYouTubeEmbed from 'react-lite-youtube-embed'; import 'react-lite-youtube-embed/dist/LiteYouTubeEmbed.css'; export default function App() { return ( <LiteYouTubeEmbed id="dQw4w9WgXcQ" title="Rick Astley - Never Gonna Give You Up" /> ); }That's it! You now have a performant, private YouTube embed.
<LiteYouTubeEmbed id="VIDEO_ID" title="Video Title" lazyLoad={true} />Defers loading offscreen thumbnails, reducing bandwidth and improving mobile performance.
<LiteYouTubeEmbed id="VIDEO_ID" title="Video Title" seo={{ name: "Full Video Title", description: "Video description for search engines", uploadDate: "2024-01-15T08:00:00Z", duration: "PT3M33S" }} />Enables JSON-LD VideoObject structured data for Google Rich Results.
<LiteYouTubeEmbed id="VIDEO_ID" title="Video Title" enableJsApi onPlay={() => console.log('Video started')} onPause={() => console.log('Video paused')} onEnd={() => console.log('Video finished')} />React to player state changes for analytics, auto-advancing playlists, and more.
<LiteYouTubeEmbed id="VIDEO_ID" title="Video Title" poster="maxresdefault" />Use maxresdefault for hero sections and featured content.
π Visit the full documentation β
- Getting Started
- API Reference - Complete props documentation
- Live Examples - Interactive demonstrations
- Code Examples - Copy-paste patterns
- Performance Guide
- Events Documentation
We welcome contributions! See CONTRIBUTING.md for guidelines.
# Install dependencies npm install # Run tests npm test # Build npm run buildThis package includes:
- β SLSA Build Level 3 Provenance - Cryptographically signed builds
- β CodeQL Analysis - Automated security scanning
- β Dependency Audits - Regular security updates
Verify package authenticity:
npm audit signaturesSee .github/SLSA.md for more details.
MIT Β© Ibrahim Cesar
See LICENSE for full details.
- Paul Irish (@paulirish) - Original Lite YouTube Embed
- Addy Osmani (@addyosmani) - Adaptive Loading concepts
Made with π§© in Brazil π§π·
