◉RORK LABJP
●SUBDOMAIN — Rork can now connect your web app to a subdomain only, leaving your root domain and www untouched (12/1)●UPDATES — expo-updates 58.0.23 fixes Android release builds embedding a stale runtime version●FLASH END — Intro pricing for Gemini Flash models ends 12/31, 29 days from now. Time to recheck AI feature costs●HMR — Some report the dev server picking up another server's bundle and then exiting●FIRST VIEW — Map the first screen for a normal launch, a notification, and a link, and back navigation stops surprising you●CARBON — Gemini 4 Carbon and Argon are now at standard rates: $4.00 input, $20.00 output per 1M tokens●SUBDOMAIN — Rork can now connect your web app to a subdomain only, leaving your root domain and www untouched (12/1)●UPDATES — expo-updates 58.0.23 fixes Android release builds embedding a stale runtime version●FLASH END — Intro pricing for Gemini Flash models ends 12/31, 29 days from now. Time to recheck AI feature costs●HMR — Some report the dev server picking up another server's bundle and then exiting●FIRST VIEW — Map the first screen for a normal launch, a notification, and a link, and back navigation stops surprising you●CARBON — Gemini 4 Carbon and Argon are now at standard rates: $4.00 input, $20.00 output per 1M tokens
Articles/Dev Tools
⬡ Dev Tools/2026-05-09Advanced

Building a Rork A/B Testing Platform with GrowthBook and PostHog from Scratch

Drop Firebase and pair GrowthBook with PostHog to ship an A/B testing stack for your Rork apps: SDK wiring, a KV-cached feature endpoint on Cloudflare Workers, sample-size math, SRM checks, and the operational pitfalls.

GrowthBookPostHog3A/B Testing8Feature Flags4Cloudflare Workers26Rork622Experimentation

✦ Premium Article

While re-reading an earlier version of this guide, I noticed that the setup it described could never start an experiment. A GrowthBook instance was created, but nothing ever fetched the feature definitions. useFeatureValue kept returning its default, and the dashboard kept saying "no data." You can probably guess how long a night spent hunting for the cause can get.

The places where an experiment platform trips you up are usually upstream of the statistics: a missing initialization call, mismatched identifiers, a package name that doesn't exist. Clear those first, and you can judge the results by the numbers instead of by suspicion.

Here I'll walk through wiring GrowthBook (the experiment engine) and PostHog (product analytics) into the React Native app Rork generates, up to your first experiment. I've separated the code I could run locally from the parts you should check against the official docs. I've also redone the sample-size math, because the figure in the old version was wrong.

Why GrowthBook + PostHog, Not Firebase

Firebase Remote Config plus Firebase Analytics is the shortest path to a first A/B test. Once experimentation becomes routine, a few limits show up.

The first is how much of the statistics you can adjust. Firebase A/B Testing runs its statistics internally, and you can't change the prior or the significance level. GrowthBook lets you choose the engine (Bayesian or frequentist) and thresholds in settings, and offers variance-reduction methods like CUPED (Controlled-experiment Using Pre-Experiment Data). Some of these, CUPED and sequential testing among them, may sit in paid plans, so check the pricing page before relying on them.

The second is where design and analysis live. Remote Config delivers flags and Analytics collects events, so you can't follow an experiment in one view. GrowthBook keeps definition, delivery rules, and analysis in a single dashboard, and with PostHog as the data source, your PostHog events become experiment metrics directly.

The third is avoiding lock-in. The cores of both GrowthBook and PostHog are open source and can be self-hosted with Docker. Some features of each sit under a separate commercial license, though. "It's all MIT, so I'm completely free" is not quite true; check which side of the line the features you want fall on.

The free tiers of GrowthBook Cloud and PostHog Cloud are enough to start. Limits and prices change, so confirm them on each vendor's pricing page before you decide.

Architecture Overview

The platform has four parts.

PartResponsibilityWhere it can live
GrowthBook dashboard and APIExperiment definitions, targeting rules, statistical analysisGrowthBook Cloud or self-hosted
Delivery cache (Workers + KV)Serve the feature-definition JSON from close to the appCloudflare Workers
PostHogEvent collection, funnels, the metric data sourcePostHog Cloud or self-hosted
Rork app (React Native / Expo)Flag evaluation, exposure logging, conversion eventsOn device

The flow is simple. When the app starts, the GrowthBook SDK fetches the feature-definition JSON. Flags are evaluated inside the app, and the moment a user is assigned to an experiment, an exposure event goes to PostHog. GrowthBook aggregates PostHog's events and decides the winner.

One point to hold onto: flag evaluation happens on the device, and only the definition JSON is delivered. The delivery side only has to return definitions quickly and keep returning them.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦Wire GrowthBook and PostHog into a Rork app and run a first experiment, including the initialization step that is easy to miss
✦Reproduce a minimal Workers + KV cache for feature delivery that has been exercised locally, and measure latency yourself instead of trusting a quoted number
✦Calculate the required sample size first, check for SRM, and decide where to stop instead of declaring a winner because a number crossed 95%
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

⬡ Dev Tools2026-08-01
Every Experiment Kept Landing on the Same Devices: Hash Choice and Salt Position, Measured Across a Million IDs
On-device experiment assignment looked fine in isolation, then collapsed the moment two experiments ran side by side. Here is what one million IDs revealed about four hash functions, why the culprit was the concatenation order rather than hash quality, and the implementation I settled on, with the measured numbers.
⬡ Dev Tools2026-04-30
Rork × AI Moderation Production Guide: Reporting, Auto-Review, and Tiered Sanctions for UGC Apps
A complete production-grade guide to layering AI moderation, reporting, and tiered sanctions into your Rork UGC app. Includes a working three-layer pipeline using OpenAI Moderation, Perspective API, and Cloudflare Workers Queues.
⬡ Dev Tools2026-03-22
Making Feature Flags Survive Production: Kill Switches and Gradual Rollouts in Rork Max
Wire Firebase Remote Config into a Rork Max app, then harden it: kill switches that work offline, stable bucket assignment for gradual rollouts, and a registry that keeps flags from turning into debt.