# @serverless-chrome/lambda

> Run headless Chrome/Chromium on AWS Lambda

Latest version **1.0.0-57.2** (published 2020-10-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @serverless-chrome/lambda
pnpm add @serverless-chrome/lambda
yarn add @serverless-chrome/lambda
bun add @serverless-chrome/lambda
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0-57.2 |
| Published | 2020-10-24 |
| First published | 2017-05-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 6.10 |
| Dependencies | 1 |
| Unpacked size | 34 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | yes |
| GitHub stars | 2887 |
| Author | Marco Lüthy |
| Maintainers | adieuadieu, botsimo |
| Keywords | serverless, chrome, chromium, headless, aws, lambda |

## Links

- npm: https://www.npmjs.com/package/@serverless-chrome/lambda
- Repository: https://github.com/adieuadieu/serverless-chrome
- Homepage: https://github.com/adieuadieu/serverless-chrome/tree/master/packages/lambda
- Issues: https://github.com/adieuadieu/serverless-chrome/issues
- npm.io page: https://npm.io/package/@serverless-chrome/lambda

## Dependencies (1)

- [extract-zip](https://npm.io/package/extract-zip.md) 1.6.6

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.0-57.2 (latest) — 2020-10-24
- 1.0.0-57.1 — 2020-10-24
- 1.0.0-57 — 2020-10-23
- 1.0.0-55 — 2018-09-06
- 1.0.0-54 — 2018-08-11
- 1.0.0-53 — 2018-08-03
- 1.0.0-52 — 2018-08-03
- 1.0.0-51 — 2018-07-27
- 1.0.0-50 — 2018-07-15
- 1.0.0-49 — 2018-06-15
- 1.0.0-48 — 2018-06-10
- 1.0.0-47 — 2018-06-01
- 1.0.0-46 — 2018-05-18
- 1.0.0-45 — 2018-05-16
- 1.0.0-44 — 2018-05-12
- … 31 more at https://npm.io/package/@serverless-chrome/lambda/versions

## README

# serverless-chrome/lambda

Standalone package to run Headless Chrome on AWS Lambda's Node.js (6.10+) runtime.

[![npm](https://img.shields.io/npm/v/@serverless-chrome/lambda.svg?style=flat-square)](https://www.npmjs.com/package/@serverless-chrome/lambda)


## Contents
1. [Installation](#installation)
1. [Setup](#setup)
1. [Local Development](#local-development)
1. [Framework Plugins](#framework-plugins)
1. [Specifying Chromium Channel](#specifying-chromium-channel)


## Installation
Install with yarn:

```bash
yarn add @serverless-chrome/lambda
```

Install with npm:

```bash
npm install --save @serverless-chrome/lambda
```

If you wish to develop locally, you also need to install `chrome-launcher`:

```bash
npm install --save-dev chrome-launcher
```


## Setup

Use in your AWS Lambda function. Requires Node 6.10.


```js
const launchChrome = require('@serverless-chrome/lambda')
const CDP = require('chrome-remote-interface')

module.exports.handler = function handler (event, context, callback) {
  launchChrome({
    flags: ['--window-size=1280,1696', '--hide-scrollbars']
  })
  .then((chrome) => {
    // Chrome is now running on localhost:9222

    CDP.Version()
      .then((versionInfo) => {
        callback(null, {
          versionInfo,
        })
      })
      .catch((error) => {
        callback(error)
      })
  })
  // Chrome didn't launch correctly 😢
  .catch(callback)
}
```


## Local Development

Local development is supported. In a non-lambda environment, the package will use chrome-launcher to launch a locally installed Chrome. You can also pass your own `chromePath`:

```js
launchChrome({ chromePath: '/my/local/chrome/path' })
```

**Command line flags (or "switches")**

The behavior of Chrome does vary between platforms. It may be necessary to experiment with flags to get the results you desire. On Lambda [default flags](/packages/lambda/src/flags.js) are used, but in development no default flags are used.

The package has zero external dependencies required for inclusion in your Lambda function's package.


## Framework Plugins

There are plugins which bundle this package for easy deployment available for the following "serverless" frameworks:

- [serverless-plugin-chrome](/packages/serverless-plugin)


## Specifying Chromium Channel

This package will use the latest stable-channel build of Headless Chromium for AWS Lambda. To select a different channel (beta or dev), export either an environment variable `NPM_CONFIG_CHROMIUM_CHANNEL` or add `chromiumChannel` to the `config` section of your `package.json`:

Your `package.json`:

```json
{
  "name": "my-cool-project",
  "version": "1.0.0",
  "config": {
    "chromiumChannel": "dev"  <-- here
  },
  "scripts": {

  },
  "description": {

  }
}
```

Note: the `dev` channel is _almost_ `canary`, so use `dev` if you're looking for the Canary channel.

You can skip download entirely with `NPM_CONFIG_SERVERLESS_CHROME_SKIP_DOWNLOAD` or setting `skip_download` in the `config` section of your `package.json`

_Caution_: We test and develop features against the stable channel. Using the beta or dev channel versions of Chromium may lead to unexpected results, especially in relation to the [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/tot/Emulation/) (which is used by tools like Chromeless and Puppeteer).

---
_Source: https://npm.io/package/@serverless-chrome/lambda · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
