# Embed vid2context on your site

Any page can show what vid2context knows about a video: the transcript with timestamps, the chapters, a quoted passage with its time, or a small card. The widget is a page on this site, `/embed/`, made to live in an iframe. It reads its options from the address, fetches the video's context from the API, and renders it in your theme. Nothing to install and no key.

There are three ways to embed it:

- **An iframe.** Paste the HTML. Works anywhere that accepts an iframe: WordPress, Notion, Ghost, Webflow, plain HTML.
- **The web component.** Add `/embed.js` once, then write `<vid2context-embed url="...">`. It sizes itself to its content, turns the widget's messages into DOM events, and has `seek()`, `search()` and `load()` methods.
- **A link.** Where iframes are not allowed (a GitHub README, an email), link to the widget address. It works as a page on its own.

## Build an embed

Change any option and the preview, the widget address and the code update at once. The preview is the real widget, so clicking a line in it sends the events listed under it, and the buttons under **Drive it from the page** send the commands your page can send. **Copy link to this setup** gives you an address that reopens the builder with the same options.

The interactive embed builder runs on the HTML version of this page. The snippet it starts with:

```html
<iframe
  src="https://vid2context.com/embed/?sample=zoo"
  title="Video transcript by vid2context"
  width="100%" height="480"
  style="border:0;border-radius:12px;max-width:720px"
  loading="lazy"
></iframe>
```
The builder starts from a recorded sample, so the preview works without calling the API. Switch the source to **Video URL** to try a real video: the widget then calls `GET /api/v1/context` on this site. YouTube sometimes blocks cloud servers; when a video fails here, the widget shows the error and a link to the app, and the same embed pointed at your own server (the `api` option) will usually work.

## What each view looks like

These are live widgets, each one an iframe with the snippet under it.

### Transcript

Searchable, with chapters as a second tab. Click a line to get a segment event.

```html
<iframe
  src="https://vid2context.com/embed/?sample=zoo"
  title="Video transcript by vid2context"
  width="100%" height="480"
  style="border:0;border-radius:12px;max-width:720px"
  loading="lazy"
></iframe>
```

### Chapters

Only the chapter list, each one a link to that moment.

```html
<iframe
  src="https://vid2context.com/embed/?sample=zoo&amp;view=chapters&amp;tools=0"
  title="Video chapters by vid2context"
  width="100%" height="360"
  style="border:0;border-radius:12px;max-width:720px"
  loading="lazy"
></iframe>
```

### Quote

The lines between start and end, with a timed citation.

```html
<iframe
  src="https://vid2context.com/embed/?sample=zoo&amp;view=quote&amp;start=5&amp;end=13"
  title="Video quote by vid2context"
  width="100%" height="240"
  style="border:0;border-radius:12px;max-width:720px"
  loading="lazy"
></iframe>
```

### Card

Title, thumbnail and chapters, with a button to the full transcript. Loads the thumbnail from YouTube.

```html
<iframe
  src="https://vid2context.com/embed/?sample=zoo&amp;view=card"
  title="Video summary by vid2context"
  width="100%" height="420"
  style="border:0;border-radius:12px;max-width:720px"
  loading="lazy"
></iframe>
```

### Link box

A small form that opens any video in the vid2context app. Needs no video.

```html
<iframe
  src="https://vid2context.com/embed/?view=input"
  title="Get video context with vid2context"
  width="100%" height="120"
  style="border:0;border-radius:12px;max-width:720px"
  loading="lazy"
></iframe>
```
## How it works

1. The iframe loads `/embed/?url=<video>` from this site (or from your own deployment).
2. The widget calls `GET /api/v1/context` on the same server, so no CORS setup is needed. With `sample` it reads a recorded file instead, and with `src` it reads a VideoContext JSON you host.
3. It renders the view with the text set as plain text, never as HTML, and posts `ready`, `loaded` and `resize` messages to your page.
4. Clicks post `segment` messages. With `player=1` on a YouTube video, the widget also follows playback and posts `seek` as the current line changes.

The widget makes no third-party request unless you ask for one: `player=1` loads the YouTube player from `youtube-nocookie.com`, and the card view loads the video's thumbnail.

## Next

- [Embed parameters](https://vid2context.com/docs/embed/parameters.md): Every option of the vid2context embed widget, as a query parameter of /embed/ or an attribute of vid2context-embed, with defaults, accepted values and examples.
- [The web component and postMessage API](https://vid2context.com/docs/embed/javascript.md): Use the vid2context-embed element and Vid2Context.embed(), listen for loaded, segment and seek events, and drive the widget with seek, search, theme and load commands over postMessage.
- [Embed in WordPress, Notion, React and more](https://vid2context.com/docs/embed/platforms.md): Step-by-step embedding of the vid2context widget in WordPress, Notion, Ghost, Webflow, Squarespace, React, Next.js, Vue, Svelte, Docusaurus and Markdown, plus serving the widget from your own deployment.
