Rendral

Stack · Next.js

Generate PDFs in Next.js

Bundling Puppeteer into a Next.js app deployed on Vercel doesn't work — Chromium is far larger than the function size limit, and the edge runtime can't launch a browser at all.

Instead, call the rendering API from a route handler and stream the PDF straight back to the client. No system dependencies, no cold-start browser launches.

01Call it from Next.js

render.ts
// app/api/invoice/route.ts
export async function GET() {
  const res = await fetch("https://rendral.com/api/v1/pdf", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.PDF_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ html: "<h1>Invoice</h1>", options: { pageNumbers: true } }),
  });
  return new Response(await res.arrayBuffer(), {
    headers: { "Content-Type": "application/pdf" },
  });
}

Frequently asked

Why not just use Puppeteer in Next.js?

On serverless hosts like Vercel, Chromium exceeds the function size limit and the edge runtime can't launch a browser. A hosted API sidesteps both.

Does this work with the App Router?

Yes — call the API from a route handler or a server action and return the bytes. The example above uses the App Router.

Is there a TypeScript SDK?

Yes — install the official Node/TypeScript client for typed methods instead of raw fetch.

Start rendering in minutes.

A free tier, five endpoints, and SDKs for Node and Python.