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
abTestdocument 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
generateStaticParamsso 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:
Then register it in your studio config, specifying which schema type the tests attach to:
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.