Next.js Discord

Discord Forum

Generating PDF on route handler

Answered
Australian Freshwater Crocodile posted this in #help-forum
Open in Discord
Australian Freshwater CrocodileOP
I have a project where I have a form and fill out some data, then i submit it to /submit and in my route.ts i need to create and email a pdf of what was in the form. I have it working locally with Puppeteer and it works great but when I deploy it to Vercel, it can't find Chrome.. ok.. I tried using chrome-aws-lambda to supply the Chrome package but that resulted in the serverless function exceeding the 50mb limit. How would you guys do this? What are my options here? Any help would be greatly appreciated. TIA.
Answered by Australian Freshwater Crocodile
Thanks!! I ended up using browserless.io to handle the chrome part for me, seems to be working pretty well. just had to make it use my local version of chrome when the NODE_ENV is development to keep the api requests from piling up while i test things
View full answer

8 Replies

Maybe something like this?
if you're using pupetter or playwright or a similar approach
by leveraging the browser
that stuff most likely wont run on vercel due to the lambda size limit
If you're attached to that approach, spin up your nextjs app on fly.io or ec2 or railway
and delegate expensive tasks to it
Australian Freshwater CrocodileOP
Thanks!! I ended up using browserless.io to handle the chrome part for me, seems to be working pretty well. just had to make it use my local version of chrome when the NODE_ENV is development to keep the api requests from piling up while i test things
Answer