Feature flags
Pass visitor data into your docs through a feature flag provider.
Last updated
Was this helpful?
Pass visitor data into your docs through a feature flag provider.
Last updated
Was this helpful?
Was this helpful?
Using adaptive content with feature flags requires adding code to your application.
Currently, the GitBook helper only supports React based setups.
GitBook provides helper functions and integrations for popular feature flag service providers like and .
This allows you to read the feature flags users have access to in your product, as they read your docs. This is useful if you need to show documentation for features that are only available to a specific group of people.
LaunchDarkly allows you to send feature flag access as claims through the launchdarkly-react-client-sdk
and GitBook’s package.
If you’re using LaunchDarkly feature flags in your product already, chances are you already have this package configured.
To pass you these feature flags as claims to GitBook, follow these steps:
To get started, you’ll first need to install the LaunchDarkly integration into your GitBook site.
After setting your visitor schema, you’re ready to tailor your docs experience for the users visiting your site, using the feature flags the user has access to.
Any feature flag value available in LaunchDarkly will be exposed as part of the visitor schema under the unsigned.launchdarkly.flags
object. Read more about unsigned claims .
Head to to learn more about personalizing your docs for your users.
Bucket allows you to send feature flag access as claims through the @bucketco/react-sdk
and GitBook’s @gitbook/adaptive
package.
If you’re using Bucket feature flags in your product already, chances are you already have this package configured.
To pass you these feature flags as claims to GitBook, follow these steps:
To get started, you’ll first need to install the Bucket integration into your GitBook site.
After setting your visitor schema, you’re ready to tailor your docs experience for the users visiting your site, using the feature flags the user has access to.
Any feature flag value available in Bucket will be exposed as part of the visitor schema under the unsigned.bucket.flags
object. Read more about unsigned claims .
Head to to learn more about personalizing your docs for your users.
npm install @gitbook/adaptive
import { render } from 'react-dom';
import { withLaunchDarkly } from '@gitbook/adaptive';
import { asyncWithLDProvider, useLDClient } from 'launchdarkly-react-client-sdk';
import MyApplication from './MyApplication';
function PassFeatureFlagsToGitBookSite() {
const ldClient = useLDClient();
React.useEffect(() => {
if (!ldClient) {
return;
}
return withLaunchDarkly(ldClient);
}, [ldClient]);
return null;
}
(async () => {
const LDProvider = await asyncWithLDProvider({
clientSideID: 'client-side-id-123abc',
context: {
kind: 'user',
key: 'user-key-123abc',
name: 'Sandy Smith',
email: 'sandy@example.com'
},
options: { /* ... */ }
});
render(
<LDProvider>
<PassFeatureFlagsToGitBookSite />
<MyApplication />
</LDProvider>,
document.getElementById('reactDiv'),
);
})();
npm install @gitbook/adaptive
import { withBucket } from '@gitbook/adaptive';
import { BucketProvider, useClient } from '@bucketco/react-sdk';
import MyApplication from './MyApplication';
function PassFeatureFlagsToGitBookSite() {
const client = useClient();
React.useEffect(() => {
if (!client) {
return;
}
return withBucket(client);
}, [client]);
return null;
}
export function Application() {
const currentUser = useLoggedInUser();
const appConfig = useAppConfig();
return (
<BucketProvider
publishableKey={appConfig.bucketCo.publishableKey}
user={{
id: currentUser.uid,
email: currentUser.email ?? undefined,
name: currentUser.displayName ?? '',
}}
company={{
id: currentUser.company.id,
}}
>
<PassFeatureFlagsToGitBookSite />
<MyApplication />
</BucketProvider>
);
}