Skip to main content

Generate PDFs in Next.js

This guide shows you how to add PDF generation to a Next.js application using Deckle.

1. Install the SDK

2. Set Up Environment Variables

Add your API key to .env.local:

3. Create an API Route

Create a server-side API route to generate PDFs. Never expose your API key to the client.

4. Call from the Client

5. Use Templates for Complex Layouts

For production invoices, use templates: