Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Next.js template demonstrating Statsig feature flags with the Flags SDK, including gates, experiments, and the Vercel Flags Explorer.
The Statsig Flags SDK Example is a Vercel-deployable Next.js template that shows how to integrate Statsig feature management with the Flags SDK and the @flags-sdk/statsig adapter. It uses two feature gates and one experiment configured in Statsig to control UI variations on a single page, and it ships with a documented setup workflow for developers.
This template is a working reference app that wires the Flags SDK to Statsig's experimentation platform. It takes two feature gates (summer_sale and free_delivery) and one experiment (proceed_to_checkout) as inputs, and renders their outcomes as two banners and a checkout button color on the page. The template runs on Vercel, is part of Vercel's official examples collection, and can be deployed in one click from the Vercel Marketplace.
summer_sale) and Free Shipping gate (id free_delivery) each control a banner, configured to show 50% of the time.proceed_to_checkout) sets a color parameter (blue, green, or red) for different test groups.FLAGS_SECRET environment variable preconfigured.The page reads the values of the summer_sale and free_delivery gates and the proceed_to_checkout experiment at request time via the Flags SDK. The flags are fetched using the @flags-sdk/statsig adapter, and the Flags Explorer adds an in-app toolbar when the FLAGS_SECRET environment variable is set, allowing overrides. The README documents a five-step setup: deploy, link the project, pull environment variables, create the gates and experiments in the Statsig Console, and configure their percentages and groups.
The template requires a FLAGS_SECRET variable, which must be 32 random bytes base64-encoded; it is used by the Flags Explorer to securely overwrite feature flags. Two optional variables, STATSIG_CONSOLE_API_KEY and STATSIG_PROJECT_ID, make the Explorer fetch additional metadata from the Statsig API.
It uses two feature gates named Summer Sale and Free Shipping (ids summer_sale and free_delivery), each targeting the Stable ID with a 50% show rule, and one experiment named Proceed to Checkout (id proceed_to_checkout) with groups Control, Test, and Test #2, and a color parameter set to blue, green, or red.
You can open the Dev Tools at the bottom of the page to reset your stable id and reload, which gives you a new random variation. If you have deployed your own version and configured the gates, you can also use the Flags Explorer in the Vercel Toolbar to create overrides and force specific variations.
It uses Stable ID when configuring the gates and experiments in Statsig, as instructed in the README. This means anonymous visitors get consistent variations based on a stable identifier until it is reset.
