pipedog is an unofficial community port of Pipecat, not affiliated with Daily.
pipedog

Next.js

Mount the pipedog WebRTC offer endpoint in a Next.js route handler on the Node.js runtime.

An App Router route handler handles POST /api/offer on the Node.js runtime. It passes the web Request to offer unchanged.

Install

bun add @pipedog/core @pipedog/asyncio @pipedog/transport-smallwebrtc @pipedog/transport-websocket @pipedog/serializer-protobuf @pipedog/openai @pipedog/audio-silero @pipedog/audio-smart-turn

@pipedog/audio-smart-turn isn't imported anywhere: the default turn strategies load it. To run the snippet from a checkout instead, see Installation.

Files

The endpoints come from the shared module on the overview. @/lib/voice re-exports it:

lib/voice.ts
export { offer, runSocketAgent, socket } from "../../shared/voice.ts";
app/api/offer/route.ts
import { offer } from "@/lib/voice";

// The Node.js runtime, not the edge: the media runs over UDP, and the server has
// to stay up for the call.
export const runtime = "nodejs";

export const POST = (request: Request) => offer(request);

Run it

OPENAI_API_KEY=sk-... bunx next dev

The browser then POSTs its SDP offer to /api/offer.

Deploy

The route sets runtime = "nodejs", not the edge, because the offer's media runs over UDP and the server has to stay up for the call. Run it with next start on a long-lived server. Vercel's serverless functions don't carry the UDP media.

WebSocket

A Next.js route handler can't upgrade a WebSocket. Mount socket on a server that can upgrade: a Bun, Node or Deno server next to the Next.js app, or Cloudflare Workers.

Authentication

The route has no auth. Wrap offer with a session check before it runs, as in Authentication.

pipedog is an unofficial community TypeScript port of Pipecat. It is not affiliated with or endorsed by Daily or the Pipecat project.

Portions adapted from the Pipecat documentation, Copyright (c) 2024–2025 Daily, BSD-2-Clause (see apps/docs/LICENSE-pipecat-docs).

On this page