
The reason we're able to get puppeteer and Chrome working on Vercel is by avoiding having to download and run Chrome inside of our Vercel app. Making puppeteer work on Vercel with browserless After that we simply connect to a live browser on browserless, create a page, and generate that PDF. If it's missing we'll return a 400 message and a response indicating that it's required. This handler will check to see if there's a "?url" query-parameter for the site to convert to a PDF. Since our handler can convert any URL into a PDF we need to make sure users supply one! Feel free to alter this block to fit your use-case or needs with puppeteer.įinally we have our route file. Next is a "Json" type to describe our responses back to the client. The typings aren't required if you're using plain NodeJS, so feel free to delete those in that case. To get started we import some type information for NextJS and then import the puppeteer module from puppeteer-core. To get started, create a new Next.js application through the CLI:Įnter fullscreen mode Exit fullscreen mode Feel free to alter this, but it'll be enough to get you started! For the purpose of this blogpost we'll create a basic route that generates a PDF of a URL.


Below we detail how you can get around these issues easily with browserless. When done locally this is a pretty straightforward task, however, you'll likely run into a few issues regarding bundle size and memory limits once you deploy your project to Vercel’s cloud. As of version 19, Puppeteer supports both Firefox and Chrome.Ĭombining these technologies is the task for today! We’ll use Puppeteer to generate a PDF of a website and Vercel.JS to host it. Puppeteer is a NodeJS library that allows developers to programmatically control a web-browser. For the purposes of this post, however, we’ll be mostly focusing on NextJS. At the time of this writing, Vercel powers more than 35+ frameworks. Vercel is the platform for frontend developers, providing the speed and reliability innovators need to create at the moment of inspiration.
