createWithAbTestingMiddleware
createWithAbTestingMiddleware is a middleware helper for Next.js App projects where A/B Testing must be chained with i18n routing.
It lets one request flow resolve both:
- the active locale
- the active A/B Testing variant
The selected variant is stored in a cookie. When rendering the page, read it with getAbTestingCookie and pass it to fetchPage as variantName.
When to use it
Section titled “When to use it”Use createWithAbTestingMiddleware when:
- your project uses the Next.js App Router
- your project uses React Bricks i18n middleware
- your project also uses A/B Testing and Multischeduling
For Next.js Pages or Astro projects, use createAbTestingMiddleware.
Implementation notes
Section titled “Implementation notes”Middleware chaining is project-specific, because it depends on your routing, locales, and analytics setup.
Use the starter implementation as the recommended reference: https://github.com/ReactBricks/reactbricks-starters/tree/feature/ab-testing/apps/nextjs-app