astro-livid
Livid, ad-free video hosting for individuals and small businesses. astro-livid lets you embed a Livid video in Astro with one component.
Open Source Component ∙

astro-livid

An Astro component for embedding Livid videos in a responsive, lazy-loaded iframe, with typed props for all of Livid's advanced embedding parameters and an optional click-to-load facade.

astro-livid is an Astro component that lets you embed a Livid-hosted video with one line. It outputs a responsive, lazy-loaded iframe and gives you typed props for every one of Livid’s advanced embedding parameters. It works with Astro 6 and 7.

Demo

This site runs on Jekyll, so it can’t run an Astro component. Here’s the Astro code:

---
import { Livid } from 'astro-livid';
---

<Livid id="YEsVONDwAoi8" lividLogo title={false} airplay chromecast pip speed qualitySelector keyboard />

The player below is the same embed that component produces, rendered here with my jekyll-livid tag:

Why This Exists

I built jekyll-livid first. I also build sites in Astro, and I wanted the same one-line embed there, with typed props so my editor autocompletes the options.

Source Code

Installation

npm install astro-livid

There’s no integration to register and nothing to add to your Astro config.

Usage

Basic embed:

---
import { Livid } from 'astro-livid';
---

<Livid id="YEsVONDwAoi8" />

The same import works in MDX.

The id prop takes either the video ID or the full share URL. The ID is the string of letters and numbers at the end of your Livid share URL (https://livid.com/watch/YEsVONDwAoi8 has the ID YEsVONDwAoi8).

With parameters:

<Livid id="YEsVONDwAoi8" autoplay muted />
<Livid id="YEsVONDwAoi8" color="ff0000" controls={false} />
<Livid id="YEsVONDwAoi8" pip speed title={false} />
<Livid id="YEsVONDwAoi8" t={30} />

Booleans work bare, so pip means pip={true}. t={30} starts the video at 30 seconds.

Click to Load

Add facade and the component renders only a poster image and a play button. The player loads when a visitor clicks, so the page stays light.

<Livid id="YEsVONDwAoi8" facade />
<Livid id="YEsVONDwAoi8" facade poster="/my-image.jpg" />

The poster and title come from Livid’s oEmbed endpoint at build time. If that lookup fails, the component falls back to the normal iframe. Use poster to supply your own image instead.

Other Props

Prop Values Notes
aspect CSS aspect-ratio Defaults to 16/9. Use aspect="9/16" for vertical video.
iframeTitle text The iframe’s accessible name. It’s separate from title, which shows or hides the title inside the player.
class text Added to the wrapper.

The package also exports two helpers, buildEmbedUrl(id, params) and parseVideoId(input).

Output

The component renders a div with the class livid-embed around a responsive, lazy-loaded iframe. It ships no client JavaScript unless you use facade.

Styling

The component doesn’t add any margins or spacing, and that’s on purpose. Every site has its own type rhythm and spacing scale.

If the video sits too close to the content below it, add a rule to your site’s CSS:

.livid-embed {
  margin-bottom: 32px; /* adjust to match your site's heading/paragraph spacing */
}

Advanced Parameters

Every one of Livid’s advanced embedding parameters works. Livid’s snake_case names become camelCase props.

Prop Values Notes
autoplay true/false All videos
muted true/false All videos
loop true/false All videos
controls true/false Pro/Premium
color hex code (no #) Pro/Premium
colors up to 4 comma-separated hex codes Pro/Premium
dnt true/false Disables analytics. All videos.
background true/false No controls, loops, autoplay, muted. Pro/Premium.
t seconds Start position
preload auto/metadata/none All videos
playsinline true/false Mobile inline playback. All videos.
fullscreen true/false Pro/Premium
pip true/false Picture-in-picture. Pro/Premium.
keyboard true/false All videos
lividLogo true/false livid_logo. Pro/Premium.
title true/false Pro/Premium
share true/false Pro/Premium
speed true/false Pro/Premium
qualitySelector true/false quality_selector. Pro/Premium.
minQuality 240p–4k min_quality. Pro/Premium.
maxQuality 240p–4k max_quality. Pro/Premium.
initialQuality 240p–4k initial_quality. Pro/Premium.
quality 240p–4k Pro/Premium
progressBar true/false progress_bar. Pro/Premium.
timeDisplay true/false time_display. Pro/Premium.
volume true/false Pro/Premium
cc true/false Closed captions. Pro/Premium.
chromecast true/false Pro/Premium
airplay true/false Safari only. Pro/Premium.
playButtonPosition auto/bottom/center play_button_position. Pro/Premium.
transparent true/false All videos
customLogo true/false custom_logo. Pro/Premium.