Lighthouse CI: Automate Performance Testing in CI/CD

Learn how to use @lhci/cli to automate Lighthouse audits on every commit. Prevent performance regressions, enforce budgets, and track metrics over time.
Harlan WiltonHarlan Wilton Published

Lighthouse CI (LHCI) is Google's official tool for running Lighthouse audits in continuous integration pipelines. It catches performance regressions before they reach production.

Current Version: LHCI 0.15.x uses Lighthouse 12.6.1. The PWA category was removed in Lighthouse 12 (May 2024). Lighthouse 13 is not yet supported as it requires Node 22.19+.

What is Lighthouse CI?

Lighthouse CI is a suite of tools that integrate Lighthouse into your CI/CD workflow:

  • @lhci/cli — Command-line tool for running audits (~2M monthly npm downloads)
  • @lhci/server — Optional server for storing historical data
  • GitHub App — Status checks on pull requests

Why Use Lighthouse CI?

83% of Fortune 500 companies have integrated automated performance testing into their CI/CD pipelines. Without it, regressions slip through:

  1. Developer fixes performance issues
  2. PR gets merged
  3. Next week, someone adds a 500KB image
  4. Performance tanks, nobody notices until users complain

LHCI solves this by running Lighthouse on every commit and failing builds that don't meet your standards.

Key Features

  • Regression prevention — Fail builds when Core Web Vitals like LCP, CLS, and TBT (proxy for INP) drop
  • Performance budgets — Set thresholds for scores and resource sizes
  • Historical tracking — Compare builds over time
  • Variance reduction — Run multiple times, use median results
  • GitHub integration — Status checks and PR comments

Quick Start

Install and run:

npm install -g @lhci/cli
lhci autorun --collect.url=https://example.com --upload.target=temporary-public-storage

Or with a config file (lighthouserc.js):

module.exports = {
  ci: {
    collect: {
      url: ['https://example.com/'],
    },
    upload: {
      target: 'temporary-public-storage',
    },
  },
}

Then run:

lhci autorun

How It Works

The lhci autorun command executes three steps:

  1. collect — Runs Lighthouse N times per URL
  2. assert — Checks results against budgets/assertions
  3. upload — Stores results (temporary storage, filesystem, or LHCI server)

Run lhci healthcheck --fatal separately to verify Chrome and config before autorun.

Results are saved to .lighthouseci/ locally.

What LHCI Measures

Lighthouse CI audits four categories on every run:

Each category gets a 0-100 score. Set thresholds in your config to block merges when scores drop.

How scores map to percentiles: A score of 50 means you're faster than 75% of sites. A score of 90 puts you in the top 8% of all websites. Currently, only 53% of origins pass all Core Web Vitals.

Prerequisites

  • Node.js 18+
  • Chrome/Chromium installed
  • A URL to test (can be localhost with startServerCommand)

Tutorials

GitHub Actions

Set up LHCI with GitHub Actions and status checks.

GitLab CI

Configure LHCI for GitLab CI/CD pipelines.

Configuration

All lighthouserc.js options explained.

Performance Budgets

Set and enforce performance thresholds.

LHCI Server

Self-host a dashboard for historical tracking.

Troubleshooting

Fix common LHCI issues.

Performance Impact

Why invest in performance testing? Research shows direct business impact:

Resources