Quick Start

Run your first visual regression test with Frontguard in under 5 minutes.

Quick Start

Get visual regression testing running in under 5 minutes.

Initialize Configuration

Run frontguard init in your project root. It auto-detects your framework (Next.js, Remix, SvelteKit, Nuxt, Astro) and generates a config file:

npx frontguard init

This creates frontguard.config.ts:

frontguard.config.ts
export default {
  version: 1,
  baseUrl: 'http://localhost:3000',

  discover: {
    startUrl: '/',
    maxDepth: 3,
    exclude: ['/admin/*', '/api/*'],
  },

  viewports: [375, 768, 1440],
  browsers: ['chromium'],
  threshold: 0.1,

  ignore: [
    { selector: '.dynamic-timestamp' },
  ],
};

Start Your Dev Server

Frontguard needs a running application to screenshot:

npm run dev

Make sure your app is accessible at the baseUrl defined in your config.

Capture Baselines

Your first run captures baseline screenshots โ€” the "known good" state of your application:

npx frontguard run --url http://localhost:3000

Since there are no existing baselines, all pages are marked as NEW and saved automatically.

 frontguard v0.1.0

 ๐Ÿ” Discovering routes... found 12 routes
 ๐Ÿ–ฅ  Rendering 12 routes ร— 3 viewports

 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  RESULTS                        12 routes
 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  โ˜… /                375  768  1440   NEW
  โ˜… /about           375  768  1440   NEW
  โ˜… /pricing         375  768  1440   NEW
 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

  0 regressions ยท 0 warnings ยท 0 passed ยท 12 new

Make Changes and Re-run

Now make a CSS or layout change in your code, then run Frontguard again:

npx frontguard run --url http://localhost:3000

Frontguard compares the new screenshots against your baselines and reports differences:

 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  RESULTS                        12 routes
 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  โœ“ /                375  768  1440   PASS
  โœ“ /about           375  768  1440   PASS
  โœ˜ /pricing         375  768  1440   REGRESSION
 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

  โœ˜ /pricing @ 375px
    AI: "Button width changed from 100% to auto,
         causing text truncation on mobile."
    Severity: ๐Ÿ”ด Critical (confidence: 94%)

  1 regression ยท 0 warnings ยท 11 passed ยท 0 new

Update Baselines

When changes are intentional, accept the new screenshots as baselines:

npx frontguard update-baselines

This replaces old baselines with the current screenshots. Future runs compare against this new state.

What Happens Under the Hood

  1. Route Discovery โ€” Frontguard crawls your app starting from the start URL, discovering all navigable pages
  2. Smart Filtering โ€” If a dependency graph is available, only pages affected by your changes are rendered
  3. Multi-Viewport Rendering โ€” Each route is captured at every configured viewport width using Playwright
  4. Pixel Diff โ€” Screenshots are compared against baselines using pixelmatch with SSIM fallback
  5. AI Analysis โ€” If configured, visual diffs are sent to GPT-4V or Claude for classification and explanation
  6. Reporting โ€” Results are output to console, JSON, HTML report, and optionally as a GitHub PR comment

The pipeline uses error boundaries at every stage. If one page fails to render, the rest still complete.

Add to Your Scripts

Add Frontguard to your package.json scripts for easy access:

package.json
{
  "scripts": {
    "test:visual": "frontguard run --url http://localhost:3000",
    "test:visual:update": "frontguard update-baselines"
  }
}

Next Steps

On this page