> For the complete documentation index, see [llms.txt](https://docs.hackle.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hackle.io/en/development-guide/sdk/evaluation-mode/local-evaluation.md).

# Local Evaluation

Local Evaluation is a mode in which the SDK performs evaluation directly on the user's device.

Because there is no server communication for evaluation, distribution is handled without re-syncing with the server even when user information changes.\
It is the default evaluation mode for all Hackle SDKs and can be used without any additional configuration.

### Feature Support

Local Evaluation evaluates based on user information stored on the device.

{% hint style="info" %}
Local Evaluation does not sync with user information stored on the Hackle server.

* To use User Property-based targeting, the required properties must be stored on the device or in the browser.
* We recommend setting User Properties when the user logs in.
* User Properties set in the app are stored on the device. They are retained until the app is deleted.
  {% endhint %}

<table><thead><tr><th width="469.87890625">Feature</th><th align="center">Local Evaluation</th><th align="center">Remote Evaluation</th></tr></thead><tbody><tr><td>A/B Test distribution</td><td align="center">✅</td><td align="center">✅</td></tr><tr><td>Feature Flag decision</td><td align="center">✅</td><td align="center">✅</td></tr><tr><td>Remote Config lookup</td><td align="center">✅</td><td align="center">✅</td></tr><tr><td>Evaluation based on user information stored on the device</td><td align="center">✅</td><td align="center">❌</td></tr><tr><td>Evaluation based on user information stored on the server</td><td align="center">❌</td><td align="center">✅</td></tr><tr><td>Re-evaluation without server communication when user information changes</td><td align="center">✅</td><td align="center">❌</td></tr></tbody></table>

### How It Works

During initialization, the SDK fetches the workspace configuration, such as A/B Tests and Feature Flags, and stores it internally.\
When distribution is needed, the SDK evaluates directly using the stored configuration.

```mermaid
sequenceDiagram
    participant App as Client
    participant SDK as SDK (Local Evaluation engine)
    participant Hackle as Hackle server

    App->>SDK: Initialize SDK
    SDK->>Hackle: Request workspace configuration
    activate Hackle
    Hackle-->>SDK: Workspace configuration
    deactivate Hackle
    Note over SDK: Store the configuration internally

    App->>SDK: Distribution/decision call
    SDK->>SDK: Evaluate directly with the stored configuration<br/>(no network call)

    opt User information changes (setUser, property update, etc.)
        App->>SDK: Change user information
        SDK->>SDK: Re-evaluate with the stored configuration<br/>(no need to re-sync with the server)
    end

    opt Configuration refresh (fetch call)
        App->>SDK: Call fetch
        SDK->>Hackle: Request the latest configuration
        activate Hackle
        Hackle-->>SDK: Workspace configuration
        deactivate Hackle
        Note over SDK: Update the stored configuration
    end

```

1. On SDK initialization, the SDK fetches the workspace configuration, such as A/B Tests and Feature Flags, from the Hackle server and stores it internally.
2. On a distribution/decision call, the SDK evaluates directly using the stored configuration.\
   No network call occurs in this process.

{% hint style="success" %}
Except when fetching the workspace configuration, Local Evaluation handles distribution without server communication or network delay for evaluation.
{% endhint %}

### When User Information Changes

When the User Identifier changes (`setUser`, `setUserId`, `setDeviceId`, `resetUser`) or User Properties are updated, the SDK stores the user information in its internal storage.

When functions such as A/B Test are called, distribution is processed in real time using that user information.

### Reflecting Dashboard Changes

Local Evaluation evaluates based on the configuration stored inside the SDK.\
Evaluation is based on **when the configuration was fetched**, not on the Dashboard settings at the moment the distribution/decision was called.

The configuration stored in the SDK is updated at the following points:

* On SDK initialization
* When the SDK's `fetch` function is called

{% hint style="warning" %}
Even if you adjust an A/B Test's traffic allocation or turn a Feature Flag on or off in the Dashboard, evaluation uses the existing configuration until the SDK fetches the configuration again.

To apply the changed settings, reinitialize the SDK or call the `fetch` function.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.hackle.io/en/development-guide/sdk/evaluation-mode/local-evaluation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
