Skip to content

FlagDiligence docs

Getting started

From a new account to a working flag in your code.

Before you begin

  • A modern web browser for the dashboard.
  • Node.js 18 or newer for the Node.js SDK.
  • React 16.8 or newer for the React SDK.

1. Create your account and workspace

  1. Sign upOpen FlagDiligence and choose Sign up, then log in.
  2. Create an organizationThis is your company or team workspace. Members and roles live here.
  3. Create a projectA project groups the flags for one application or service. It starts with three environments: Development, Staging and Production.
  4. Copy an SDK keyEach environment has a server key and a client key. Use the key for the environment your code runs in.

2. Create your first flag

In your project choose Create flag. Give it a readable name (for example New checkout flow) and a key you will use in code (for example new_checkout_flow). Leave the type as Boolean for now.

Switch it on in Development. Flags are configured per environment, so this does not affect Staging or Production.

3. Use it in your code

On a server (Node.js):

import { init } from '@weborlabs/flagdiligence-node';

const client = init({
  sdkKey: 'sdk-server_your_key',
  baseUrl: 'https://your-flagdiligence-host',
  mode: 'streaming',
});
await client.init();

const user = { key: 'user-123', email: 'user@example.com' };

if (client.variation('new_checkout_flow', user, false)) {
  // new checkout
} else {
  // current checkout
}

In a React app:

import { FlagDiligenceProvider, useBooleanFlag } from '@weborlabs/flagdiligence-react';

function App() {
  return (
    <FlagDiligenceProvider
      sdkKey="sdk-client_your_key"
      baseUrl="https://your-flagdiligence-host"
      mode="streaming"
      user={{ key: 'user-123', email: 'user@example.com' }}
    >
      <Checkout />
    </FlagDiligenceProvider>
  );
}

function Checkout() {
  const { enabled, isLoading } = useBooleanFlag('new_checkout_flow', false);
  if (isLoading) return null;
  return enabled ? <NewCheckout /> : <OldCheckout />;
}

The last argument of variation is the default. It is returned if the flag does not exist or the SDK cannot reach the server, so choose the safe behaviour. Use the server key only on servers; the client key is safe in front-end code.

4. Release gradually

When you are ready, enable the flag in Staging, test both the on and off states, then enable it in Production with a small rollout percentage. See Core concepts and how to roll out safely.

Core concepts →

Need help with FlagDiligence?

Open the app, or tell us what you are trying to do.