ABSplits

Next.js A/B testing

Add AB Splits to your root layout and test any page of your Next.js app. The snippet follows client-side navigation, so tests run on every route change, not just the first page load.

Free plan · 1,000 visitors / month · no card

Set up in 3 steps

  1. 01Add the script to app/layout.tsx with next/script and the beforeInteractive strategy.
  2. 02Deploy, then click Check install in AB Splits.
  3. 03Create a test with a URL pattern like /pricing* and a selector, ideally a data attribute such as [data-ab=hero-title].

app/layout.tsx

import Script from "next/script";

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        {children}
        <Script src="https://absplits.com/s.js" data-key="YOUR_SITE_KEY" strategy="beforeInteractive" />
      </body>
    </html>
  );
}

Your real site key is shown in the dashboard after you add your site.

What to test on Next.js

All 56 examples →

AI writes variants

Choose a headline or button and AI reads your real page to write 3–5 alternatives, each with its reasoning.

Honest stats

Chance to beat the original, 95% intervals, and a plain keep-running or stop verdict. No p-value guesswork.

Results in GA4

Every tested visitor is tagged in GA4, so any report can be split by variant.

Questions

Does it work with client-side navigation?+

Yes. The snippet listens for route changes and re-applies tests and page-view goals each time the URL changes.

Will React overwrite the variant during hydration?+

Give tested elements a stable data attribute, for example data-ab="hero-title", and use that as the selector. The snippet keeps applying changes while the page renders.

Can I see results in Google Analytics 4?+

Yes. Every visitor in a test sends an absplits_exposure event to GA4 with the test and variant name, so you can break down any GA4 report by variant. AB Splits also shows its own Bayesian results.

A/B testing on other platforms