~2 min read • Updated Oct 28, 2025
Using
In Next.js, you can embed videos using the video tag for direct files or iframe for hosted platforms like YouTube and Vimeo.
Example: Using
<video width="320" height="240" controls preload="none">
<source src="/path/to/video.mp4" type="video/mp4" />
<track src="/path/to/captions.vtt" kind="subtitles" srcLang="en" label="English" />
Your browser does not support the video tag.
</video>Important
controls: Shows playback controlsautoPlay: Starts playback automatically (requiresmutedandplaysInline)preload: Controls how video is preloaded (none, metadata, auto)track: Adds subtitles
Example: Using
<iframe src="https://www.youtube.com/embed/19g66ezsKAg" allowFullScreen />Useful attributes: width, height, loading="lazy", title, sandbox
Choosing the Right Method
- Self-hosted videos: Full control and customization
- Hosted platforms: Easy integration and platform features
Streaming with React Suspense
Use Suspense to stream video components:
<Suspense fallback={<p>Loading video...</p>}>
<VideoComponent />
</Suspense>Using Skeleton UI
<Suspense fallback={<VideoSkeleton />}>
<VideoComponent />
</Suspense>Benefits of Self-Hosting
- Complete control and independence
- Customization for design and functionality
- Scalable performance
- Easy integration with Next.js
Hosting Videos with Vercel Blob
Vercel Blob provides scalable cloud storage for videos.
- Upload videos via dashboard or server action
- Display videos using the file URL
Example: Displaying Video from Vercel Blob
const { blobs } = await list({ prefix: fileName, limit: 1 })
const { url } = blobs[0]
<video controls preload="none">
<source src={url} type="video/mp4" />
</video>Adding Subtitles from Vercel Blob
const { url } = blobs[0]
const { url: captionsUrl } = blobs[1]
<track src={captionsUrl} kind="subtitles" srcLang="en" label="English" />Conclusion
Next.js makes it easy to embed and optimize videos using HTML tags, React Suspense, and cloud storage like Vercel Blob. Choose the method that best fits your project’s needs and user experience goals.
Written & researched by Dr. Shahin Siami