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
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.Next steps
Components
Document, Page, and layout components
Styling
Tailwind CSS, custom CSS, and inline styles
Self-Hosting
Run PDF generation on your own infrastructure