Nx + Next.js + TypeScript starter for exporting Markdown content to PDF without writing custom Markdown parsing logic.
- Nx workspace
- Next.js (App Router)
- TypeScript
md-to-pdffor Markdown → PDF rendering
- UI page:
apps/web/src/app/page.tsx- Paste Markdown
- Click Export PDF
- API route:
apps/web/src/app/api/export-pdf/route.ts- Accepts
{ markdown: string } - Generates PDF using
md-to-pdf - Returns downloadable PDF bytes
- Accepts
npm install
npx nx serve webOpen: http://localhost:4200
POST /api/export-pdf
Request body:
{
"markdown": "# Hello\n\nThis will become a PDF."
}Response:
200 application/pdfon success- JSON error on failure
- The API route runs with
runtime = 'nodejs'. - Puppeteer launch flags include
--no-sandboxfor server compatibility. - If deployment platform blocks Chromium, use a platform-supported browser runtime.