Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

How to Set Up Chromatic with Storybook in Next.js

Install Storybook in a Next.js project, connect Chromatic, publish visual baselines, and automate builds safely with GitHub Actions.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

From your Next.js project root, run npm create storybook@latest and follow the setup prompts. For most new projects, Storybook recommends its Vite-based @storybook/nextjs-vite framework; keep the Webpack-based @storybook/nextjs option when your project depends on custom Webpack/Babel configuration or a Webpack-specific feature. Then create or select a Chromatic project, add its CLI to your development dependencies, and publish a first build to establish visual baselines.

Before you start

  • Work from the root of the Next.js repository, where its package manifest is located.
  • Check the live Storybook Next.js installation guidance for current compatibility. The official installation information retrieved on October 3, 2026 lists Next.js 14+ and Node.js 20+ among its requirements; these version requirements can change.
  • Have access to a Chromatic account so you can create or select a project and obtain its project token.

Install Storybook in the Next.js project

  1. Open a terminal at the project root.
  2. Run npm create storybook@latest.
  3. Answer the CLI prompts and let it inspect the project dependencies to choose a configuration. Review the generated files and scripts before committing them.
  4. Start Storybook using the script the CLI adds to your package manifest, commonly npm run storybook. Confirm your stories render locally before connecting Chromatic.

The exact generated configuration and script names can vary by Storybook release and package manager. If Storybook is already installed, use the current upgrade and migration instructions instead of copying an older major-version setup; older projects may contain legacy Next.js addons that current framework guidance says are redundant.

As an Amazon Associate I earn from qualifying purchases.

Choose the Next.js framework: Vite or Webpack

Framework Choose it when Trade-off
@storybook/nextjs-vite You are starting a typical new Next.js Storybook setup and do not need a Webpack-only feature. Storybook recommends it for most projects, citing faster builds and development startup, modern test support, and simpler configuration.
@storybook/nextjs Your project relies on custom Webpack or Babel configuration that cannot move to Vite, or requires specific Webpack functionality. Retains a Webpack-based integration where compatibility matters more than moving to the Vite-based setup.

Use the framework the CLI selects unless your project’s configuration gives you a concrete reason to choose differently. Verify framework support against the current documentation for the Storybook and Next.js versions actually installed.

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

Resolve common Next.js story behavior

Stories that use next/navigation

If a story imports next/navigation, it may need the app-directory setting. Add nextjs.appDirectory: true to that story’s parameters, or set it globally in the preview configuration if the application uses only the app directory. Follow the framework’s current Next.js documentation for the configuration shape supported by your installed release.

Google Fonts fail during a build

A Storybook build can fail when it tries to fetch Google Fonts from an environment without reliable external network access. Storybook’s Next.js guidance recommends mocking those font requests through its documented environment-variable mechanism when they cause a failure. This is a targeted workaround, not a setting every project needs.

Other Next.js integrations

The selected framework supports Next.js-related behavior for features such as images, routing and navigation, fonts, styling, and absolute imports. Exact behavior depends on the framework and release, so consult the current framework page rather than assuming a setting from an older guide still applies.

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

Connect the project to Chromatic and publish the first build

  1. Create a Chromatic project or select one associated with your Storybook.
  2. Install the CLI as a development dependency: npm install --save-dev chromatic.
  3. Run the first publish from the repository root, replacing the example with your real project token: npx chromatic --project-token=<your-project-token>.
  4. Review the build in Chromatic. Its CLI builds and uploads Storybook to Chromatic’s cloud service and starts the publish and visual-test workflow.
  5. Treat snapshots from the first successful build as the initial visual baselines. Later builds compare new snapshots with those baselines; review changes and update baselines when the UI change is intentional.

Keep the project token private. For local testing, avoid committing it in source or shell scripts that will be checked in. In continuous integration, provide it through the CI provider’s secret store as CHROMATIC_PROJECT_TOKEN. Chromatic documents that environment variable for authentication.

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.

Run Chromatic in GitHub Actions

Add the token under your GitHub repository’s Actions secrets, using the name CHROMATIC_PROJECT_TOKEN. A minimal workflow has this shape; replace the version placeholders with action versions compatible with your repository and choose deliberately whether to pin to an exact version, a major version, or a moving latest tag.

name: Chromatic
on: push
jobs:
  chromatic:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@<chosen-version>
        with:
          fetch-depth: 0
      - uses: actions/setup-node@<chosen-version>
        with:
          node-version: <project-supported-version>
      - run: npm ci
      - uses: chromaui/action@<chosen-version>
        with:
          projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}

Full Git history is included because Chromatic’s documented GitHub Actions pattern checks out the repository with fetch-depth: 0. If the project uses a package manager other than npm, replace npm ci with its lockfile-respecting install command. Pinning an exact action version makes updates explicit; a moving tag can pick up changes without editing the workflow, so it requires a different update policy. Consult the Chromatic GitHub Actions guide for its current action syntax and version-tag options.

Troubleshoot setup and build failures

Storybook’s local build fails before upload

First run the local Storybook start or build command and inspect its output. A broken story, project-specific configuration, or unavailable external resource can fail before Chromatic receives an upload; do not assume every failure originates in Chromatic.

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

The build fails while fetching a font

If the logs point to Google Fonts and the build environment cannot reach the font service, apply Storybook’s documented environment-variable mock for those requests. Do not add the mock when fonts already load successfully.

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

A story using app-router navigation does not render correctly

For stories importing next/navigation, check whether nextjs.appDirectory: true is needed. Configure it on the story or globally when the application uses only the app directory.

Chromatic rejects authentication or cannot find the project

Confirm that the token belongs to the intended Chromatic project and is passed to the CLI or action without being truncated. In GitHub Actions, verify the repository secret name matches CHROMATIC_PROJECT_TOKEN and that the workflow references ${{ secrets.CHROMATIC_PROJECT_TOKEN }}.

A visual change appears in the review

A snapshot difference is a comparison result, not an automatic diagnosis that the change is a defect. Inspect the affected story and decide whether the UI change is intended; update the baseline for intentional changes using the review workflow.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need screenshots of web pages rather than hosted component stories and visual review, ScreenshotNeo offers a website screenshot API and MCP server. For example, its one-call request can return a screenshot:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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. It accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, with verdict and billing details in response headers. Its MCP server gives AI agents tools for screenshots, page information, and PDF capture. The free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo free: 1,000 screenshots a month, no card required.

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.

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.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
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.