Getting started
The Astro Embed package provides components for adding rich media from third-party services to your Astro website.
Installation
Section titled “Installation”npm i astro-embedpnpm add astro-embedyarn add astro-embedUsing the components
Section titled “Using the components”Astro Embed components can be used in Astro and MDX files.
Each component expects an id prop identifying the resource to be embedded.
In Astro files
Section titled “In Astro files”To use components in .astro files, import them in the component script and then use them in your template:
---import { Tweet, Vimeo, YouTube } from 'astro-embed';---
<Tweet id="https://twitter.com/astrodotbuild/status/1512144306898976768" />
<Vimeo id="https://vimeo.com/32001208" />
<YouTube id="https://youtu.be/xtTy5nKay_Y" />In MDX files
Section titled “In MDX files”When using the Astro MDX integration, you can also import and use the embed components in MDX files:
---title: My MDX page with embed components---
import { Tweet, Vimeo, YouTube } from 'astro-embed';
Hey look! I can embed a tweet _in Markdown_!
<Tweet id="https://twitter.com/astrodotbuild/status/1512144306898976768" />
Vimeo and YouTube videos work too :-)
<Vimeo id="https://vimeo.com/32001208" /><YouTube id="https://youtu.be/xtTy5nKay_Y" />Auto-embed URLs in MDX
Section titled “Auto-embed URLs in MDX”Use the Astro Embed integration to automatically convert URLs in MDX files to embed components.
Learn how to set up the integration in the “Auto-embed URLs” guide.
Supported services
Section titled “Supported services”Astro Embed currently supports the following services: