Feature Flagging with React Server Components

This ad is not shown to multipass and full ticket holders
React Summit US
React Summit US 2026
November 17 - 20, 2026
New York, US & Online
Upcoming event
React Summit US 2026
React Summit US 2026
November 17 - 20, 2026. New York, US & Online
Bookmark
Rate this content
Sentry
Promoted
Code breaks, fix it faster

Crashes, slowdowns, regressions in prod. Seer by Sentry unifies traces, replays, errors, profiles to find root causes fast.

Get started

Feature flagging is a great way to reduce risk by separating code deployments from feature releases, but with React Server Components present some unique challenges and complexities. In this talk, you will learn about these challenges and how to overcome them.  I will also give a live demo that will illustrate step-by-step implementation, showcasing how to dynamically render components based on feature flags using a variety of rendering strategies.

This talk has been presented at React Summit US 2024, check out the latest edition of this React Conference.

FAQ

Feature flagging is a technique that allows developers to enable or disable features in an application without deploying new code. It helps separate code deployments from feature releases, allowing for safer and more controlled rollouts.

Feature flagging with React allows developers to manage feature releases independently from deploying code, which is crucial for large teams with frequent commits. It also facilitates A-B testing and live QA in production environments.

Feature flags allow developers to commit code without exposing incomplete features to users, support trunk-based development, enable conditional feature releases, and provide a kill switch for quick feature rollback in case of bugs.

Feature flags allow for conditional feature releases to different user groups, enabling A-B testing by comparing the performance and impact of different feature versions across randomly assigned user segments.

Static site generation with feature flags is limited because user-specific targeting is not possible at build time, and changes to feature flags require redeployment, negating the immediate control benefits of feature flagging.

The server-client hybrid approach involves using server components to cache feature flag payloads for efficiency, while client components handle synchronous evaluation, providing a balance between performance and feature flexibility.

Flickering can occur because the initial render of the app may not have the updated feature flag state, causing a temporary display of default states before updating. This can be mitigated by optimizing feature flag payload retrieval.

Growthbook is an open-source platform for feature flagging and A-B testing, offering tools to manage feature releases and measure their impact. It provides a user interface for stakeholders and integrates with code through SDKs.

Server components in React allow for asynchronous operations, eliminating the need for complex state management like useEffect, and enabling more efficient feature flag evaluation with less client-side setup.

Feature flags can impact SEO if the flagged content is not included in the initial HTML payload served to search engines. It's generally not common to use feature flags for SEO purposes, as they are more user-specific.

Graham McNicoll
Graham McNicoll
20 min
22 Nov, 2024

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Hey, everybody, I'm Graham, and I'm really excited to give you a talk today on feature flagging with React server components. We're going to give examples of how you can deploy feature flags in your application, and how feature flagging interacts with React's rendering strategies. Feature flags are conditional logic that allows you to control the state of a feature independent from the code deploy. This separation of code deployments from feature releases is critical for large product organizations. It enables frequent commits without exposing changes to users, conditional release of features, and easy rollback in case of unexpected bugs. Using FeatureFlag gives you a kill switch where you can turn off your feature. It allows you to do A-B testing and measure the impact of new features. You conditionally release the feature to different sets of users, allowing you to control for externalities and changes to your product. A FeatureFlag is used to get the state and conditionally show a component. The flag state can be stored in a file or using environment variables. However, environment variables have limitations in terms of complexity. A more complex example uses growth book syntax, allowing for advanced control over feature rollout. Building your own system can be tricky, but feature flagging platforms offer fully-featured solutions with two main advantages. Feature flagging applications have a nice UI for controlling feature releases and an SDK that integrates with the code. React poses complications in using feature flags due to its rendering strategies. Static site generators like Next.js have limitations in user targeting and require redeploy for updates. Client components are not async, requiring the use of React primitives. These approaches have their own challenges in implementing feature flags. To initialize the SDK, instantiate the SDK outside of the app and use a user effect hook to download the feature flag payload and update the user data on the SDK. The growth book provider builds context for evaluating feature flags, allowing components to easily access feature flag states. However, there may be a slight flicker in the UX due to the time it takes to initialize the SDK and download the feature flag state. Network optimization can help reduce flickering, but the client's network connection is beyond your control. There are some workarounds for flickering, like showing a loading spinner while rendering in the background. Using feature flags for SEO is not ideal as the initial HTML payload doesn't include all the contents. Server components in React 19 provide an async solution without the need for complicated useEffect and state. react.cache allows caching expensive operations scoped to the current request. The getSdk function call retrieves the value of the feature flag from the cache, providing faster subsequent calls. Our SDK has its own in-memory cache. Dynamic rendering can be expensive in terms of requests, rendering, network calls, and running React on the service side. It can also be slow, and tracking events may be challenging. The server-client hybrid approach combines the advantages of the previous strategies without the downsides. By making the outer app a server component and caching the feature flag payload, we can achieve no-flicker client-side feature flagging. The client component can use the UseMemo hook and the initSync method with the payload already in memory. Passing the SDK instance and wrapping the main app in a provider allows us to have the best of both worlds. Although it may be slightly more complex to set up, using Next.js with React server components offers a cool and modern approach to feature flagging with high performance.

1. Introduction to Feature Flagging with React

Short description:

Hey, everybody, I'm Graham, and I'm really excited to give you a talk today on feature flagging with React server components. We're going to give examples of how you can deploy feature flags in your application, and how feature flagging interacts with React's rendering strategies. Feature flags are conditional logic that allows you to control the state of a feature independent from the code deploy. This separation of code deployments from feature releases is critical for large product organizations. It enables frequent commits without exposing changes to users, conditional release of features, and easy rollback in case of unexpected bugs.

Hey, everybody, I'm Graham, and I'm really excited to give you a talk today on feature flagging with React server components, and so let's jump right in. I'm Graham McNichol. I'm the co-founder of Growthbook. Growthbook is the most popular open-source feature flagging and A-B testing platform. I went through Y Combinator a couple of years ago and was previously the CTO of my last startup.

So the goal of today's talk is to, if you're not already familiar, kind of give you a quick introduction to what feature flagging is all about. We're going to give some examples of how you can kind of deploy feature flags in your application and then some more complex examples. And then really the meat of this talk is to talk about how feature flagging interacts with React and particularly with some of the different rendering strategies that React has. So we're going to take a look at four different examples of different rendering strategies that React and how you can use feature flagging within each of those.

All right, so with that in mind, we're going to take a look at what is feature flagging. So feature flags are conditional logic that you place around a block of code that allows you to control the state of that feature independent from the code deploy. So it really helps you separate code deployments from feature release, right? And that's really critical when you're working with large product organizations. You have a lot of commits happening at the same time.

And so let's take a look at some of those advantages. So from a development point of view, it allows you to commit code, even though it's a work in progress because it will never be seen by a user. So you can commit more frequently without exposing those changes to your users. And also enables trunk-based development, which feel free to look it up. I don't have time to go into that, but that's also a cool way to kind of do development if you find yourself getting a lot of merge conflicts constantly. And so it also allows you to do conditional release of features. So you can do release features to a subset of your users, or you can do live QA in production by, say, targeting for just beta users, or doing canary releases, or just releasing to like a small subset of your users. And you really can't do that without other systems or hard coding that in. And FeatureFlag makes that so trivially easy.

From a product perspective, as engineers, one of the things that happens is we can release a feature and cause an unexpected bug. And in which case, historically, you've had to quickly roll back your code, figure out the bug and redeploy, or roll it back to a previous version and then deploy that version. And now you're waiting for your CICD pipeline to finish. And it's sort of nerve-wracking a couple of minutes while everything goes. Hopefully, it's a couple of minutes. Sometimes, it could be much, much longer. And then there's all kinds of interaction effects. If your deploy went out with other features, now you're rolling back other people's works.

2. Advantages of Using Feature Flags and A-B Testing

Short description:

Using FeatureFlag gives you a kill switch where you can turn off your feature. It allows you to do A-B testing and measure the impact of new features. You conditionally release the feature to different sets of users, allowing you to control for externalities and changes to your product.

And it just gets really messy. So using FeatureFlag gives you a kill switch where you can just turn off just your feature. Yeah. So that's really powerful. And the other cool thing it does is it allows you to do A-B testing. So we feel that FeatureFlags is the best way to release new features. And A-B test is the best way to measure the impact of those features. So what you do is you kind of conditionally release that feature to a random set of users that get the control version, a random set that get the new variant, and then you kind of measure the impact. So it allows you to sort of control for all the different externalities that can happen and sort of changes to your product that can happen if you just looked at before and after testing.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
This talk discusses the usage of Microfrontends in Remix and introduces the Tiny Frontend library. Kazoo, a used car buying platform, follows a domain-driven design approach and encountered issues with granular slicing. Tiny Frontend aims to solve the slicing problem and promotes type safety and compatibility of shared dependencies. The speaker demonstrates how Tiny Frontend works with server-side rendering and how Remix can consume and update components without redeploying the app. The talk also explores the usage of micro frontends and the future support for Webpack Module Federation in Remix.
Understanding React’s Fiber Architecture
React Advanced 2022React Advanced 2022
29 min
Understanding React’s Fiber Architecture
Top Content
This Talk explores React's internal jargon, specifically fiber, which is an internal unit of work for rendering and committing. Fibers facilitate efficient updates to elements and play a crucial role in the reconciliation process. The work loop, complete work, and commit phase are essential steps in the rendering process. Understanding React's internals can help with optimizing code and pull request reviews. React 18 introduces the work loop sync and async functions for concurrent features and prioritization. Fiber brings benefits like async rendering and the ability to discard work-in-progress trees, improving user experience.
Thinking Like an Architect
Node Congress 2025Node Congress 2025
31 min
Thinking Like an Architect
Top Content
In modern software development, architecture is more than just selecting the right tech stack; it involves decision-making, trade-offs, and considering the context of the business and organization. Understanding the problem space and focusing on users' needs are essential. Architectural flexibility is key, adapting the level of granularity and choosing between different approaches. Holistic thinking, long-term vision, and domain understanding are crucial for making better decisions. Effective communication, inclusion, and documentation are core skills for architects. Democratizing communication, prioritizing value, and embracing adaptive architectures are key to success.
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
RemixConf EU discussed full stack components and their benefits, such as marrying the backend and UI in the same file. The talk demonstrated the implementation of a combo box with search functionality using Remix and the Downshift library. It also highlighted the ease of creating resource routes in Remix and the importance of code organization and maintainability in full stack components. The speaker expressed gratitude towards the audience and discussed the future of Remix, including its acquisition by Shopify and the potential for collaboration with Hydrogen.
The Dark Side of Micro-Frontends
React Advanced 2025React Advanced 2025
29 min
The Dark Side of Micro-Frontends
In the Talk, various key points were discussed regarding micro-front-end architecture. These included challenges with micro-intents, common mistakes in system design, the differences between micro-intents and components, granularity in software architecture, optimizing micro-front-end architecture, efficient routing and deployment strategies, edge computing strategies, global state and data sharing optimization, managing data context, governance and fitness functions, architectural testing, adaptive growth, value of micro-frontends, repository selection, repo structures, and web component usage.
The Eternal Sunshine of the Zero Build Pipeline
React Finland 2021React Finland 2021
36 min
The Eternal Sunshine of the Zero Build Pipeline
For many years, we have migrated all our devtools to Node.js for the sake of simplicity: a common language (JS/TS), a large ecosystem (NPM), and a powerful engine. In the meantime, we moved a lot of computation tasks to the client-side thanks to PWA and JavaScript Hegemony.
So we made Webapps for years, developing with awesome reactive frameworks and bundling a lot of dependencies. We progressively moved from our simplicity to complex apps toolchains. We've become the new Java-like ecosystem. It sucks.
It's 2021, we've got a lot of new technologies to sustain our Users eXperience. It's time to have a break and rethink our tools rather than going faster and faster in the same direction. It's time to redesign the Developer eXperience. It's time for a bundle-free dev environment. It's time to embrace a new frontend building philosophy, still with our lovely JavaScript.
Introducing Snowpack, Vite, Astro, and other Bare Modules tools concepts!

Workshops on related topic

AI on Demand: Serverless AI
DevOps.js Conf 2024DevOps.js Conf 2024
163 min
AI on Demand: Serverless AI
Top Content
Featured WorkshopFree
Nathan Disidore
Nathan Disidore
In this workshop, we discuss the merits of serverless architecture and how it can be applied to the AI space. We'll explore options around building serverless RAG applications for a more lambda-esque approach to AI. Next, we'll get hands on and build a sample CRUD app that allows you to store information and query it using an LLM with Workers AI, Vectorize, D1, and Cloudflare Workers.
High-performance Next.js
React Summit 2022React Summit 2022
50 min
High-performance Next.js
Workshop
Michele Riva
Michele Riva
Next.js is a compelling framework that makes many tasks effortless by providing many out-of-the-box solutions. But as soon as our app needs to scale, it is essential to maintain high performance without compromising maintenance and server costs. In this workshop, we will see how to analyze Next.js performances, resources usage, how to scale it, and how to make the right decisions while writing the application architecture.
Model Context Protocol (MCP) Deep Dive: 2-Hour Interactive Workshop
AI Coding Summit 2025AI Coding Summit 2025
86 min
Model Context Protocol (MCP) Deep Dive: 2-Hour Interactive Workshop
Workshop
Stepan Suvorov
Stepan Suvorov
Join a focused 2-hour session covering MCP's purpose, architecture, hands-on server implementation, and future directions. Designed for developers and system architects aiming to integrate contextual data with ML models effectively. Agenda:- Introduction & Why MCP? Key challenges MCP solves and core benefits.- Architecture Deep Dive: components, interactions, scalability principles. - Building Your Own MCP Server: guided walkthrough with code snippets and best practices; live demo or code review.- Future of MCP Developments: potential enhancements, emerging trends, real-world scenarios.
Key Takeaways:- Clear understanding of MCP's rationale.- Insight into design patterns and scaling considerations.- Practical steps to implement a prototype server.- Awareness of upcoming trends and how to apply MCP in projects. 
From Async Chaos to Deterministic React: Hands-On State Machine Architecture for Real-Time Systems
React Summit 2026React Summit 2026
86 min
From Async Chaos to Deterministic React: Hands-On State Machine Architecture for Real-Time Systems
Workshop
Rajni Gediya
Rajni Gediya
Mentorship available
As React apps move into real-time systems — streaming data, AI workflows, hardware devices — async complexity grows quickly. Reducers and scattered async handlers often work at first, but once concurrency and lifecycle interruptions enter the picture, things start to break in subtle ways.
In this hands-on workshop, we’ll take a fragile async React setup and redesign it into a deterministic, state-machine-driven architecture. The goal isn’t to teach a specific library, but to show how explicit state modeling makes complex systems easier to reason about and more reliable in production.
Node's Concurrency With the Strength of a Bull With BullMQ
Node Congress 2026Node Congress 2026
95 min
Node's Concurrency With the Strength of a Bull With BullMQ
Workshop
Edy Silva
Douglas Marques
2 authors
Node's concurrent nature is powerful already, but often we need to push work out of the main server for several reasons. In this work, we will explore a few scenarios in which work is cleverly pushed to another Node process to resolve.
Once we use a queue to distribute workloads, we need to identify the nature of the work to be done. For either I/O- or CPU-intensive work, the first is already perfectly covered by a single Node.js process; we will need to tweak the worker setup to match the available resources and throughput.