We cover installing Playwright, which will run the headless browser for us, in a way that doesn't also install unused browser bundles, reducing the size and allowing us to deploy it to netlify in a function. We also cover a set of Playwright APIs like page.setContent, page.evaluate, page.screenshot, and how to return a base64 encoded image from a lambda function. We also cover passing values from native browser functions like getBoundingClientRect back to our node script and fixing a few errors along the way.
Facing this error
{"errorType":"TypeError","errorMessage":"Cannot read property 'newPage' of undefined","trace":["TypeError: Cannot read property 'newPage' of undefined"," at Runtime.exports.handler (/var/task/src/functions/gen-opengraph-image/gen-opengraph-image.js:6:30)"]}
If your are getting an error while deploying to netlify because of the dependecies, install in the project main root folder (not the function one) the playwright dependencies, and try again