Skip to main content
The Lighthouse Node module gives you full programmatic control over audits. Use it to integrate Lighthouse into build scripts, test suites, or custom reporting pipelines.
Chrome must be installed on the machine running Lighthouse. The chrome-launcher package handles launching and connecting to it automatically.
1

Install dependencies

Install lighthouse and chrome-launcher as dev dependencies.
2

Write your first script

The following example launches a headless Chrome instance, runs a Lighthouse audit, saves an HTML report, and prints the performance score.
audit.js
Run it with:
3

Access the report and result object

The lighthouse() function returns a RunnerResult with two key properties:Access category scores and individual audit results directly from .lhr:
4

Run performance-only audits

Pass onlyCategories in the options object to limit which audit categories run. This reduces run time significantly when you only need specific data.
You can also pass multiple categories:

Configuration

Pass a config object as the third argument to lighthouse() to customize audits beyond what flags allow:
Extend lighthouse:default to build on the standard configuration, or omit it to start from scratch. See Configuration overview for all available options, and Node API reference for the full API surface.