<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Flagship.io</title>
    <description>The latest articles on DEV Community by Flagship.io (@flagship).</description>
    <link>https://dev.to/flagship</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F4372%2F903499a0-56b8-4baf-bd73-dc4b28ca1ab5.png</url>
      <title>DEV Community: Flagship.io</title>
      <link>https://dev.to/flagship</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/flagship"/>
    <language>en</language>
    <item>
      <title>Need an honest review of our Free Trial Product Tour</title>
      <dc:creator>Louis de Chateauvieux</dc:creator>
      <pubDate>Mon, 14 Feb 2022 09:50:10 +0000</pubDate>
      <link>https://dev.to/flagship/need-an-honest-review-of-our-free-trial-product-tour-4bmd</link>
      <guid>https://dev.to/flagship/need-an-honest-review-of-our-free-trial-product-tour-4bmd</guid>
      <description>&lt;p&gt;Hi everyone!&lt;br&gt;
I'm Louis, Product Marketing Manager at Flagship.io, our feature management platform.&lt;br&gt;
I'm currently working on redesigning the product tour and since our solution is meant to be used by you guys, I'd like to know if you can sign up at &lt;a href="https://www.flagship.io/sign-up/"&gt;https://www.flagship.io/sign-up/&lt;/a&gt;, then take the product tour and finally share your honest feedback &lt;a href="https://docs.google.com/forms/d/e/1FAIpQLSdwQjiFrQDucmzJspvxO1AuBZD7K2H9Xe04K9To-s2bqx_DYg/viewform?usp=sf_link"&gt;on this survey?&lt;/a&gt;&lt;br&gt;
While you are there, please feel free to try the platform, I am also collecting feedback about it.&lt;br&gt;
Thank you very much, it would help me a lot.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The Many Uses of Feature Flags to Control Your Releases</title>
      <dc:creator>Anthony Brebion</dc:creator>
      <pubDate>Wed, 08 Sep 2021 12:15:09 +0000</pubDate>
      <link>https://dev.to/flagship/the-many-uses-of-feature-flags-to-control-your-releases-49gc</link>
      <guid>https://dev.to/flagship/the-many-uses-of-feature-flags-to-control-your-releases-49gc</guid>
      <description>&lt;p&gt;The use of feature flags has evolved and expanded as teams now recognize the value they can bring to their releases.&lt;/p&gt;

&lt;p&gt;First, let's start with a simple definition of feature flags. &lt;strong&gt;A feature flag is a software development technique that lets you turn functionalities on and off to test new features in production without changing code.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is a technique that can be employed across a wide range of use-cases, from the most simple to more advanced uses as various teams such as engineering and production teams across organizations have begun to recognize the benefits of feature flags in their software release strategy.&lt;/p&gt;

&lt;p&gt;In this article, we will explore these different uses so you can see first-hand exactly what feature flags can do across different contexts depending on your pain points and objectives.&lt;/p&gt;

&lt;p&gt;Many of the use-cases outlined below revolve around one main idea: &lt;strong&gt;risk mitigation&lt;/strong&gt;. There may be a bug in production and you want to turn it off without delaying the release or you have second-thoughts about a feature and you're not ready for all your users to see it. So you'd rather test this feature on a subset of users.&lt;/p&gt;

&lt;p&gt;Feature flags also increase &lt;strong&gt;productivity and speed&lt;/strong&gt; of teams. You're no longer waiting to merge your code if other changes are incomplete; you just put it behind a flag until it's ready. With this, you get more predictability to your releases. There's no need to delay your release cycle for any last-minute bugs detected.&lt;/p&gt;

&lt;p&gt;Therefore, we will see how the use-cases outlined below bring these benefits to your team.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
Prepare for launch

&lt;ul&gt;
&lt;li&gt;Hassle-free deployments: release anytime&lt;/li&gt;
&lt;li&gt;Controlling rollouts: progressive delivery&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
Time your launch

&lt;ul&gt;
&lt;li&gt;Running experiments and A/B testing&lt;/li&gt;
&lt;li&gt;Continuous delivery&lt;/li&gt;
&lt;li&gt;User targeting&lt;/li&gt;
&lt;li&gt;Giving early access&lt;/li&gt;
&lt;li&gt;Power to the users: beta testing&lt;/li&gt;
&lt;li&gt;Dogfooding&lt;/li&gt;
&lt;li&gt;No trespassing allowed: blocking users&lt;/li&gt;
&lt;li&gt;Managing entitlements&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
Other scenarios

&lt;ul&gt;
&lt;li&gt;By pass app store validation&lt;/li&gt;
&lt;li&gt;Kill Switch: turning off features&lt;/li&gt;
&lt;li&gt;Sunsetting features&lt;/li&gt;
&lt;li&gt;Managing migrations&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prepare for launch
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Hassle-free deployments: release anytime
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.flagship.io/feature-flags/"&gt;Feature flags allow you to deploy whenever you and your team sees fit&lt;/a&gt;. You no longer need to delay your releases. Any changes to a feature that are not yet ready can be toggled off with a switch.&lt;/p&gt;

&lt;p&gt;What feature flags do in this scenario is separate code deployment from release. This is done through a release toggle, which allows specific parts of a feature to be activated or deactivated so any unfinished will remain invisible to users until they are ready to be released.&lt;/p&gt;

&lt;p&gt;Why is the distinction between deployment and release significant? To answer this question, it is worth noting the difference between the two terms:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Deployment&lt;/em&gt; is the process of putting code in its final destination on a server or any other place in your infrastructure where your code will run.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Release&lt;/em&gt; is exposing your code to your end-users and so it is the moment when they get access to your new features.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This difference is why we talk about &lt;strong&gt;decoupling deployment from release&lt;/strong&gt; because once you do that, you can push code anywhere, anytime, without impacting your users. Then, you can release gradually and selectively whenever you're ready through progressive and controlled rollouts as we will see below.&lt;/p&gt;

&lt;h3&gt;
  
  
  Controlling rollouts: progressive delivery
&lt;/h3&gt;

&lt;p&gt;With feature flags, you are in complete control. This means once you have a feature ready for release, you can control which subset of users will see this feature through phased rollout of releases.&lt;/p&gt;

&lt;p&gt;Such a practice is referred to as progressive rollout, which builds on continuous delivery to include the use of feature flags to gradually introduce features to your users.&lt;/p&gt;

&lt;p&gt;Rather than releasing to all your users, which is often risky, you may want to release to just 5 or 10% of your users. These users should represent your overall users. Meanwhile, the team observes how these users respond to the new feature before rolling out to everyone else.&lt;/p&gt;

&lt;p&gt;One progressive rollout technique is known as &lt;a href="https://www.flagship.io/canary-deployments/"&gt;canary deployment&lt;/a&gt;. This is where you test how good your feature is on a small group of users and if there's any issue, you can immediately fix it before it's exposed to a larger number of users. This sort of gradual rollout helps mitigate the risk of a so-called big bang release. It also helps ease the pressure on your server in case it cannot handle the load.&lt;/p&gt;

&lt;p&gt;You may also carry out what is known as 'ring deployments'. This technique is used to limit the impact on end-users by gradually rolling out new features to different groups. These groups are represented by an expanding series of rings, hence the name, where you start with a small group and keep expanding this group to eventually encompass all users.&lt;/p&gt;

&lt;p&gt;In a &lt;a href="https://www.flagship.io/glossary/ring-deployment/"&gt;ring deployment&lt;/a&gt;, you choose a group of users based on similar attributes and then make the features available to this group.&lt;/p&gt;

&lt;p&gt;Rings and feature flags work together where feature flags can help you hide certain parts of your feature if they're not ready in any of the deployment rings.&lt;/p&gt;

&lt;p&gt;The advantage of such controlled rollouts is the feedback you would generate from users, especially for releases you're less than confident about and so with the feedback received, you can improve your product accordingly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Time your launch
&lt;/h2&gt;

&lt;p&gt;We know at this point that feature flags give you the control to release at any time you deem suitable.&lt;/p&gt;

&lt;p&gt;Feature flags, then, are important because you always decide the 'when'. As such, with feature flags, you can aim for a timed launch where you push your feature for people in your trusted circle, such as your QA team, to &lt;a href="https://www.flagship.io/testing-in-production/"&gt;test in production&lt;/a&gt;. Afterwards, when it's time to launch, you simply turn on the feature for everyone else without any fuss with the added advantage that you're feeling much more confident when it comes to the actual release to everyone else.&lt;/p&gt;

&lt;p&gt;This significantly reduces stress among your team because you've tested the feature before the official launch and you've made sure it's working as it should before going ahead with a wider release.&lt;/p&gt;

&lt;h3&gt;
  
  
  Running experiments and A/B testing
&lt;/h3&gt;

&lt;p&gt;This is related to the previous point and another variation of controlled rollouts. Feature flags are great for running A/B tests where you can create feature variations and assign a subset of users to each variation and see which performs better.&lt;/p&gt;

&lt;p&gt;This is a great use for product and marketing teams who can easily test new ideas and eliminate them if they don't fulfil the hypothesis defined upon creation of the test.&lt;/p&gt;

&lt;p&gt;For example, feature flags would allow your product and marketing teams to send 50% of users to the new variation of a feature and the other 50% to the original one to compare performance according to the goals set and see which variation runs better.&lt;/p&gt;

&lt;p&gt;Using feature flags to run A/B tests is particularly useful when a feature receives enough traffic to generate efficient results. So, as a cautionary note, keep in mind that not everything can be an A/B test when it comes to feature flags.&lt;/p&gt;

&lt;p&gt;In this sense, you can look at feature flags like a light switch. You decide when you want to turn on the feature, when to turn it off and which users have access to it. This allows you to continuously test in production until you're satisfied with the end-result which you can then roll out to the rest of your users.&lt;/p&gt;

&lt;h3&gt;
  
  
  Continuous delivery
&lt;/h3&gt;

&lt;p&gt;We've already seen that with feature flags, you can release at any time. Consequently, we can deduce that feature flags facilitate the process of continuous delivery.&lt;/p&gt;

&lt;p&gt;Let's imagine you are all set to release but then one developer's changes have not yet been integrated into the main feature branch. Does this mean you need to wait especially when you know time is precious when it comes to releasing to impatient customers in this day and age?&lt;/p&gt;

&lt;p&gt;Feature flags enable continuous delivery because as mentioned, feature flags decouple deployment from release so even unfinished features can be merged but can easily be hidden behind a flag so users don't see it while users get access to all the complete changes for testing.&lt;/p&gt;

&lt;h3&gt;
  
  
  User targeting
&lt;/h3&gt;

&lt;p&gt;You don't just choose the when, you also choose to whom&lt;/p&gt;

&lt;p&gt;Feature flags, as we've seen, gives you a lot of control over the release process by putting the power of when to release in your hands.&lt;/p&gt;

&lt;p&gt;It's worth mentioning yet another form of power feature flags can give you, which is the ability to choose which users can access the feature. When you are testing in production, having the option to choose who you want to test on is extremely valuable depending on the kind of feedback you're seeking.&lt;/p&gt;

&lt;h3&gt;
  
  
  Giving early access
&lt;/h3&gt;

&lt;p&gt;We've seen in canary deployment that sometimes the sample you pick can be completely random. Other times, however, you might decide to carefully handpick a select group of users to give them early access to your new feature.&lt;/p&gt;

&lt;p&gt;Why is this important? Because these are the users that are considered to be 'early adopters'. They are users you trust and whose feedback is the top priority and who are most interested in this particular feature. These users are also the most forgiving should anything go wrong with the release.&lt;/p&gt;

&lt;p&gt;With feature flags, you can release the feature to these early adopters who are more than willing to provide the kind of feedback you need to improve your product. This technique works well if you have a very risky release that you're hesitant to release to a wider audience.&lt;/p&gt;

&lt;h3&gt;
  
  
  Power to the users: beta testing
&lt;/h3&gt;

&lt;p&gt;This is another side to early access where in this scenario users willingly opt-in to test out your new features before they are released to the rest of your users.&lt;/p&gt;

&lt;p&gt;As a result, the customers who opt-in get to see and test the feature by turning it on in their accounts and should they wish to back out they can easily disable the feature, which makes these users more inclined to opt-in in the first place as it makes them feel more in control.&lt;/p&gt;

&lt;p&gt;This is an important use-case because it shows your customers that you're really listening to their feedback by asking them to test your release. The users who opt-in are those who you're targeting with this feature so how they react to the feature will be of extreme use to you. Hence, you get to test out your new feature and you deliver value to your customers by responding to their feedback; it's a win-win situation!&lt;/p&gt;

&lt;h3&gt;
  
  
  Dogfooding
&lt;/h3&gt;

&lt;p&gt;This term refers to eating your own dog food and is another way to test in production but internally.&lt;/p&gt;

&lt;p&gt;Here, you basically release your new features or changes to people within your organization. This is a great way of testing especially when you're introducing new features or major changes that you're not fully confident in.&lt;/p&gt;

&lt;p&gt;This way, you are taking less risks because it's only people within your organization who can see the releases as opposed to your actual, external users who may be more unforgiving in case things take a bad turn during a release.&lt;/p&gt;

&lt;h3&gt;
  
  
  No trespassing allowed: blocking users
&lt;/h3&gt;

&lt;p&gt;Just as you can pick users who you want to access your feature, you can also block users from seeing it. For example, you can block certain users from a particular country or organization.&lt;/p&gt;

&lt;p&gt;What feature flags would allow you to do is hide some features from these less forgiving users who might not give you the right sort of feedback while giving access to the relevant target consumers and who would be most impacted by the new feature.&lt;/p&gt;

&lt;h3&gt;
  
  
  Managing entitlements
&lt;/h3&gt;

&lt;p&gt;With feature flags, you can manage which groups of users get access to different features. This is especially common in SaaS companies that offer various membership plans and so with entitlements, you can dictate which features each plan can access. This way, you would be offering different experiences to your users.&lt;/p&gt;

&lt;p&gt;Let's take the example of Spotify. Spotify offers free and paid plans. With the free membership, you can stream music but with advertisements while with the premium membership, you can stream unlimited music with no ads. You also get unlimited skips and you can download music to listen to offline. There are also different levels of premium to choose from including student and family plans. Consequently, with each plan, you are entitled to different content and features.&lt;/p&gt;

&lt;p&gt;With feature flags, you can wrap a flag around a feature and release it to a particular customer depending on their subscription plan. These types of flags are usually referred to as permission toggles. They also allow you to move features easily between the different plans i.e. paid and free versions, for example.&lt;/p&gt;

&lt;p&gt;Managing entitlements is considered to be an advanced use case as it requires careful coordination across teams and involves working with multiple flags to control permissions for the features. The person who manages entitlements is usually on the product team so careful planning and monitoring of each change performed by which person is required. There should also be a seamless process in place to move users from one plan to another. Thus, this use case requires vigilant implementation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other scenarios
&lt;/h2&gt;

&lt;h3&gt;
  
  
  By pass app store validation
&lt;/h3&gt;

&lt;p&gt;This is when we use A/B testing to test different experiences within mobile apps. Imagine you've just released a brand new app or introduced a new shiny update to your app.&lt;/p&gt;

&lt;p&gt;How can you make sure your app or this update is running smoothly or that you haven't unintentionally introduced an update full of bugs that crashes on your users? Anything that goes wrong will involve a lengthy review process that will setback your entire release as you attempt to locate and resolve the issue.&lt;/p&gt;

&lt;p&gt;You no longer need to wait for app store approval, which could take some time and the changes are released to all users instead of smaller segments.&lt;/p&gt;

&lt;p&gt;Instead, with remote config implemented through feature flags, any changes can be made instantly and remotely and then released to a small subset of users to get feedback before releasing it to everyone else. Therefore, you can upgrade your app continuously in real-time based on feedback from your users without waiting on app store approval.&lt;/p&gt;

&lt;p&gt;It's also a good way to personalize experiences for different types of users rather than creating a unified experience for all users depending on the demographics you set forth.&lt;/p&gt;

&lt;p&gt;As a result, with feature flags, you can roll out different versions of your mobile app to monitor their impact by releasing different features to different groups of users. Afterwards, you can decide on what features will be incorporated in the final release of your app.&lt;/p&gt;

&lt;p&gt;Using feature flags to test out your mobile app is an excellent way to generate buzz around your release by giving exclusive access to a select number of users.&lt;/p&gt;

&lt;h3&gt;
  
  
  Kill Switch: turning off features
&lt;/h3&gt;

&lt;p&gt;Using feature flags will allow you to disable a feature if it's not working as it should. This is done by using a &lt;a href="https://www.flagship.io/glossary/kill-switch/"&gt;kill switch&lt;/a&gt;. Thus, whenever anything goes wrong in production, you can turn it off immediately while your team fixes the issue. This would prevent you from having to roll back the entire release so other changes can be deployed and released without worrying about delaying the whole release.&lt;/p&gt;

&lt;p&gt;With a kill switch, you can switch off a specific, troublesome feature so you can decrease the number of users who can see it, including turning it off for all users if necessary until the issue is analyzed and resolved by your team. This way, you won't have to go through the entire code review process to locate the issue.&lt;/p&gt;

&lt;p&gt;Kill switches therefore give you even more control over the release process. This not only empowers your team of developers but also marketing and production teams with no software development experience who can now easily test in production and kill a feature without having to rely on engineering support.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sunsetting features
&lt;/h3&gt;

&lt;p&gt;Feature flags can also enable the 'sunsetting' of features. For example, with time, you might see your usage of feature flags increasing and widening to encompass a number of features. However, this accumulation of features may eventually turn into a heavy debt.&lt;/p&gt;

&lt;p&gt;This is why it is important to continuously keep track of which features you are using and which features have run their time and need to be retired from your system.&lt;/p&gt;

&lt;p&gt;Sunsetting, then, enables you to kill off features that are no longer being used. Feature flags would give you an idea of the usage of certain features which would help you determine whether it's time to kill it off, lest you end up with the dreaded technical debt.&lt;/p&gt;

&lt;p&gt;Removing unused features and clearing up old flags is the best way to keep such hidden costs in check. Thus, you should have a careful plan in mind to remove some flags once they have served their purpose or otherwise you end up with the aforementioned technical debt. This will require you to have an efficient feature flag management system in place to track down 'stale' flags.&lt;/p&gt;

&lt;h3&gt;
  
  
  Managing migrations
&lt;/h3&gt;

&lt;p&gt;Feature flags can be used to safely and effectively migrate to a new database as business requirements change and evolve. What organizations would normally do before feature flags is a one-time migration then hope for the best as rollbacks are usually a painful process.&lt;/p&gt;

&lt;p&gt;Obviously, the biggest risk that comes with switching databases is loss of data. Therefore, developers need a way to test that the data will remain intact during the migration process.&lt;/p&gt;

&lt;p&gt;Enter feature flags. They allow you to facilitate migration and should something go wrong, you can disable the migration by simply toggling the flag off.&lt;/p&gt;

&lt;p&gt;A percentage rollout can then be implemented using feature flags to validate the new database and any changes can be reversed by using feature flags as a kill switch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bottomline&lt;/strong&gt;: Use feature flags, use them often but proceed with caution.&lt;/p&gt;

&lt;p&gt;As we've seen so far, many of the use cases can be easily implemented. However, others will require the ability to make detailed, complex and context-specific decisions so a more &lt;a href="https://www.flagship.io/"&gt;advanced feature flagging system that enables such functionalities&lt;/a&gt; would be needed.&lt;/p&gt;

&lt;p&gt;Regardless of what you decide to use feature flags for, one thing is clear: feature flags put you in the driver seat when it comes to releases. You are in complete control of the when and to whom you release. It also allows you to experiment to your heart's content but without the risks, especially when the release doesn't go as expected.&lt;/p&gt;

&lt;p&gt;Working with feature flags also increases productivity among teams. As we've seen in the use-cases outlined above, it's not just developers who have complete control over and access to the release process but product and operations teams can release and roll back as needed.&lt;/p&gt;

&lt;p&gt;You can use feature flags for many things across different contexts. Some may remain for a long period of time while others need to be extracted as soon as possible so as not to run into technical debt.&lt;/p&gt;

&lt;p&gt;Thus, the general advice would be to use feature flags often but keep in mind that proactive flag management and implementation will be needed to maximize the benefits while minimizing the costs.&lt;/p&gt;

&lt;p&gt;Don't just take our word for it. Start your feature flag journey and see for yourself what feature flags can do for you by signing up for a &lt;a href="https://www.flagship.io/sign-up/"&gt;free trial at Flagship by AB Tasty&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>featureflag</category>
      <category>release</category>
      <category>agile</category>
      <category>devops</category>
    </item>
    <item>
      <title>How to Implement Feature Flags in a React JS App</title>
      <dc:creator>Anthony Brebion</dc:creator>
      <pubDate>Mon, 05 Jul 2021 14:25:31 +0000</pubDate>
      <link>https://dev.to/flagship/how-to-implement-feature-flags-in-a-react-app-1dk2</link>
      <guid>https://dev.to/flagship/how-to-implement-feature-flags-in-a-react-app-1dk2</guid>
      <description>&lt;p&gt;We discuss three ways to implement feature flags in your React apps, from the DIY approach to third party cloud based solutions through open source libraries.&lt;/p&gt;

&lt;p&gt;Feature flags, or toggles, as described by Martin Fowler are a "powerful technique, allowing teams to modify system behavior without changing code." In other words, implementing feature flags as a set of patterns is a robust way to manage code complexity and deliver new features to users using CI/CD pipelines, reducing the time to value and decreasing the risk of deploying buggy, error-ridden code to production.&lt;/p&gt;

&lt;p&gt;In summary, there are 4 different types of feature flags each with a different use case:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Release flags:&lt;/strong&gt; These are temporary feature toggles, providing software developers with the ability to ship untested code as latent code that might never be turned on.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Experiment flags:&lt;/strong&gt; These flags or toggles are utilized to perform A/B or multivariate testing. This is a highly dynamic flag and is only functional until statistically significant results are generated before the flag is removed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ops flags:&lt;/strong&gt; These flags are usually short-lived and can be introduced when rolling out a new feature that has unclear performance implications, providing the operations team with the ability to disable this feature very quickly after the deployment has completed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Permissioning flags:&lt;/strong&gt; Permissioning flags are generally long-lived and are used to manage the features and groups of features that specific groups of users can access, such as premium features that paying customers can access.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Implementing feature flags inside React projects
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.flagship.io/feature-flags/"&gt;Feature flags&lt;/a&gt; are an integral part of deploying software updates via CI/CD pipelines without disrupting existing functionality. There are several ways to implement feature flags in your React apps. Let's consider three of the most popular and common ways:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The do-it-yourself method where the developer writes the feature flag code from scratch.&lt;/li&gt;
&lt;li&gt;The use of open-source libraries that are integrated into the React Single-Page Application (SPA).&lt;/li&gt;
&lt;li&gt;Signing up with a cloud based solution.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Do it yourself: A simple and free solution
&lt;/h2&gt;

&lt;p&gt;This method requires you to write code, switching feature flags on and off directly in JavaScript. By expanding on this method, let's consider a simple use case, including code samples from a feature flag React app project, before looking at the primary pros and cons of this method.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Setting up the React project
&lt;/h3&gt;

&lt;p&gt;If you already have your React project set up, you can skip to the next section, "Adding new feature flags" otherwise, here is a step-by-step guide to setting up a new project.&lt;/p&gt;

&lt;p&gt;The reactjs.org website notes that the create-react-app is the easiest way to develop a new single-page application with React.&lt;/p&gt;

&lt;p&gt;Therefore, use the following code to create a new boilerplate app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app my-app
cd my-app
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Adding new feature flags
&lt;/h3&gt;

&lt;p&gt;Now that we have the project created and an empty app template, let's look at how to add a feature flag in React.&lt;/p&gt;

&lt;p&gt;Feature flags can be stored in different places such as a database server, inside local storage, or in a cookie. In this scenario, we will store them inside local storage.&lt;/p&gt;

&lt;p&gt;The first step is to create a Reactjs feature flag file with the following format used to create new features. This will act as your config file that you'll update every time you want to turn on/off a specific feature.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;[{&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;banner&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Banner shown on top of the page&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;active&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;span class="p"&gt;}]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each feature flag must have a unique name that we can later call or reference in React. A short description is also needed to describe the functionality it adds and an active flag to determine whether the toggle is on or off.&lt;/p&gt;

&lt;p&gt;As seen from the code snippet for creating a banner flag, our flags are stored inside an array.&lt;/p&gt;

&lt;p&gt;To store these flags in local storage, add the following function to your app.js file and call it at the top of your feature component file.&lt;/p&gt;

&lt;p&gt;Note: This will create 3 new feature flags if there are no feature flags created in local storage (localStorage). You also need to use the JSON.stringify () method to convert the JavaScript objects into strings as localStorage can only handle strings.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;initFeatures&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;flags&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;flags&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;banner&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Banner shown on top of the page&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;active&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;reporting-yn&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Switch on reporting modules for premium clients&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;active&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;info-message&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Enhance info message with icon and link&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;active&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;]));&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;initFeatures&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Adding the feature component
&lt;/h3&gt;

&lt;p&gt;In order to reference these feature flags in React and show/hide features based on these feature flags, you need to create a new React component . Define it in a file called feature.js and store it in your src folder.&lt;/p&gt;

&lt;p&gt;This component accepts 2 props:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the flag name to check against,&lt;/li&gt;
&lt;li&gt;the child content to be used (children prop).&lt;/li&gt;
&lt;li&gt;The first step is to get the feature from localStorage and see if it is set to active or not. If the feature is active, we can render the feature; otherwise, we return null.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Feature&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;features&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;flags&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;feature&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;features&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;feature&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;feature&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;feature&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;feature&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;active&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Feature&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This component will handle the toggling of feature flags on and off. Finally, you just import and render the component where you need.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Feature&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./feature&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;initFeatures&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'App'&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Feature&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'banner'&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Banner&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Feature&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Pros
&lt;/h3&gt;

&lt;p&gt;There are several advantages to using this method. The most obvious being the fact that when writing your own feature flag code, it is free, easily accessible, and highly available for small React feature toggle projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cons
&lt;/h3&gt;

&lt;p&gt;However, what happens when your application grows in scale, and you need to create and manage several different feature flags, both long- and short-lived?&lt;/p&gt;

&lt;p&gt;This is where this method's disadvantages come to the fore. Succinctly stated, this method is difficult to scale where lots of flags are utilized. And as you can see from the code samples highlighted above, advanced features require more development work which can be challenging and complicated to maintain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Feature flag open-source libraries for React
&lt;/h2&gt;

&lt;p&gt;The second method is to use existing libraries that you can find on NPM or Github. A simple search for "feature flag" will lead you to multiple open-source libraries or packages. Here are a few examples of these packages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/react-feature-flags"&gt;React-Feature-Flags&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/feature-toggle-api"&gt;Feature-Toggle-API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/react-unleash-flags"&gt;React Unleash Flags&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/sergiodxa/flagged"&gt;Flagged&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Flagged, for instance, provides nice features such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hooks API&lt;/li&gt;
&lt;li&gt;High Order Component API&lt;/li&gt;
&lt;li&gt;Render Props API&lt;/li&gt;
&lt;li&gt;TypeScript Support&lt;/li&gt;
&lt;li&gt;Zero Dependencies&lt;/li&gt;
&lt;li&gt;Nested Flags&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Pros
&lt;/h3&gt;

&lt;p&gt;The advantages of using these open-source libraries are that they are freely available, easy to use, and quick to set up. As described above, all you need to do is consume the libraries into your application and then call the functions created in the library files, passing in variables as required and reading returned variables to understand the state of your feature flags.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cons
&lt;/h3&gt;

&lt;p&gt;However, as with everything, there are also disadvantages to using open-source feature flag libraries. The most prominent includes the fact that maintenance and evolution are not guaranteed, and the library's functional scope might not suit your app's specific requirements. In both cases, a fair amount of refactoring and new code development will have to take place to maintain the existing code and add the features specific to your application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Feature flag management platforms
&lt;/h2&gt;

&lt;p&gt;The third and last way to implement feature flags in a single-page application is using a dedicated feature flag management 3rd-party service that provides a React integration.&lt;/p&gt;

&lt;p&gt;By way of expanding on this statement, let's look at a step-by-step guide on how to set up feature flags in Flagship.io with the React SDK. As an alternative, you can also directly call the Flagship Decision API (REST API), but for the sake of simplicity we'll use the dedicated SDK that provides additional capabilities out of the box (ex: bucketing). The platform also provides additional SDKs for JAVA, Python, PHP, .Net, Go, iOS, Android, Flutter...&lt;/p&gt;

&lt;p&gt;As a cloud-based feature management service, using Flagship.io is a 2- step process. First, in your codebase, you wrap your features once with flags using methods and providers from the React SDK. Once this is done, you remotely configure your flags (values, segments…) from the Flagship.io dashboard.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Set up the React SDK in your SPA project and wrap features with flags
&lt;/h3&gt;

&lt;p&gt;Let's use the same project that we created in the first method (Setting up the project) using our create-react-app boilerplate app.&lt;/p&gt;

&lt;p&gt;Install the SDK using NPM or yarn.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @flagship.io/react-sdk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Import the Flagship provider from the React SDK which makes Flagship features available to the rest of your app. You can wrap your app directly within the app.js file.&lt;/p&gt;

&lt;p&gt;The envID and apiKey props are required. You access them from the Flagship UI under the "Settings" section. For more information on the different props available, please refer to the &lt;a href="https://developers.flagship.io/docs/sdk/react/v2.1"&gt;API references&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;FlagshipProvider&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@flagship.io/react-sdk&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;FlagshipProvider&lt;/span&gt;
      &lt;span class="na"&gt;envId&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"YOUR_ENV_ID"&lt;/span&gt;
      &lt;span class="na"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"YOUR_API_KEY"&lt;/span&gt;
      &lt;span class="na"&gt;visitorData&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;YOUR_VISITOR_ID&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="c1"&gt;// some context&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;isAuthenticated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="na"&gt;enableConsoleLogs&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* [...] */&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;FlagshipProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, from the React component you want to get access to your flags, import and use one of our React Hook. useFlagship hook is the most useful one from our React SDK. It gets modifications assigned to the current user as well as further functionalities, such as sending hit tracking, checking the SDK status…&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useFlagship&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@flagship.io/react-sdk&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MyReactComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fsParams&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;modifications&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;requested&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;btnColor&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// btnColor is your flag identifier that should be declared in the Flagship UI&lt;/span&gt;
        &lt;span class="na"&gt;defaultValue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;green&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;activate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;modifications&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;fsModifications&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;fsStatus&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;hit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;fsHit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useFlagship&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fsParams&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;
      &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;200px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;200px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;modifications&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I'm a square with color=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;modifications&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;backgroundColor&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Declare your flags in the Flagship UI and set up values
&lt;/h3&gt;

&lt;p&gt;The first step is to &lt;a href="https://www.flagship.io/sign-up/"&gt;sign up with Flagship.io&lt;/a&gt; and sign into your account.&lt;/p&gt;

&lt;p&gt;You can refer to this short video that goes through all the process of a feature flag setup or read the detailed instructions below.&lt;/p&gt;

&lt;h4&gt;
  
  
  Creating your feature flag use case
&lt;/h4&gt;

&lt;p&gt;To create a feature flag from the dashboard, apply the following steps:&lt;/p&gt;

&lt;p&gt;Go to the Flagship dashboard.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click the + button.&lt;/li&gt;
&lt;li&gt;Choose an existing project or create a new one&lt;/li&gt;
&lt;li&gt;Click the "Add a use case" button.&lt;/li&gt;
&lt;li&gt;You are presented with a list of different templates or use cases (ex: progressive rollout, A/B test...)&lt;/li&gt;
&lt;li&gt;Choose the "Feature toggling" template.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Entering the basic information
&lt;/h4&gt;

&lt;p&gt;First, you need to enter the basic information of your feature flag use case:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The feature name: use the most representative name for your feature, because this is the one you'll need to remember in case you want to find it later.&lt;/li&gt;
&lt;li&gt;The feature description: explain exactly what your feature deployment is about and what its purpose for your business is.&lt;/li&gt;
&lt;li&gt;The primary/secondary metric to follow (optional) which will serve as a point of reference to analyze performance. For more information, refer to Configuring KPIs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Defining flags
&lt;/h4&gt;

&lt;p&gt;This is where you configure the flags and their values based on your different scenarios. Think of it as the config file mentioned in the first method, but that you manage remotely from the cloud. Important: flag names you specify here should match the ones used in your codebase ("btnColor" in your code example above).&lt;/p&gt;

&lt;h4&gt;
  
  
  Defining targeting
&lt;/h4&gt;

&lt;p&gt;During this step, you can define which users will be assigned to your different flag values. This is a segmentation engine built into the platform that makes it easy to assign flags conditionally based on user traits (or attributes) that you have access to in your codebase. Refer to this article about feature flag targeting for more information. The 3 following options are available:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All Users if you want all your users to progressively see your feature.&lt;/li&gt;
&lt;li&gt;Users by ID if you want only users with a specific ID to see your feature.&lt;/li&gt;
&lt;li&gt;Key if you only want users matching this key value to see your feature.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Enabling your feature
&lt;/h4&gt;

&lt;p&gt;Once you have configured your feature, it is OFF by default to allow you to check that it is correctly configured. Back to the dashboard, you can activate your feature ON when you are ready!&lt;/p&gt;

&lt;p&gt;And that's it. Now, provided changes to your codebase have been deployed, you can activate/deactivate feature flags, remotely change their values and have your React App react instantly to these changes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Last thoughts
&lt;/h3&gt;

&lt;p&gt;This article describes three ways of implementing feature flags in a React SPA (single-page application):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the do-it-yourself method,&lt;/li&gt;
&lt;li&gt;using open-source libraries,&lt;/li&gt;
&lt;li&gt;signing up with a dedicated feature management platform.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While there are pros and cons to each approach, the third-party vendor option is probably the most efficient method for large teams with evolving use cases that don't want to deal with the &lt;a href="https://www.flagship.io/feature-flag-journey/"&gt;challenges of an in-house system&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>featureflags</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
