Video Embedding

Embed YouTube, Bilibili, and custom videos in your posts

jet-w
4min

Video Embedding

Add videos to make your content more engaging and informative.

YouTube

Embed YouTube videos using the component:

<YouTube id="dQw4w9WgXcQ" />

Or with a full URL:

<YouTube url="https://www.youtube.com/watch?v=dQw4w9WgXcQ" />

Options

<YouTube
  id="dQw4w9WgXcQ"
  title="Video Title"
  start={30}
/>
OptionDescription
idYouTube video ID
urlFull YouTube URL
titleVideo title for accessibility
startStart time in seconds

Bilibili

For Bilibili videos:

<Bilibili bvid="BV1xx411c7mD" />

Or with AV number:

<Bilibili aid="123456789" />

Options

<Bilibili
  bvid="BV1xx411c7mD"
  page={1}
  title="Video Title"
/>
OptionDescription
bvidBilibili BV ID
aidBilibili AV number
pagePart number (for multi-part videos)
titleVideo title

Self-Hosted Videos

For videos in your public/ folder:

<Video src="/videos/demo.mp4" />

Options

<Video
  src="/videos/demo.mp4"
  poster="/images/video-cover.jpg"
  autoplay
  muted
  loop
/>
OptionDescription
srcVideo file path
posterCover image URL
autoplayAuto-play on load
mutedMuted by default
loopLoop playback
controlsShow controls (default: true)

HTML5 Video

You can also use standard HTML5:

<video
  src="/videos/demo.mp4"
  controls
  width="100%"
  poster="/images/cover.jpg">
  Your browser doesn't support video.
</video>

Multiple Sources

<video controls width="100%">
  <source src="/videos/demo.webm" type="video/webm">
  <source src="/videos/demo.mp4" type="video/mp4">
  Your browser doesn't support video.
</video>

Video Formats

FormatExtensionSupport
MP4 (H.264).mp4Best compatibility
WebM.webmGood compression
Ogg.ogvOpen format
Recommendation

Use MP4 (H.264) for best browser support. WebM is a good secondary option.

Responsive Videos

Videos are responsive by default. For custom aspect ratios:

<div style="aspect-ratio: 16/9;">
  <Video src="/videos/demo.mp4" style="width: 100%; height: 100%;" />
</div>

Best Practices

Video Guidelines
  1. Optimize file size - Compress videos for web
  2. Add poster images - Show a preview before loading
  3. Provide captions - Improve accessibility
  4. Consider autoplay carefully - Can be annoying
  5. Use lazy loading - Don’t load videos until needed
File Size

Keep videos under 10MB when possible. For longer videos, consider hosting on YouTube or Vimeo.

External Embedding

For other platforms, use their embed codes:

<iframe
  src="https://player.vimeo.com/video/123456789"
  width="640"
  height="360"
  frameborder="0"
  allowfullscreen>
</iframe>

Next: Icons to add visual elements.