Embedding YouTube
The easiest way to add video:Implementation
Responsive YouTube
Embedding Vimeo
Similar to YouTube:Self-Hosted Videos
HTML5 Video
For videos in your public folder:With Poster
Show an image before playing:Autoplay (Muted)
Autoplay requires muted for most browsers:Video Backgrounds
Hero with Video Background
Hosting Larger Videos
Short clips can live in yourpublic/ folder and play with a standard <video>
tag (see Self-Hosted Videos above). But video files are
large, and bundling big files into your site bloats the build and slows page
loads.
For anything beyond a short clip, host the video on a dedicated video platform
and embed it. This offloads bandwidth, adds adaptive streaming, and keeps your
site fast:
Rough Guidance
| Video size | Best approach |
|---|---|
| Short clip (up to ~10 MB) | Static file in public/ |
| Longer or high-resolution video | Embed from a video host (YouTube, Vimeo) |
Video Optimization
File Formats
| Format | Support | Best For |
|---|---|---|
| MP4 | Universal | General use |
| WebM | Modern browsers | Better compression |
Provide Multiple Sources
Compression Tips
- Resolution: 1080p max for web
- Bitrate: 5-8 Mbps for 1080p
- Duration: Keep short for fast loading
- Tools: HandBrake, FFmpeg for compression
Video Players
Custom Player UI
Third-Party Players
For advanced features:- Video.js - Full-featured player
- Plyr - Simple, accessible
- React Player - Supports multiple sources
Lazy Loading Videos
Don’t load videos until needed:Video SEO
Schema Markup
Accessibility
Captions
Always provide captions:Transcripts
Provide text alternatives:Common Patterns
Product Demo Section
Video Testimonials
Tutorial Gallery
Troubleshooting
Video not playing
Video not playing
- Check file path is correct
- Ensure video format is supported
- Check browser console for errors
- Verify video isn’t blocked by CORS
Autoplay not working
Autoplay not working
- Must be muted for autoplay
- Add playsInline for mobile
- Some browsers block all autoplay
Video loads slowly
Video loads slowly
- Compress the video file
- Use appropriate resolution
- Consider streaming services for long videos
- Add poster image while loading
Using Images
Image best practices

