[Feature flags](🔗), also known as **feature toggles**, are a software development technique that lets you turn certain functionality on and off without deploying new code. This allows for better control and more experimentation over the full lifecycle of features. You can toggle a feature off to release code quickly without exposing it to users. You can also roll it out to a fraction of your user base to minimize the impact of the launch, allowing you to validate functionality and measure performance prior to rolling out broadly.
Full Stack supports advanced feature flagging through the core concept of a **feature** identified by a unique key like `
shopping_cart` or `
price_filter`. You can create a new feature and manage its rollout under the Features tab, or build a feature test in the Experiments tab.
## Create a feature
To create a feature:
Click _Features > Create New Feature…_.
Give the feature a unique key (and optional description). Valid keys contain alphanumeric characters, hyphens, and underscores, are limited to 64 characters, and can't contain spaces. You’ll use the feature key to determine whether the feature is on or off in your code.
Click _Create Feature_.
Implement the feature flag. At the bottom of the Create New Feature modal, Optimizely automatically populates example code for an API call with your feature key:
The example below shows how you can evaluate the feature flag with the `
Is Feature Enabled` method. This lets you build conditional branches in your code, showing the feature if enabled is `
true` and hiding it otherwise. You can also get a list of all the features that are enabled for a user using the `
Get Enabled Features` method.
The goal of these methods is to separate the process of developing and releasing code from the decision to turn a feature on. Build your feature and deploy it to your application behind this flag, then turn the feature on or off for specific users by running tests and rollouts. The value this method returns is determined by your test(s) and rollout associated with the feature. For example, if the current user is assigned to a variation in a feature test for which the feature is on, the method returns `
true`. Otherwise, it returns `
## Configuration variables
In addition to binary flagging, features also support **variables** for remote configuration. This lets you parameterize the feature and configure its settings without deploying new code. For example, you can tune the parameters of a search algorithm or the display of a user interface.
See [Define feature variables](🔗).
## Toggles and rollouts
Feature flags support **remote toggling**, so you can turn a feature on or off directly from the Optimizely dashboard. This means you can deploy code silently, then toggle an individual feature on without impacting other features in your release. It also supports **incremental rollouts** so you can launch a feature to a targeted subset your users. For example, you can launch a new feature to a random 10% of all users, or to a specific audience of beta testers. If anything goes wrong, you can immediately roll back without redeploying your app.
See [Rollout and rollback features](🔗).
## Feature tests
Full Stack enables you to experiment on the features you build. You can build a [feature test](🔗) to measure whether your feature raises key metrics, or if it actually hurts them. For example, did a redesigned homepage lead to higher revenue, or did it actually slow down the app? You can also test different configurations against each other to find the ideal combination of variables to show different users.
See [Run feature tests](🔗).