Member-only story
Next.js Middleware: Server-side A/B Testing for Enhanced Performance
Server-side Feature Flagging via Firebase Remote Config Using Next.js Middleware — With Optimal Performance.

💡 This article demonstrates how to do A/B testing with Firebase Remote Config through Next.js edge middleware. See Vercel’s examples for more feature flag tool demos including similar approach for Split here.
Problems of A/B testing on web
A/B testing is a statistical technique used to test new features or different versions of an application on a select group of users before making them available to all users. On the webapp I am currently working with in my company, we use feature flagging tools like Split and Firebase Remote Config to enable product owners or managers to control feature flags remotely. Currently, we have 13 feature flags active in production, which are fetched in 17 different places on our React SPA. This negatively affects our website’s performance and user experience. This is also one of the reasons we are migrating to Next.js framework.
Client-side A/B testing
Client-side A/B testing is expensive as it results in delays and negatively impacts core web vitals scores such as LCP, FCP, and CLS…