Skip to content

Oembed

The <Oembed> component resolves a URL against the bundled Provider Snapshot, fetches the oEmbed response at build time, and renders the appropriate output.

---
import { Oembed } from 'astro-oembed';
---
<Oembed url="https://www.youtube.com/watch?v=dQw4w9WgXcQ" />
PropTypeDefaultDescription
urlstringRequired. The URL to embed.
posterstringOverride image for the click-to-load placeholder.
placeholderColorstring#1a1a1aFallback background color when no poster is available.
maxWidthnumberPassed to the oEmbed endpoint as maxwidth.
maxHeightnumberPassed to the oEmbed endpoint as maxheight.
accessTokenstringPassed as access_token for providers that require authentication (e.g. Meta Graph API).

Additional HTML attributes are spread onto the outermost rendered element.

The rendered output depends on the oEmbed response type returned by the provider.

oEmbed typeRendered as
video or rich<lite-oembed> — a click-to-load placeholder that swaps in the iframe on click
photoAstro <Image /> (requires the provider domain in image.domains)
link<a href={url}>{title ?? url}</a>
No matching providerNothing (+ console.warn in dev)

video and rich responses that return an <iframe> are wrapped in a <lite-oembed> custom element. The iframe is not loaded until the user clicks the placeholder, keeping initial page weight low.

The placeholder displays a poster image resolved in priority order: the poster prop → thumbnail_url from the oEmbed response → a solid colour using placeholderColor.

Photo responses are rendered with Astro’s built-in <Image /> component. The provider’s image domain must be listed in your Astro config:

astro.config.mjs
export default defineConfig({
image: {
domains: ['photos.example.com'],
},
});