---
title: A/B Testing on Vercel
description: Learn best practices for A/B testing on Vercel
url: /kb/guide/ab-testing-on-vercel
canonical_url: "https://vercel.com/kb/guide/ab-testing-on-vercel"
published: 2025-11-03
last_updated: 2026-08-26
authors: Rich Haines
related:
  - /docs/routing-middleware
install_vercel_plugin: npx plugins add vercel/vercel-plugin
---
<!-- docsgraph:related -->
## Related pages

> **For AI agents:** Follow these links to understand how this page connects to the rest of the Vercel ecosystem. For the full cross-link map (inbound, outbound, prerequisites, and semantic neighbors), see the .graph.md link below.

- [Incremental Migration to Vercel](https://vercel.com/docs/incremental-migration?from=related&source_path=%2Fkb%2Fguide%2Fab-testing-on-vercel&source_site=vercel-kb&relationship=related) — Learn how to migrate your app or website to Vercel with minimal risk and high impact.
- [Integrating Vercel and Kubernetes](https://vercel.com/docs/integrations/external-platforms/kubernetes?from=related&source_path=%2Fkb%2Fguide%2Fab-testing-on-vercel&source_site=vercel-kb&relationship=related) — Deploy your frontend on Vercel alongside your existing Kubernetes infrastructure.
- [Replacing Google Optimize with the Vercel Edge Network](https://vercel.com/blog/vercel-edge-google-optimize?from=related&source_path=%2Fkb%2Fguide%2Fab-testing-on-vercel&source_site=vercel-kb&relationship=related)
- [How to run A/B tests with Next.js and Vercel](https://vercel.com/blog/ab-testing-with-nextjs-and-vercel?from=related&source_path=%2Fkb%2Fguide%2Fab-testing-on-vercel&source_site=vercel-kb&relationship=related)
- [Running an A/B test](https://vercel.com/docs/flags/vercel-flags/cli/run-ab-test?from=related&source_path=%2Fkb%2Fguide%2Fab-testing-on-vercel&source_site=vercel-kb&relationship=related) — Set up an A/B test with a feature flag, track results through Web Analytics, and clean up afterward using the Vercel CLI
- [How to build zero-CLS A/B tests with Next.js and Vercel Edge Config](https://vercel.com/blog/zero-cls-experiments-nextjs-edge-config?from=related&source_path=%2Fkb%2Fguide%2Fab-testing-on-vercel&source_site=vercel-kb&relationship=related)
- [Vercel Edge Middleware: Dynamic at the speed of static (historical)](https://vercel.com/blog/vercel-edge-middleware-dynamic-at-the-speed-of-static?from=related&source_path=%2Fkb%2Fguide%2Fab-testing-on-vercel&source_site=vercel-kb&relationship=related)
- [Getting Started with Routing Middleware](https://vercel.com/docs/routing-middleware/getting-started?from=related&source_path=%2Fkb%2Fguide%2Fab-testing-on-vercel&source_site=vercel-kb&relationship=related) — Learn how you can use Routing Middleware, code that executes before a request is processed on a site, to provide speed a
- [Testing & troubleshooting microfrontends](https://vercel.com/docs/microfrontends/troubleshooting?from=related&source_path=%2Fkb%2Fguide%2Fab-testing-on-vercel&source_site=vercel-kb&relationship=related) — Learn about testing, common issues, and how to troubleshoot microfrontends on Vercel.
- [Building secure and performant web applications on Vercel](https://vercel.com/blog/building-secure-and-performant-web-applications-on-vercel?from=related&source_path=%2Fkb%2Fguide%2Fab-testing-on-vercel&source_site=vercel-kb&relationship=related)
- [How to Integrate Optimizely Feature Experimentation with Next.js and Vercel](https://vercel.com/kb/guide/how-to-integrate-optimizely-feature-experimentation-next-vercel?from=related&source_path=%2Fkb%2Fguide%2Fab-testing-on-vercel&source_site=vercel-kb&relationship=related) — This guide covers setting up feature flags, implementing A/B tests, and optimizing performance using React Server Compon
- [How to ship a NestJS app on Vercel](https://vercel.com/kb/guide/ship-a-nestjs-app-on-vercel?from=related&source_path=%2Fkb%2Fguide%2Fab-testing-on-vercel&source_site=vercel-kb&relationship=related) — Deploy a NestJS app to Vercel with zero configuration. Learn how to ship from a template, the Nest CLI, or Git, and conf

Full cross-link map for this page: [/kb/guide/ab-testing-on-vercel.graph.md](/kb/guide/ab-testing-on-vercel.graph.md?from=related&source_path=%2Fkb%2Fguide%2Fab-testing-on-vercel&source_site=vercel-kb&relationship=graph)
<!-- /docsgraph:related -->


A/B testing allows you to serve different versions of your site to different groups of visitors. This could be two versions, split at 50% of your traffic, or as complex as thousands of small experiments to optimize the content shown on screen.

One example application of A/B testing is news sites. When you land on a news article, the headline has been carefully selected for you. For example, the experiment might start out as a split test between two headlines:

1. ”How Next.js is bringing dynamic at the speed of static”
   
2. ”A/B testing and high-performance personalization with Next.js”
   

After monitoring the experiment, metrics show option two has higher click-through rates. The headline is then updated to use the higher performing variation. Other metrics besides click-through rates could be used, including:

- User conversion
  
- User engagement
  
- Sessions
  
- Bounce rate
  

## Routing Middleware

[Routing Middleware](https://vercel.com/docs/routing-middleware) allows you to run code before a request is completed. This gives you full flexibility to add A/B testing and personalization to any part of your application, all defined as code instead of configuration.

A/B testing on the server-side with [Routing Middleware](https://vercel.com/docs/routing-middleware) reduces layout shift by preventing client-loaded experiments and improves your site's performance by serving smaller JavaScript bundles.

Because you have access to the incoming request and `User-Agent`, you can also prevent bots or search crawlers from hitting experiments.

## Providers

Routing Middleware can be used with any third-party library or service to run experiments and A/B testing, including:

- [A/B Testing with Cookies](https://vercel.com/templates/next.js/cookies)
  
- [Configcat](https://vercel.com/templates/next.js/ab-testing-configcat)
  
- [Split](https://vercel.com/templates/next.js/ab-testing-split)
  
- [Builder.io](https://vercel.com/templates/next.js/personalization-builder-io)
  
- [Google Optimize](https://vercel.com/templates/next.js/ab-testing-google-optimize)
  
- [Statsig](https://vercel.com/templates/next.js/ab-testing-statsig)
  

View more [templates](https://vercel.com/templates?type=edge-functions).