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.
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
- Threshold assertions — fail CI on any Lighthouse metric exceeding your budget (score, numeric, or both)
- Multi-URL support — audit multiple pages per build (homepage, product page, checkout flow)
- Statistical accuracy — run N times, use median to smooth out variance
- GitHub integration — post pass/fail status checks directly on pull requests
- Result storage — temporary public storage, self-hosted LHCI server, or custom webhook
- Dashboard — self-hosted server includes a UI for browsing historical results and diffs
- Puppeteer scripts — test authenticated pages, SPAs, and custom interactions
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.5s | 2.5s – 4s | > 4s |
| INP (Interaction to Next Paint) | ≤ 200ms | 200ms – 500ms | > 500ms |
| CLS (Cumulative Layout Shift) | ≤ 0.1 | 0.1 – 0.25 | > 0.25 |
| FCP (First Contentful Paint) | ≤ 1.8s | 1.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.
Related Products
on GumroadDeveloper Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad →AI Prompt Engineering Toolkit
58 structured prompt templates for Claude, ChatGPT, and Gemini — organized by use case. Code Review, Debugging, Documentation, Architecture, and 10 model-specific tips. Stop writing prompts from scratch.
Buy on Gumroad →Developer Cheat Sheet Bundle
10 print-ready cheat sheets for the tools developers use every day: Git, Docker, Linux CLI, SQL, Regex, HTTP Status codes, VS Code shortcuts, Bash scripting, jq/JSON, and Markdown.
Buy on Gumroad →You Might Also Need
JSON Formatter & Validator
Format, beautify, and validate JSON online. Paste your JSON to instantly pretty-print it with 2-space, 4-space, or tab indentation. Minify JSON too. Free, runs in your browser.
Open free tool →
Regex Tester
Free regex tester. Test regular expressions against multiple strings with expected match/no-match assertions — see instant pass/fail results. Built-in presets for email, URL, IPv4, and phone. Pro: unl
Open free tool →
Base64 Encoder & Decoder
Free Base64 Encoder & Decoder. Convert text, images, and any file to Base64 and back. Supports URL-safe Base64, image data URIs, and file download from Base64. Runs 100% in your browser — no data sent
Open free tool →
More Free Tools
Related Articles
curl 深度使用手冊:API 測試從入門到進階
curl 是每位開發者必備的 CLI 工具。本文涵蓋 GET/POST/PUT/DELETE 請求、認證、header 設定、檔案上傳、除錯技巧,以及 REST API 測試的完整實戰範例。
Best AI Code Review Tools 2026: CodeRabbit, Sourcery, DeepCode & Bito Compared
Compare top AI code review tools for 2026: CodeRabbit, Sourcery, DeepCode, and Bito. Features, pricing, GitHub/GitLab integration, and choosing the right tool for your team.
AI Code Review Tools 2026: GitHub Copilot, CodeRabbit, Qodo Merge Ranked
Compare AI code review tools for 2026: GitHub Copilot code review, CodeRabbit, Qodo Merge, Sourcery, and PR-Agent. Pricing, accuracy, and GitHub integration.
AI Coding Tools Comparison 2026: GitHub Copilot vs Cursor vs Windsurf vs Cline
Comprehensive comparison of the best AI coding tools in 2026: GitHub Copilot, Cursor, Windsurf, and Cline. Pricing, features, model support, and real-world benchmarks.
AI Pair Programming in 2026: GitHub Copilot vs Cursor vs Claude Code
Master AI pair programming in 2026. Compare GitHub Copilot, Cursor, and Claude Code for autocomplete, chat, and agentic workflows. Includes setup guides and productivity tips.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$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.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →