import { VideoEmbed } from "@pixxl-tools/components";
// In Server Components:
import { VideoEmbed } from "@pixxl-tools/components/server";| Prop | Type | Default | Description |
|---|---|---|---|
fallbackHref (required) | string | — | — |
fallbackLabel (required) | ReactNode | — | — |
src (required) | string | — | https: embed URL on an allowed host; youtube.com / youtu.be links are rewritten to the privacy-enhanced youtube-nocookie.com player. |
title (required) | string | — | Title (any content). |
poster | ReactNode | — | Facade background: an image URL (decorative, alt="") or an element such as a framework image. Serve it from your own origin. |
allow | string | autoplay; encrypted-media; fullscreen; picture-in-picture | The iframe allow list (default autoplay; encrypted-media; fullscreen; picture-in-picture). |
allowedHosts | readonly string[] | DEFAULT_VIDEO_EMBED_HOSTS | Hosts the player may load from, exact match (default DEFAULT_VIDEO_EMBED_HOSTS: www.youtube-nocookie.com, player.vimeo.com). Other URLs render only the fallback link. Never list your own origin: a same-origin frame with allow-scripts allow-same-origin can remove its own sandbox. |
aspectRatio | string | — | — |
facade | boolean | false | Click-to-load (default false): show poster, the title and a Play button, and load the player only on press (with autoplay, focus moved into it). Nothing is requested from the video host before that, so a site can embed video before consent. aspectRatio is the minimum: the stage grows when the title and note need more room (long titles on phones) and keeps that height under the player. |
facadeNote | ReactNode | "Playing loads the video from {host}." | Text under the facade's Play button (default: "Playing loads the video from {host}."). null hides it. |
fallbackHrefrequiredstring
fallbackLabelrequiredReactNode
srcrequiredstring
https: embed URL on an allowed host; youtube.com / youtu.be links are rewritten to the privacy-enhanced youtube-nocookie.com player.
titlerequiredstring
Title (any content).
posterReactNode
Facade background: an image URL (decorative, alt="") or an element such as a framework image. Serve it from your own origin.
allowdefault autoplay; encrypted-media; fullscreen; picture-in-picturestring
The iframe allow list (default autoplay; encrypted-media; fullscreen; picture-in-picture).
allowedHostsdefault DEFAULT_VIDEO_EMBED_HOSTSreadonly string[]
Hosts the player may load from, exact match (default DEFAULT_VIDEO_EMBED_HOSTS: www.youtube-nocookie.com, player.vimeo.com). Other URLs render only the fallback link. Never list your own origin: a same-origin frame with allow-scripts allow-same-origin can remove its own sandbox.
aspectRatiostring
facadedefault falseboolean
Click-to-load (default false): show poster, the title and a Play button, and load the player only on press (with autoplay, focus moved into it). Nothing is requested from the video host before that, so a site can embed video before consent. aspectRatio is the minimum: the stage grows when the title and note need more room (long titles on phones) and keeps that height under the player.
facadeNotedefault "Playing loads the video from {host}."ReactNode
Text under the facade's Play button (default: "Playing loads the video from {host}."). null hides it.
Other props are passed to the root element (HTMLAttributes<HTMLElement>), including className, style, id and aria-* attributes.
const embedUrl = "https://www.youtube-nocookie.com/embed/VIDEO_ID";
const videoUrl = "https://www.youtube.com/watch?v=VIDEO_ID";
<VideoEmbed facade poster="/video-poster.jpg" src={embedUrl} title="Product walkthrough" fallbackHref={videoUrl} fallbackLabel="Watch video" />