Skip to main content

Lighthouse CI

Run Google Lighthouse on every commit. Lighthouse CI integrates web performance audits into your CI/CD pipeline, enforces Core Web Vitals budgets, and fails the build when performance regressions are detected — before they reach production.

✓ Performance budgets in CI ✓ Core Web Vitals enforcement ✓ GitHub PR status checks ✓ Historical trend tracking

What is Lighthouse CI?

Lighthouse CI (@lhci/cli) is the official open-source tooling for running Google Lighthouse in automated environments. While Lighthouse itself is a browser audit tool that measures performance, accessibility, SEO, and best practices, Lighthouse CI wraps it for CI pipelines — handling multi-run averaging, threshold assertions, and result storage.

By adding Lighthouse CI to your workflow, you get a hard gate on performance: if LCP exceeds 2.5s or CLS exceeds 0.1, the build fails and the PR is blocked. This makes performance a first-class engineering constraint, not an afterthought.

Key Features

Installation

# Install globally or as dev dependency
npm install -g @lhci/cli
# or
npm install --save-dev @lhci/cli

# Verify
lhci --version

Configuration (lighthouserc.js)

# lighthouserc.js
module.exports = {
  ci: {
    collect: {
      url: ['https://example.com/', 'https://example.com/about'],
      numberOfRuns: 3,
    },
    assert: {
      assertions: {
        'categories:performance': ['error', { minScore: 0.9 }],
        'categories:accessibility': ['warn', { minScore: 0.9 }],
        'first-contentful-paint': ['error', { maxNumericValue: 2000 }],
        'largest-contentful-paint': ['error', { maxNumericValue: 2500 }],
        'cumulative-layout-shift': ['error', { maxNumericValue: 0.1 }],
        'total-blocking-time': ['warn', { maxNumericValue: 300 }],
      },
    },
    upload: {
      target: 'temporary-public-storage',
    },
  },
};

GitHub Actions Integration

# .github/workflows/lighthouse.yml
name: Lighthouse CI
on: [push]

jobs:
  lhci:
    name: Lighthouse
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npm run build
      - name: Run Lighthouse CI
        run: |
          npm install -g @lhci/[email protected]
          lhci autorun
        env:
          LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}

Core Web Vitals Thresholds

Metric Good Needs Improvement Poor
LCP (Largest Contentful Paint)≤ 2.5s2.5s – 4s> 4s
INP (Interaction to Next Paint)≤ 200ms200ms – 500ms> 500ms
CLS (Cumulative Layout Shift)≤ 0.10.1 – 0.25> 0.25
FCP (First Contentful Paint)≤ 1.8s1.8s – 3s> 3s

Self-Hosted LHCI Server

# Run via Docker
docker run -p 9001:9001 patrickhulce/lhci-server

# Or install and run with Node.js
npm install -g @lhci/server
lhci server --storage.storageMethod=sql \
  --storage.sqlDialect=sqlite \
  --storage.sqlDatabasePath=./lhci.db

Point your upload.serverBaseUrl to the server address. The server provides a web UI for browsing historical Lighthouse reports and performance trend charts.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →