The YouTubeEmbed component provides a performant way to embed YouTube videos. It
wraps the community
@astro-community/astro-embed-youtube
package, which uses lite-youtube-embed under the hood — rendering a static
poster image and only loading the YouTube iframe when the user clicks play.
---
import YouTubeEmbed from "astro-theme-university/components/YouTubeEmbed.astro";
---
Props#
| Prop | Type | Default | Description |
|---|---|---|---|
id * | string | --- | YouTube video ID. |
title | string | --- | Accessible title for the embedded iframe. |
Examples#
Basic embed
Embed with custom title
Notes#
Always provide a descriptive title prop for accessibility.
The embed renders a clickable poster image on initial load. Only the small
lite-youtube-embed script that defines the custom element loads with the page;
YouTube’s own iframe and player JavaScript load when the user clicks play.