Overview

Fast, no-browser YouTube transcript extraction for Node, serverless and Cloudflare Workers — with optional React components.

extract-youtube fetches the captions of any YouTube video straight from YouTube's own caption endpoints. There is no headless browser, no Puppeteer, and no YouTube Data API key — just fetch, which is why the same code runs in Node, Bun, AWS Lambda, Vercel Edge and Cloudflare Workers.

The package has three independent entry points:

Entry pointWhat it isPulls in React?
extract-youtubeThe transcript API, formatters, proxy configs and the CLINo
extract-youtube/libraryA video library with an admin API: in-memory or D1 storage, one HTTP handler, a typed clientNo
extract-youtube/reactA floating YouTube player, a synced-transcript modal, video grid and list components, and library admin screensYes (peer dependency)

Import only what you need; the rest never ends up in your bundle. Everything runs on Cloudflare Workers, and the live demo shows the library, the grid, the floating player and the admin screens together, on the same server as these docs.

Install

npm install extract-youtube

Or run it once without installing:

npx extract-youtube dQw4w9WgXcQ

For the React components, also install the peer dependencies:

npm install extract-youtube react react-dom lucide-react

Quick start

import { YouTubeTranscriptApi } from 'extract-youtube';

const api = new YouTubeTranscriptApi();
const transcript = await api.fetch('dQw4w9WgXcQ');

for (const snippet of transcript) {
  console.log(`${snippet.start}s: ${snippet.text}`);
}

Every snippet has text, start (seconds) and duration (seconds). transcript.toRawData() gives you the same as a plain array, ready for JSON.stringify.

What's in the box

Why this package

  • Proven approach. A TypeScript port of the widely used Python youtube-transcript-api caption-fetching logic.
  • Serverless-first. No filesystem access, no native modules, nothing that needs a Node-only socket — so it fits Lambda, Vercel Edge and Workers.
  • Typed end to end. Full TypeScript types and a typed error for every failure mode (TranscriptsDisabled, NoTranscriptFound, IpBlocked, …).
  • Small. ESM and CJS builds, tree-shakeable, a handful of small dependencies.

On this page