Why migrate
Puppeteer gives you low-level browser control, but you end up managing a lot yourself:- Installing and updating Chromium binaries (250MB+)
- Launching, reusing, and closing browser instances
- Writing and managing print-related CSS for pagination
- Working around Puppeteer’s limited header/footer API
- Debugging layout differences between local and production Chromium versions
| Puppeteer | pdfn | |
|---|---|---|
| Templates | HTML strings or template engines | React components |
| Pagination | Manual | Automatic |
| Headers / footers | Limited | Built-in with <PageNumber>, <TotalPages> |
| Dev workflow | No preview | Live preview with hot reload |
| Infrastructure | You manage Chromium, browser lifecycle, and deployment | Managed by pdfn Cloud (or self-host) |
| Dev / production parity | Varies by Chromium version | Identical output everywhere |
Step 1: Install
Add
@pdfn/tailwind for Tailwind CSS support, and @pdfn/next for Next.js. See the Quickstart for details.Step 2: Convert your templates
Replace HTML strings with React components using<Document> and <Page>:
- Before
- After
page.pdf() or writing @page CSS.
Step 3: Replace the generation code
- Before
- After
Step 4: Remove Puppeteer
If you prefer to keep running your own Chromium, use
client.render() instead of client.generate(). See Self-Hosting.