# Managing local state

Interacting with local data in Apollo Client

At its core, Apollo Client is a **state management** library that happens to use GraphQL to interact with a remote server. Naturally, some application state doesn't _require_ a remote server because it's entirely local.

Apollo Client enables you to manage local state alongside remotely fetched state, meaning you can interact with _all_ of your application's state with a single API.

## How it works

You can store your application's local state any way you want (such as in `localStorage` or the Apollo Client cache). You then define the logic that Apollo Client uses to fetch and populate that local data when you query a particular field. You can even include both local _and_ remotely fetched fields in the same query:

> GraphQL ServerCacheApollo ClientGraphQL ServerCacheApollo ClientCalculates local fieldsResolves remote fieldsCaches remote fieldsTime passes…Calculates local fieldsFetches remote fields (now cached)Queries local and remote fieldsQueries remote fieldsReturns remote fieldsReturns ALL fieldsExecutes same queryReturns ALL fields

To support this flow, Apollo Client introduces two complementary mechanisms for managing local state: [field policies](/content/docs/react/local-state/local-state-management#field-policies-and-local-only-fields/index.html) and [reactive variables](/content/docs/react/local-state/local-state-management#reactive-variables/index.html).

## Field policies and local-only fields

**Field policies** enable you to define what happens when you query a particular field, _including fields that aren't defined in your GraphQL server's schema_. By defining field policies for these **local-only fields**, you can populate them with data that's stored anywhere, such as in `localStorage` or [reactive variables](/content/docs/react/local-state/local-state-management#reactive-variables/index.html).

A single GraphQL query can include both local-only fields and remotely fetched fields. In the field policy for each local-only field, you specify a function that defines how that field's value is populated.

[Get started with local-only fields](/content/docs/react/local-state/managing-state-with-field-policies/index.html)

## Reactive variables

**Reactive variables** enable you to read and write local data anywhere in your application, without needing to use a GraphQL operation to do so. The [field policy](/content/docs/react/local-state/local-state-management#field-policies-and-local-only-fields/index.html) of a local-only field can use a reactive variable to populate the field's current value.

Reactive variables _aren't_ stored in the Apollo Client cache, so they don't need to conform to the strict structure of a cached type. You can store anything you want in them.

Whenever the value of a reactive variable changes, Apollo Client automatically detects that change. Every active query with a field that depends on the changed variable automatically updates.

[Get started with reactive variables](/content/docs/react/local-state/reactive-variables/index.html)

## Local resolvers

You define **local resolvers** to populate and modify local-only fields. These resolvers are similar in structure and purpose to the [resolvers that your GraphQL server defines](/content/docs/apollo-server/data/resolvers/index.html).

[Learn more about local resolvers](/content/docs/react/local-state/local-resolvers/index.html)
