This project is a serverless PDF generator built with SST, Puppeteer, and Hono. It creates PDFs from HTML/JSX templates and stores them in an S3 bucket, providing a signed URL for downloading the generated PDF.
- Serverless architecture using SST
- PDF generation with Puppeteer
- API built with Hono
- S3 storage for generated PDFs
- Customizable HTML/JSX templates
To install dependencies:
bun install
To run:
bun sst dev
This command starts the SST development environment, allowing you to test and debug your application locally.
src/index.tsx
: Hono API handlersst.config.ts
: SST configuration file
- The application exposes a GET endpoint at the root ("/").
- When a request is made, it accepts an optional "name" query parameter.
- An HTML template is generated using the provided name (or "world" if no name is given).
- Puppeteer is used to create a PDF from the HTML/JSX template.
- The generated PDF is uploaded to an S3 bucket.
- A signed URL for the PDF is generated and returned in the response.
Make a GET request to the root endpoint:
GET /?name=John
Response:
{
"success": true,
"url": "https://your-signed-s3-url.com/path/to/pdf"
}
You can customize the HTML/JSX template by modifying the Template component in src/index.tsx
.
To deploy the application to your AWS account:
bun sst deploy --stage production
For local development, the application uses a local Chromium executable. Make sure the path in LOCAL_EXECUTABLE_PATH is correct for your system. See this guide for more information.
This project was created using bun init
in bun v1.1.27. Bun is a fast all-in-one JavaScript runtime.