Skip to content



sanity-plugin-roboto-ab-test

Our open-source Sanity plugin for authoring A/B test variants directly in the studio.

entry 08 of 12 · plugin · updated 2026-07-23



What it is

sanity-plugin-roboto-ab-test gives editors a way to author and manage A/B test variants from inside Sanity Studio v3. Installing it adds an abTest document type to your schema. Editors create test entries that attach variant content to a page, then a Next.js middleware reads a cookie to decide which variant to serve on each request.

The pattern keeps experiment content alongside the rest of the document, rather than in a separate tool that only developers can access. Variants live in Sanity, get the same editorial workflow as any other content, and don't require a code deployment each time something changes.

What you get

  • An abTest document type added to your schema, with a matching structure list helper for the studio sidebar.
  • Cookie-based variant assignment via a small Next.js middleware snippet the README supplies: visitors are bucketed once, then rewritten at the edge to a /test/[variant]/[slug] route.
  • Because the variant is chosen by an edge rewrite rather than client-side JavaScript, there's no flicker on page load, and the README ships the full variant page implementation with generateStaticParams so each variant pre-renders.
  • Content for each variant stays in Sanity, so editors can update copy without a developer involved.

How to use it

Install it from npm:

bash
npm i sanity-plugin-roboto-ab-test

Then register it in your studio config, specifying which schema type the tests attach to:

ts
// sanity.config.ts
import { defineConfig } from "sanity";
import { abTest } from "sanity-plugin-roboto-ab-test";

export default defineConfig({
  plugins: [
    abTest({
      schemaType: "page",
    }),
  ],
});

You will also need to add abTestStructureList to your structure builder so the document type appears in the sidebar, and wire in the middleware snippet from the README to handle cookie assignment and URL rewriting.

How we use it

Running an experiment usually means either a developer writing variant logic in code or an editor working in a tool that is disconnected from the CMS. This plugin puts both sides in the same place: variant content lives in Sanity, editors can adjust it on their own schedule, and no code deployment is needed to change copy.





Get in touch

Tell us what you're building. We reply within one working day. Jono or someone on the team picks up every message personally.

By sending this you agree to our privacy policy. We only use your details to reply.