Skip to main content
The Lighthouse Node API gives you full programmatic control over audits, user flows, and report generation. Install the package first:
Node 22 (LTS) or later is required. Some CLI flags are not available in the Node API — pass configuration directly as the third argument instead.

lighthouse(url, flags, config, page)

The default export. Runs a full navigation audit against a URL and returns a RunnerResult.

Parameters

string
The URL to audit. Optional when running in auditMode.
object
default:"{}"
Runtime flags that override config settings. Common flags include port, output, onlyCategories, and logLevel. See Configuration reference for the full list.
object
A Lighthouse config object. If omitted, the default config (lighthouse:default) is used. See Configuration reference.
Puppeteer.Page
An existing Puppeteer Page instance. If provided, Lighthouse uses it directly instead of connecting via the port flag.

Return value

Returns Promise<LH.RunnerResult | undefined>.
object
required
The Lighthouse Result object. See Understanding results.
string | string[]
required
The formatted report string (HTML, JSON, or CSV). When multiple output formats are requested this is an array.
object
required
Raw artifacts collected during the run.

startFlow(page, options)

Creates a UserFlow instance to record multiple steps (navigations, timespans, snapshots) in sequence, then generate a single combined flow report.

Parameters

Return value

Returns Promise<UserFlow>. The UserFlow instance exposes .navigate(), .startTimespan(), .endTimespan(), .snapshot(), and .generateReport().
Performs a single navigation-based audit. This is the function lighthouse() calls internally.

Parameters

Return value

Returns Promise<LH.RunnerResult | undefined>.

startTimespan(page, options)

Begins a timespan audit that records user interactions between startTimespan and endTimespan. Use this to measure the performance impact of a specific interaction.

Parameters

Return value

Returns Promise<{endTimespan: () => Promise<LH.RunnerResult | undefined>}>.

snapshot(page, options)

Audits the current state of the page without navigating. Useful for auditing the state of a single-page application after user interaction.

Parameters

Return value

Returns Promise<LH.RunnerResult | undefined>.

generateReport(result, format)

Converts a Lighthouse result or flow result object to a formatted report string.

Parameters

Return value

Returns string.

auditFlowArtifacts(flowArtifacts, config)

Re-audits previously collected flow artifacts against an optional config. Useful when you want to change scoring or audits without re-running the browser.

Parameters

Return value

Returns Promise<LH.FlowResult>.

getAuditList()

Returns an array of all available built-in audit IDs.

Return value

Returns string[].

Base classes

Audit

The base class for all Lighthouse audits. Extend this to create custom audits.

Gatherer

The base class for all Lighthouse gatherers. Extend this to collect custom artifacts.

Computed artifact

NetworkRecords

A computed artifact that parses devtools log entries into structured network request objects. Useful when writing custom audits that need network data.

Built-in configs


traceCategories

An array of Chrome trace category strings that Lighthouse requires for its audits. Pass these to your own tracing setup if you collect traces externally.