embed-lite
embed-lite
embed-lite is a zero-dependency static embed parser that transforms external media URLs (YouTube, Twitter/X, Vimeo, Spotify, GitHub, CodePen, and more) into responsive, accessible HTML iframe embeds.
Privacy & Performance
embed-lite uses lazy loading (loading="lazy") and sandboxed iframe parameters to safeguard visitor privacy and maintain sub-second page performance.
Installation
pnpm
npm
bun
pnpm add embed-lite
npm install embed-lite
bun add embed-lite
Usage
import { parseEmbed, isEmbeddable } from 'embed-lite';
const url = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
if (isEmbeddable(url)) {
const html = parseEmbed(url, {
responsive: true,
aspectRatio: '16:9'
});
console.log(html);
}
Supported Providers
embed-lite natively detects and parses links from:
- Video: YouTube, Vimeo, Loom, TikTok, Twitch
- Social: Twitter / X, Reddit, LinkedIn, Facebook, Instagram
- Audio: Spotify, SoundCloud, Apple Music
- Code & Docs: GitHub Gist, CodePen, CodeSandbox, Figma
API Reference
parseEmbed(url, options?)
Converts a supported URL into responsive iframe markup.
isEmbeddable(url)
Returns true if the URL matches a supported provider pattern.