Skip to content
Latchkey

lhci autorun: Run Lighthouse CI End to End

lhci autorun runs Lighthouse against your URLs, applies assertions, and uploads the reports, all driven by a lighthouserc config file.

Lighthouse CI measures performance, accessibility, and best-practice scores per build. lhci autorun chains the collect, assert, and upload phases so one command runs the whole flow in CI.

What it does

lhci autorun reads lighthouserc.js (or .json), starts a static server or uses startServerCommand, collects Lighthouse runs for each URL, evaluates the assertions, and uploads results to the configured target (temporary-public-storage or an LHCI server). It exits non-zero if assertions fail.

Common usage

Terminal
lhci autorun
# lighthouserc.json
# {
#   "ci": {
#     "collect": { "url": ["http://localhost:3000/"], "numberOfRuns": 3 },
#     "assert": { "preset": "lighthouse:recommended" },
#     "upload": { "target": "temporary-public-storage" }
#   }
# }

Options

Config / flagWhat it does
collect.urlURLs to audit
collect.startServerCommandCommand to boot the app before collecting
collect.numberOfRunsRuns per URL (median is used)
assert.presetlighthouse:recommended or no-pwa
upload.targettemporary-public-storage or lhci-server
--config <file>Path to a non-default rc file

In CI

Use numberOfRuns of 3 or more and let Lighthouse take the median; a single run is noisy and produces flaky gates. For an LHCI server upload, supply the server URL and LHCI_TOKEN (build token) from CI secrets so historical comparisons work.

Common errors in CI

"Unable to determine the URL to run Lighthouse against" means neither collect.url nor a static server was configured. "No Chrome installations found" / "ChromeLauncher ... ENOENT" means Chrome is missing on the runner; install it or use a Lighthouse CI action that bundles it. "Error: Assertions failed" with a count is the gate working: a score or metric missed its threshold and the job exits non-zero.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →