Embed Code

Embed Code is a copy-paste React component that stops embed leaked a private token before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/embed-code
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsEmbed leaked a private token

Was this component page useful?

How do I install Embed Code?

pnpm dlx shadcn@latest add @bollard/embed-code

The files land in your project. They're yours to edit.

How do I use Embed Code in React?

embed-code-usage.tsx
import { EmbedCode } from "@/components/ui/embed-code"

<EmbedCode
  resource={resource}
  defaultValue={{ allowedDomains: ["acme.dev"] }}
  renderPreview={() => (
    <div className="relative grid size-full place-items-center bg-linear-to-br from-zinc-800 to-zinc-950 text-white">
      <span className="grid size-10 place-items-center rounded-full bg-white/15">
        <Play aria-hidden className="size-4 fill-current" />
      </span>
      <span className="absolute bottom-2 left-3 text-xs font-medium text-white/80">{resource.title}</span>
    </div>
  )}
/>

What input mistakes does Embed Code catch?

  • Secrets in the embed URL (token=, sig= and similar)
  • Draft or private resources about to be embedded
  • Tracking the embed adds, with a privacy-mode option
  • Allowed-site entries that aren't valid domains

What props does Embed Code accept?

EmbedCode props
PropTypeDefault
resource* (required)

What is being embedded, and what it exposes.

EmbedResource—
value

Controlled embed options.

EmbedOptions—
defaultValue

Initial options when uncontrolled.

Partial<EmbedOptions>—
onValueChange

Called with the embed options whenever they change.

(options: EmbedOptions) => void—
onCopy

Called with the snippet after it is copied.

(snippet: string) => void—
renderPreview

Renders the live preview for a src. Defaults to a titled placeholder at the chosen size.

(src: string) => React.ReactNode—
labels

Override any visible label.

Partial<typeof DEFAULT_LABELS>—

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is Embed Code accessible?

  • Labelled options and allowed-domain field with aria-invalid and aria-describedby
  • Readback rows use icons plus text

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Scope embed tokens to read-only, short-lived access on the server, and enforce allowed origins with frame-ancestors.

  • Exposure and tracking come from the resource description you pass
  • Stripping a token may break an embed that genuinely needs it

What expensive mistakes does Embed Code stop?

Embed leaked a private token

Also known as

embed · iframe · embed code · youtube · privacy-enhanced · widget · share · token in url

What dependencies does Embed Code require?

Embed Code facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameEmbed Code
Registry identifier@bollard/embed-code
Install commandnpx shadcn@latest add @bollard/embed-code
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Embed Code

What form validation mistake does Embed Code catch?

Embed Code prevents embed leaked a private token. Reads back what an embed will show and track, and strips tokens from its URL, so an embed doesn't leak a private link or secret. Catches: Secrets in the embed URL (token=, sig= and similar), Draft or private resources about to be embedded, Tracking the embed adds, with a privacy-mode option, Allowed-site entries that aren't valid domains. Limitation: validate embed-code schemas on backend.

How do I install embed-code with shadcn?

Run `npx shadcn@latest add @bollard/embed-code`. Sources added: registry/default/embed-code/embed-code.tsx, registry/default/embed-code/embed-snippet.ts. Package requirements: lucide-react.

What props customize Embed Code?

Embed Code accepts `resource`, `value`, `defaultValue`, `onValueChange`, `onCopy`. Configures embed, iframe, embed code behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of embed-code?

Exposure and tracking come from the resource description you pass. Stripping a token may break an embed that genuinely needs it Server requirement: Scope embed tokens to read-only, short-lived access on the server, and enforce allowed origins with frame-ancestors.

How does Embed Code meet accessibility guidelines?

Labelled options and allowed-domain field with aria-invalid and aria-describedby. Readback rows use icons plus text. Minimizes errors: iframe embed leaks token, embed tracks visitors.

Which components pair with Embed Code?