DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
FREEDOM251

Freedom251 › Blog › Chromatic

How to Use Chromatic with Vite and Storybook

By Freedom251 Team · · 7 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To use Chromatic with a Vite-based Storybook, keep Storybook’s Vite builder, add the official @chromatic-com/storybook addon, connect a Chromatic project, and publish a first build to create visual baselines. Review later differences before accepting them, then publish from CI—typically with a protected CHROMATIC_PROJECT_TOKEN secret. Storybook’s versioned documentation says the addon requires Storybook 7.6 or later; check the current instructions for your installed version before changing dependencies.

What Chromatic does in a Vite and Storybook workflow

Storybook’s Vite builder runs your stories using Vite and can reuse the Vite configuration already in your project. Chromatic builds and publishes that Storybook, captures story snapshots, and compares later snapshots with established baselines. This makes it useful for spotting visual changes to rendered components—such as layout, color, size, or contrast—during review.

As an Amazon Associate I earn from qualifying purchases.

Visual comparison is not a substitute for functional or accessibility tests. It checks rendered appearance; Storybook’s documentation also distinguishes pixel comparison from markup snapshots, which compare rendered HTML. Keep interaction, accessibility, and other tests for the behaviors they cover.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set up Storybook’s Vite builder

Check the existing project first

If Storybook is already initialized for your Vite application, the Vite builder may already be installed and configured. Storybook identifies its Vite builder as the default and recommends it for most projects. Avoid installing a second builder or copying Webpack-specific settings into a Vite configuration without confirming they apply.

Keep shared Vite settings in the project’s Vite config where practical. If Storybook needs a different adjustment, use the Storybook configuration file—usually .storybook/main.ts—and its viteFinal hook.

Point Storybook at a nonstandard Vite config when needed

If your Vite configuration is not at the expected project root, the builder supports a viteConfigPath option. Use it to identify the right file rather than duplicating the configuration. For project-specific changes, apply them through viteFinal in .storybook/main.ts or the corresponding JavaScript file. The exact configuration depends on your project; do not paste an unrelated Webpack configuration into a Vite project.

Add the Chromatic visual-testing addon

From the project root, run Storybook’s documented add-on command:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
npx storybook@latest add @chromatic-com/storybook

The installer can add the required integration and, after you select a Chromatic project, its identifiers. The versioned Storybook 8 documentation specifies Storybook 7.6 or higher for this addon. Because compatibility and setup instructions can vary with Storybook releases, verify the current documentation for the version in your project before upgrading or following version-specific steps.

Connect a Chromatic project and publish the first build

  1. Create or select a project: Sign in to Chromatic and create a project for the Storybook you intend to publish. Use its project identifier or token as required by the selected setup path.
  2. Finish the addon setup: Follow the installer prompts. The setup can add configuration and identifiers after you choose the project.
  3. Build and publish: Run the Chromatic CLI workflow for your project. It builds and uploads Storybook, then starts Chromatic’s publishing and testing workflow. Make sure the build uses the intended Storybook configuration and stories.
  4. Review the initial result: The first build captures story snapshots to establish baselines. Check the published Storybook’s visibility before sharing its link: Chromatic’s publishing documentation says logged-in collaborators have private access by default, with public visibility available as a setting.

The first publication is important because later comparisons use those snapshots as the reference. A baseline is not proof that every displayed state is correct; it is the appearance against which subsequent builds are evaluated.

Review changes and update baselines safely

  1. Open the build’s visual changes and inspect each affected story in context.
  2. If the difference is intended, accept it so the new appearance becomes the baseline.
  3. If it is unexpected, correct the component, styling, data, or story setup, then publish another build.
  4. Confirm accepted baselines are synchronized to the cloud so teammates and CI use the updated references.

Do not accept a change simply to clear a check. A deliberate baseline update records an intended design change; an unexplained difference should be investigated first.

Run Chromatic in CI

For pull-request checks, publish Storybook from CI using either the Chromatic CLI or Chromatic’s GitHub Action. Keep the project token out of committed source and store it as a protected repository secret, conventionally named CHROMATIC_PROJECT_TOKEN. Configure the job to build and publish Storybook, then make its result visible as a check on the pull request.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

CLI or GitHub Action?

Approach Useful when Configuration and cautions
Chromatic CLI You want a portable command that can run in different CI providers as well as locally. The CLI accepts command-line flags and can read chromatic.config.json from the project root. Command-line flags take precedence over config-file options.
GitHub Action Your repository uses GitHub Actions and you want the publish step integrated into that workflow. Use a repository secret for the token. Chromatic documents pinning the action to a major or exact version; review its current documentation for action tags and runner examples. The zip option is available for large builds.

Chromatic’s CLI uses a project token for authenticated builds. Do not put a real token in a checked-in configuration file. For either route, ensure the job invokes the right Storybook build: build-storybook is the documented default script name, and custom scripts or an already-built Storybook directory need corresponding configuration.

Example GitHub Actions workflow

The following illustrates the essential shape of a job. Replace the action version with the version you have reviewed and chosen from Chromatic’s current action documentation. Ensure your project’s dependency installation and build requirements are handled by the surrounding workflow.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
name: Chromatic
on: [push, pull_request]
jobs:
  chromatic:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: chromaui/action@vX
        with:
          projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}

vX is intentionally not a pin: choose a real major or exact action version after checking the current official instructions. Do not copy a changing runner or action tag blindly.

Common setup problems and fixes

  • The addon command fails or reports an unsupported Storybook version: Check the installed Storybook version and use the instructions that match it. The cited Storybook 8 page sets the addon minimum at Storybook 7.6; do not assume every release has identical setup.
  • Storybook cannot find the Vite configuration: Confirm the project root and config filename. If the file is elsewhere, configure viteConfigPath for the builder.
  • A Storybook-only Vite change is missing: Put project-specific adjustments in viteFinal in .storybook/main.ts (or the corresponding JavaScript file), rather than assuming Storybook will read settings placed elsewhere.
  • The build publishes the wrong output or fails to build stories: Check that Chromatic is invoking the correct Storybook build script. Its documented default is build-storybook; configure custom scripts or an existing build directory as appropriate.
  • CI authentication fails: Confirm the project token is present in the runner environment through a protected secret, that the secret name matches the workflow, and that the token belongs to the intended Chromatic project.
  • A pull request shows visual differences you did not expect: Inspect the affected stories and determine whether the change is intentional before accepting it. If not, fix the source of the difference and publish again.
  • A teammate cannot open a published Storybook link: Check the project visibility and collaborator access. Published Storybooks are private by default for logged-in collaborators; public visibility is an available setting.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and cost considerations

The documented workflow builds and uploads Storybook, so CI duration and reliability depend in part on your project’s build and runner setup. Chromatic’s documentation mentions a zip option for large builds; consult its current action instructions before enabling it. The supplied product documentation does not establish a universal runtime, pricing figure, or guarantee for this workflow, so treat those as plan- and project-specific rather than assuming a fixed cost or build time.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For reliable comparisons, publish the same intended stories and build configuration consistently, protect the token, and update baselines only after review. If a build fails, check the underlying Storybook build and authentication configuration before interpreting it as a visual regression.

Or skip the browser setup

Chromatic is the fit for hosted story-based visual regression and shared baselines. ScreenshotNeo is a separate website screenshot API and MCP server, not a replacement for Chromatic’s component-story comparison workflow. It is useful when you need a clean capture of a web page rather than a Storybook baseline comparison.

One GET request returns a screenshot or PDF. For example, using cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. Cookie banners and consent notices, newsletter popups, and chat widgets are removed before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. Its MCP server lets AI agents use screenshot tools. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Does Chromatic test every browser interaction?

No. Its visual tests compare story renderings; use interaction and other tests for behavior that appearance snapshots do not verify.

Can I make a published Storybook public?

Yes. Chromatic documents public visibility as an available setting; check the project’s visibility before sharing a link.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

ChromaticGitHub ActionsStorybookvisual testingVite

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.