Analytics
docs
Plugin

Lighthouse Plugin

lighthousePlugin adds a full PageSpeed Insights / Lighthouse dashboard to Sanity Studio — auditing every page of your site and storing scores alongside your content.

Why this plugin?

Performance issues hurt SEO and conversions — but running Lighthouse manually for every page is slow. This plugin auto-discovers pages from your Sanity document types, runs PageSpeed Insights for mobile and desktop, and stores the scores directly in your dataset so your team can see them right in the Studio.

Features

Performance Scores

Performance

Core Web Vitals score (0–100) measuring load speed, interactivity, and visual stability.

Accessibility

Accessibility audit score — color contrast, ARIA labels, keyboard navigation.

Best Practices

Security, HTTPS, deprecated APIs, and browser compatibility checks.

Insights

Mobile & Desktop

Run audits for both strategies in parallel — see where mobile lags behind desktop.

SEO Score

Meta tags, structured data, crawlability — all checked in a single audit.

Per-Document

Automatically discovers URLs from your Sanity document types and maps reports back.

Platform

PageSpeed Insights

Powered by the Google PageSpeed Insights API — free, no Lighthouse CLI needed.

Persistent Storage

Reports stored as Sanity documents — compare across runs over time.

Full TypeScript

Exported types for all Lighthouse data structures and configuration.

Score Tiers

Each category (Performance, Accessibility, Best Practices, SEO) is scored 0–100. The dashboard color-codes results using Google's thresholds:

90–100Good
50–89Needs Improvement
0–49Poor

Quick Example

sanity.config.ts
import { defineConfig } from 'sanity'
import { lighthousePlugin } from 'sanity-plugin-analytics'

export default defineConfig({
  name: 'my-project',
  projectId: 'your-project-id',
  dataset: 'production',
  plugins: [
    lighthousePlugin({
      siteUrl: 'https://mysite.com',
      documentTypes: [
        { type: 'post', slugField: 'slug', pathPrefix: '/blog' },
        { type: 'page', slugField: 'slug' },
      ],
    }),
  ],
  schema: { types: [/* your schemas */] },
})

Use with Combined Plugin

Use sanityAnalyticsPlugin to register GA4, Search Console, and Lighthouse as a single unified tool in one Sanity toolbar entry:

sanity.config.ts
import { defineConfig } from 'sanity'
import { sanityAnalyticsPlugin } from 'sanity-plugin-analytics'

export default defineConfig({
  // ...
  plugins: [
    sanityAnalyticsPlugin({
      analytics: { apiUrl: '/api/analytics' },
      searchConsole: {},
      lighthouse: {
        siteUrl: 'https://mysite.com',
        documentTypes: [
          { type: 'post', slugField: 'slug', pathPrefix: '/blog' },
        ],
      },
    }),
  ],
})