Feature Flags

Control documentation visibility with LaunchDarkly

Fern supports conditional rendering of documentation content using feature flags, powered by LaunchDarkly integration. Control visibility of documentation sections based on feature flag states for different release stages or user segments.

Use Cases

Feature flags in documentation are particularly useful for:

  • Regional Content: Show content based on geography (e.g., EU vs. US endpoints)
  • Product Tiers: Display features based on subscription levels
  • Beta Features: Allow specific users to see beta documentation
  • Staged Rollouts: Gradually release documentation for new features
  • A/B Testing: Test different documentation approaches with different user segments

Configuration

Configure feature flags in docs.yml:

1navigation:
2 # Simple boolean flag
3 - page: Beta Features
4 feature-flag: beta-features
5
6 # Multiple flags (if any flag is true, the content will be shown)
7 - page: Advanced Features
8 feature:
9 - flag: feature-a
10 - flag: feature-b
11
12 # Configurable match
13 - section: Enterprise Features
14 feature-flag:
15 flag: release-stage
16 fallback-value: ga
17 match: beta

To read more about fallbackValue and match, see the LaunchDarkly documentation.

Using Feature Flags in MDX

Use the <Feature> component to conditionally render content:

1<Feature flag="deployment-region" match="commercial" fallbackValue="commercial">
2 <table class="fern-table">
3 <tr>
4 <th>Service</th>
5 <th>Endpoint</th>
6 </tr>
7 <tr>
8 <td>API Gateway</td>
9 <td><code>https://api.example.com</code></td>
10 </tr>
11 </table>
12</Feature>

Component Properties

flag
stringRequired

Name of the feature flag to check against

match
boolean | stringRequired

Value to match against the feature flag’s value

fallbackValue
boolean | string

Default value if the feature flag is not defined

Example: Complete Configuration

1# docs.yml
2title: API Documentation
3navigation:
4 - section: Features
5 feature-flag: features-enabled
6 layout:
7 - page: Basic Features
8 - page: Advanced Features
9 feature-flag: advanced-features
10 - page: Beta Features
11 feature:
12 - flag: beta-access
13 - flag: beta-opted-in
14
15 - section: Enterprise
16 feature-flag:
17 flag: customer-tier
18 match: enterprise
19 fallbackValue: standard

Real-time Evaluation

Feature flags are client-side only. The information is only visually hidden when the feature flag is evaluated as false.

If you toggle a feature flag on in the LaunchDarkly dashboard, the content will be shown immediately.

Conversely, if you toggle a feature flag off in the LaunchDarkly dashboard, the content will be hidden immediately.

Server-side Evaluation

Feature flags are client-side only. Want to request server-side evaluation? Let us know by filing a feature request.

Additional Feature Flag Providers

Want to request a new feature flag provider? Let us know by filing a feature request.