> ## 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.

# Overview

> Understand how FlagSync evaluates flags for users.

## Flag Evaluation Flow

FlagSync evaluates flags using the same logic flow across SDKs:

<Steps>
  <Step title="Is the SDK ready?">
    If not, the SDK returns the `defaultValue` (e.g., `false`) or `control` string.

    ```typescript theme={null}
    // Before SDK is ready
    const one = client.flag('flag-one', false); // false (defaultValue)
    const two = client.flag('flag-two'); // "control"
    await client.waitForReady();
    ```

    <Info>
      Client-side SDKs can bootstrap via `LocalStorage` or from an initial flag set, using those values until the SDK initializes with server data.
    </Info>
  </Step>

  <Step title="Does the flag key exist?">
    If the flag key isn’t found, the SDK returns the `defaultValue` or `control`.

    ```typescript theme={null}
    // Unknown flag, returns true (defaultValue)
    const value = client.flag('foobarbaz', true);
    ```

    <Info>
      If the flag key was included in the bootstrapped values, this value will be returned.
    </Info>
  </Step>

  <Step title="Is the flag disabled?">
    * If **disabled**: The default "off" variant is returned, halting further evaluation.
    * If **enabled**: The algorithm proceeds to targeting and rollout checks.

    <Tip>
      Explore [Flags: All Users](/flags/targeting-and-rollouts#all-users) to learn about default variants.
    </Tip>
  </Step>

  <Step title="Does the flag have Targeting Rules?">
    * See [Targeting](/sdks-flag-evaluation/targeting) for evaluation logic.
    * See [Flags: User Segments](/flags/targeting-and-rollouts#user-segments) to learn about targeting rules.
  </Step>

  <Step title="Does the flag have a Percentage Rollout?">
    * See [Rollouts](/sdks-flag-evaluation/rollouts) for evaluation logic.
    * See [Flags: Percentage Rollouts](/flags/targeting-and-rollouts#percentage-rollouts) to learn about rollouts.
  </Step>

  <Step title="Fallback">
    Returns the "on" variant if no rules or percentages apply.

    <Tip>
      See [Flags: All Users](/flags/targeting-and-rollouts#all-users) to learn about default variants.
    </Tip>
  </Step>
</Steps>

### Flow Diagram

```mermaid theme={null}
graph TD
    A[Start] --> B{SDK Ready?}
    B -->|No| C[Return defaultValue/control]
    B -->|Yes| D{Flag Exists?}
    D -->|No| C
    D -->|Yes| F{Flag Enabled?}
    F -->|No| G[Return 'off' variant]
    F -->|Yes| H{Targeting Rules?}
    H -->|Yes| I{Evaluate Rules}
    H -->|No| J{Percentage Rollout?}
    I -->|Match Found| M[Return rule variant]
    I -->|No Match| J
    J -->|Yes| K[Return rollout variant]
    J -->|No| L[Return 'on' variant]
    C & G & M & L & K --> O[End]
```

## Next Steps

Dive deeper into the flag evaluation process:

* Learn targeting logic in [Targeting](/sdks-flag-evaluation/targeting).
* Explore rollout evaluation in [Rollouts](/sdks-flag-evaluation/rollouts).
* Start with [Quickstart: SDK](/quickstarts/sdk)
