How to run A/B tests with Next.js and Vercel
Vercel demonstrates how to run A/B tests using Edge Middleware to avoid layout shift issues caused by client-side variant injection. This approach enables edge-based rewrites to serve different page variants without impacting performance.
Running A/B tests is hard.
We all know how important it is for our business–it helps us understand how users are interacting with our products in the real world.
However, a lot of the A/B testing solutions are done on the client side, which introduces as variants are dynamically injected after the initial page load. This negatively impacts your websites performance and creates a subpar user experience.layout shift
To get the best of both worlds, we built : code that runs serving requests from the edge cache. This enables developers to perform rewrites at the edge to show different variants of the same page to different users. Edge Middlewarebefore
Today, we'll take a look at a real-world example of how we used Edge Middleware to A/B test our new Templates page.
Source: original entry ↗
More from Vercel
Follow Vercel to get its new changes in your feed and email digest.
OpenAI Decisions API now available on AI Gateway
OpenAI's Decisions API is now accessible through Vercel's AI Gateway with an OpenAI-compatible endpoint, enabling decision models to answer typed questions and return probabilities, choices, and scores for routing, triage, and guardrails use cases. Support is available across the OpenAI SDK, AI SDK, HTTP API, and CLI with the latest versions.
Timestamp attributes now supported in Vercel Flags
Vercel Flags now supports timestamp attributes for entities, allowing you to create time-based targeting rules. Use this feature to run limited-time campaigns, show content between specific dates, or target users based on registration date.
Glyph Cluster now available in stealth on AI Gateway
Glyph Cluster, a reasoning model for coding and long-context analysis, is now available as a stealth model on Vercel's AI Gateway for Pro and Enterprise plan teams with purchased AI Gateway credits at no cost during the stealth period. The model supports function calling, streams responses, and can be accessed via AI SDK, OpenAI-compatible APIs, and coding agents.