Skip to content

Repository files navigation

playwright-aws-lambda

CINPM

Support for Playwright running on AWS Lambda and Google Cloud Functions.

NOTE: Currently only Chromium is supported.

Install

npm install playwright-core playwright-aws-lambda --save

Usage

This package works with the nodejs10.x, nodejs12.x, nodejs14.x, nodejs16.x, nodejs18.x and nodejs20.x AWS Lambda runtimes out of the box.

constplaywright=require('playwright-aws-lambda');exports.handler=async(event,context)=>{letbrowser=null;try{browser=awaitplaywright.launchChromium();constcontext=awaitbrowser.newContext();constpage=awaitcontext.newPage();awaitpage.goto(event.url||'https://example.com');console.log('Page title: ',awaitpage.title());}catch(error){throwerror;}finally{if(browser){awaitbrowser.close();}}};

API

Method / PropertyReturnsDescription
launchChromium{!Promise<playwright.ChromiumBrowser>}Launches the Chromium browser.
loadFont(url){Promise<void>}Downloads and activates a custom font

Loading additional fonts

If you need custom font support by e.g. emojicons in your browser, you have to load it by using the loadFont(url: string) function before you launch the browser.

awaitloadFont('https://raw.githack.com/googlei18n/noto-emoji/master/fonts/NotoColorEmoji.ttf');

Thanks / Credits

This project is based on the work of chrome-aws-lambda.

About

Support for running Microsoft's Playwright on AWS Lambda and Google Cloud Functions

Topics

Resources

Stars

429 stars

Watchers

13 watching

Forks

Releases

Packages

Used by

Contributors

Languages