> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flagsync.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Integrate the SDK

> Integrate the FlagSync JavaScript SDK to use your feature flags in code.

## Using the JavaScript SDK

With your `new-feature` flag created, bring it into your app with the JavaScript SDK.

<Note>
  Check out our [other SDKs](/sdks/overview) for **Node.js**, **Next.js**, **React**, and more.
</Note>

<Steps>
  <Step title="Install the SDK">
    Install the SDK with your preferred package manager:

    <CodeGroup>
      ```bash npm theme={null}
      npm install @flagsync/js-sdk
      npm install -D @flagsync/cli
      ```

      ```bash yarn theme={null}
      yarn add @flagsync/js-sdk
      yarn add -D @flagsync/cli
      ```

      ```bash pnpm theme={null}
      pnpm add @flagsync/js-sdk
      pnpm add -D @flagsync/cli
      ```
    </CodeGroup>
  </Step>

  <Step title="Initialize the SDK">
    Create a client with your SDK key and a unique user identifier, such as user ID or email.

    ```typescript theme={null}
    import { FlagSyncFactory } from '@flagsync/js-sdk';

    const factory = FlagSyncFactory({
      sdkKey: 'your-sdk-key', // Replace with your SDK key
      core: {
        key: 'userId_0x123' // Unique identifier
      }
    });

    const client = factory.client();
    ```

    <Tip>
      Get your SDK key from your [Workspace settings](https://www.flagsync.com/dashboard/settings/organization/workspaces/) for the target Environment.
    </Tip>
  </Step>

  <Step title="Wait for Readiness">
    Ensure the SDK is ready before checking flags:

    ```typescript theme={null}
    await client.waitForReady();
    console.log('SDK is ready!');
    ```
  </Step>

  <Step title="Evaluate Your Flag">
    Get the `new-feature` flag’s value:

    ```typescript theme={null}
    const value = client.flag<boolean>('new-feature');
    console.log(value);
    ```

    <Note>
      Calling `flag()` automatically logs an impression, tracking which variant each user sees—vital for metrics later.
    </Note>
  </Step>

  <Step title="Putting it all together">
    Here's the full example:

    ```typescript theme={null}
    import { FlagSyncFactory } from '@flagsync/js-sdk';

    const factory = FlagSyncFactory({
      sdkKey: 'your-sdk-key', // Replace with your SDK key
      core: {
        key: 'userId_0x123' // Unique identifier
      }
    });

    const client = factory.client();

    await client.waitForReady();
    console.log('SDK is ready!');

    const value = client.flag<boolean>('new-feature');
    console.log(value);
    ```
  </Step>
</Steps>

## Next Steps

The SDK is ready—now track user actions:

* Send events in [Quickstart: Send Events](/quickstarts/events).
* Explore targeting in [Targeting & Rollouts](/flags/targeting-and-rollouts).
* See other options in [other SDKs](/sdks/overview)
