http://localhost:3456.
| Flag | Default | Description |
|---|---|---|
--port | 3456 | Port for the dev server |
--open | — | Open browser automatically |
--mode | — | Load additional .env.[mode] files |
How it works
The dev server runs inside your project context:- Your dependencies work — import dayjs, lodash, or any package from
node_modules - Your path aliases work —
@/components/...resolves from yourtsconfig.json - Isolated Tailwind styles —
pdfn-templates/styles.cssis auto-detected, separate from your app’s styles
.tsx files in your templates directory with zoom controls (fit-to-window or 100%).
Template directory
By default, pdfn looks for templates inpdfn-templates/ at your project root:
.tsx files appear in the preview sidebar. Files are excluded if they:
- Are inside subdirectories (e.g.,
components/Header.tsx) - Start with
_(e.g.,_utils.tsx,_shared.tsx)
PreviewProps for dev preview
Templates use a staticPreviewProps property to provide sample data for the dev server preview:
pdfn-templates/invoice.tsx
Production usage
In production, pass actual data as props when callinggenerate():
app/api/invoice/route.tsx
PreviewPropsis only used by the dev server (pdfn dev) for preview- In production, you pass props directly to the component like any React component
- Props are required in the interface, so TypeScript ensures you pass all necessary data
Debug overlays
You can enable visual overlays for grid, margins, headers, and page breaks to debug layout issues. See Generate & Render for all options.FAQ
How do I add sample data for preview?
How do I add sample data for preview?
Use the
PreviewProps static property on your template component. The dev server uses this data automatically. See PreviewProps for dev preview.How do I exclude files from the template list?
How do I exclude files from the template list?
Two options:
- Subdirectory: Put shared components in
pdfn-templates/components/ - Underscore prefix: Name files with
_prefix (e.g.,_utils.tsx,_shared.tsx)
What files are recognized as templates?
What files are recognized as templates?
A file appears in the preview sidebar if it:
- Is a
.tsxfile in the root ofpdfn-templates/ - Has a default export (component function)
- Imports
DocumentorPagefrom@pdfn/react - Does not start with
_
Why don't my images or fonts work in production?
Why don't my images or fonts work in production?
pdfn Cloud renders PDFs on remote servers that cannot access your local filesystem. Use absolute URLs for images and Google Fonts instead of local files. See Styling — Images and Styling — Fonts.