Skip to content

About

Compare Chrome UX Report field data for multiple origins or URLs

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Repository files navigation

CrUX Compare

A web tool for comparing Chrome UX Report (CrUX) field data across multiple origins or URLs. Built with Astro and Svelte 5.

Live tool: crux.gotomi.info

Features

  • Multi-URL comparison — analyze up to 10 origins/URLs side by side, sorted by Core Web Vitals performance
  • Overview tab — the classic CrUX metrics (LCP, CLS, INP, TTFB, FCP, RTT) as a summary table with trend badges against a selectable comparison week (default: 1 week earlier) plus per-metric cards with histogram bars
  • Advanced tab — kruk's newer CrUX metrics:
    • Navigation Types — how page loads start (navigate, reload, back/forward incl. bfcache, prerender) as 100% stacked bars
    • Form Factors — desktop / phone / tablet share of page loads (available when the device filter is ALL_FORM_FACTORS)
    • LCP Resource Type — image vs text LCP element
    • LCP Image Phases — p75 breakdown in ms: time to first byte, resource load delay, load duration, element render delay
  • History mode — 25-week CrUX History trends with sparklines and weekly rank strips (Overview tab; the Advanced tab is a follow-up)
  • Experimental metrics — enable the experimental checkbox to include kruk 0.8.0's experimental metrics:
    • Soft-navigation CWV — LCP-SN, CLS-SN, INP-SN, FCP-SN: the Core Web Vitals variants that include soft navigations reported by SPA sites, with the same thresholds as the stable metrics. Shown as extra summary-table columns and metric sections (also in history mode)
    • Soft-navigation navigation types — NAV_TYPES-SN: navigation-type shares including soft navigations, shown as a stacked-bar section in the Advanced tab
    • Ad metrics — AD-COUNT, AD-DENSITY, AD-CPU, AD-KB (p75 only, no thresholds) in the Advanced tab
  • Shareable state — all form options and the active tab persist in the URL (?url=…&history&experimental&view=advanced)

Tech Stack

  • Astro (SSR, Cloudflare Workers adapter) + Svelte 5 (runes)
  • kruk 0.8.0 — CrUX API client via fetch (classic + advanced + experimental metrics, History API)

Getting Started

1. Install

git clone git@github.com:gotomi/crux-compare.git
cd crux-compare
npm install

2. Configure

Create .env in the project root:

PSIKUS=your_crux_api_key

3. Run

npm run dev

Usage

  1. Enter one or more URLs, toggle origin to compare origins instead of full pages, pick a device filter, optionally enable history and experimental
  2. Switch between the Overview and Advanced tabs above the results — the active tab is stored in the URL
  3. The Advanced tab requires no extra setup: the new metrics are fetched in the same CrUX request as the classic ones
  4. With experimental on, origins without soft-navigation or ad traffic simply omit those columns and sections

API

POST /api/getCrux

Form-encoded body: url (repeatable), checkOrigin, formFactor, history, experimental. Returns { cruxData, byMetric, advanced } for a normal query — raw records, the grouped classic metrics, and the grouped advanced metrics. With experimental, the soft-navigation CWV variants join byMetric, while NAV_TYPES-SN and the ad metrics join advanced.

With history, the endpoint returns { cruxData, byMetric, warnings? }; the Advanced tab is not available in history mode. The history request only fetches stable metrics plus experimental soft-navigation CWV variants, not the advanced/ad metrics.

Project Structure

src/
├── components/
│   ├── CruxApp.svelte          # form + results orchestrator, Overview/Advanced tabs
│   ├── AdvancedMetrics.svelte  # Advanced tab sections
│   ├── AdMetrics.svelte        # experimental ad metrics (p75 bars)
│   ├── FractionCard.svelte     # 100% stacked bars for fraction metrics
│   ├── LcpPhases.svelte        # LCP image phase breakdown
│   ├── UrlsByMetric.svelte     # Overview summary table + trend badges
│   ├── MetricsByUrl.svelte     # per-metric sections (mode switch)
│   ├── Metric.svelte           # standard metric card
│   ├── MetricHistory.svelte    # history card with sparkline
│   ├── Legend.svelte           # metric thresholds legend
│   ├── Header.svelte           # collection period summary line
│   ├── SavedQueries.svelte     # saved queries drawer
│   ├── UrlWithIcon.svelte      # favicon + URL
│   └── UiInput.svelte          # URL input with validation
├── lib/
│   ├── crux.ts                 # metric constants, converters, grouping
│   └── savedQueries.ts         # localStorage persistence
└── pages/
    ├── index.astro             # the page
    └── api/
        ├── getCrux.js          # CrUX proxy endpoint
        └── test.ts             # health check

Scripts

Command Description
npm run dev start the dev server
npm test run unit tests (Vitest)
npm run build production build (Cloudflare adapter)
npm run preview preview the production build
npm run lint / lint:fix Biome lint
npm run format / format:fix Biome format
npm run check / check:fix Biome check (lint + format)

Deployment

The app deploys to Cloudflare Workers (the project uses @astrojs/cloudflare; wrangler.jsonc holds the Worker settings).

npx wrangler login   # one-time OAuth login
npm run deploy       # astro build + wrangler deploy

Secrets are read from process.env and must be set once on Cloudflare:

npx wrangler secret put PSIKUS    # CrUX API key

For local development put them in .dev.vars (gitignored); astro dev, astro preview and wrangler dev pick them up automatically. The KV namespace for Astro sessions (SESSION) is provisioned automatically on first deploy.

About

Compare Chrome UX Report field data for multiple origins or URLs

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

⌂ 换网址