# AdapTable State Guide

Canonical page: https://www.adaptabletools.com/docs/dev-guide-adaptable-state

- AdapTable State is the UI configuration for an instance: Layouts, searches, styles, and the other Module objects
- Developers ship [Initial Adaptable State](https://www.adaptabletools.com/docs/dev-guide-adaptable-state-initial-state/index.md) at design-time (a `Layout` section is required)
- Coding agents can also be used to manage State - in 2 ways:
    - [adaptable-dev](https://www.adaptabletools.com/docs/getting-started-ai-skills-dev/index.md) for day-to-day State work
    - [adaptable-upgrade](https://www.adaptabletools.com/docs/getting-started-ai-skills-upgrade/index.md) - when upgrading between AdapTable versions
- First load merges that into User State; later loads restore the persisted User State
- Persistence is automatic (localStorage by default); most production apps use remote `loadState` / `persistState`
- Some sections are transient and are never persisted
- Support and developers [inspect live State](https://www.adaptabletools.com/docs/dev-guide-adaptable-state-management/index.md) in [AdapTable DevTools](https://www.adaptabletools.com/docs/dev-guide-support-devtools/index.md) ([Manage State](https://www.adaptabletools.com/docs/dev-guide-support-devtools-manage-state/index.md) or the [In-page API](https://www.adaptabletools.com/docs/dev-guide-support-devtools-api/index.md))

- AdapTable State does **not** include AG Grid data; it deals only with the AdapTable UI and associated objects
- Likewise AdapTable does **not** have access to the clients' private data

AdapTable State is how an instance remembers its configuration between sessions.

Developers populate [Initial Adaptable State](https://www.adaptabletools.com/docs/dev-guide-adaptable-state-initial-state/index.md) at design-time. Users then add, edit and delete objects at run-time. 

Entitlements, options and other design-time settings that users cannot change live in [Adaptable Options](https://www.adaptabletools.com/docs/technical-reference-adaptable-options/index.md), not in State

Those changes are persisted and re-applied on the next start.

- For Agent Skills install and commands see [Agent Skills](https://www.adaptabletools.com/docs/getting-started-ai-skills/index.md)
- For tickets on a live Grid see [Supporting AdapTable](https://www.adaptabletools.com/docs/dev-guide-support-overview/index.md)

## Using Agent Skills

<StateRoutes />

## How AdapTable State Works

At design-time developers create [Initial Adaptable State](https://www.adaptabletools.com/docs/dev-guide-adaptable-state-initial-state/index.md).

This is a JSON object that contains the items the AdapTable instance requires for first use.

It consists of multiple sections — each relating to one Module in AdapTable.

Other sections are optional - with the exception of `Layout` which is required and must contain at least one Layout (unless [Default Layouts](https://www.adaptabletools.com/docs/handbook-layouts-default/index.md) are configured).

Some of the contents of each section are collections of Adaptable Objects (e.g. [Layouts](https://www.adaptabletools.com/docs/handbook-layouts/index.md)) but can also be string properties (e.g. name of the Current Layout).

When the application loads for the **first time**, the [Initial Adaptable State](https://www.adaptabletools.com/docs/dev-guide-adaptable-state-initial-state/index.md) is read into memory.

This Initial State is then stored as AdapTable State and is updated (and automatically persisted) with any user state that is created during that session.

It can be stored locally or remotely depending on your settings.

Each later launch retrieves that persisted User State and pre-populates the AdapTable instance with it.

Users see the same configuration they had on their previous visit.

The [Revision](https://www.adaptabletools.com/docs/dev-guide-adaptable-state-updating-initial-state/index.md) property lets you update a section of Initial State **after** go-live without wiping the rest of User State

## What is Persisted

Most of AdapTable State is persisted. That persisted object is the Initial State sections plus [Team Sharing](https://www.adaptabletools.com/docs/handbook-team-sharing/index.md) (Team Sharing is run-time only — it is not part of Initial State).

These sections are **transient**: they exist in the in-memory store but are never written by `persistState`:

- `Internal`
- `Popup`
- `Comment`
- `Plugins`

## Default AdapTable State

AdapTable State is almost entirely empty when the Application starts for the first time.

It is then populated by the supplied [Initial Adaptable State](https://www.adaptabletools.com/docs/dev-guide-adaptable-state-initial-state/index.md).

A few defaults are provided for convenience:

All of these can be replaced by properties in Initial Adaptable State if necessary

| Module                                                           | Default Property Description                                         |
| ---------------------------------------------------------------- | -------------------------------------------------------------------- |
| [Dashboard](https://www.adaptabletools.com/docs/ui-dashboard/index.md)             | `ModuleButtons` is an empty list                                     |
| [Quick Search](https://www.adaptabletools.com/docs/handbook-quick-search/index.md) | Default highlight style (black text on yellow)                       |
| [Theme](https://www.adaptabletools.com/docs/handbook-theming/index.md)             | Current Theme is set to `light`                                      |
| [Tool Panel](https://www.adaptabletools.com/docs/ui-tool-panel/index.md)           | A *SettingsPanel* Button is provided in the `ModuleButtons` property |

## Redux

Internally AdapTable uses [Redux](https://redux.js.org/) to manage its state.

This provides a uni-directional store for all the objects used in the grid.

If using Redux in your application, continue to maintain your own Store; merging the 2 Stores can cause complications

## Pages in this Section

The pages follow the State lifecycle:

1. **Provide** Initial State
2. **Persist** User State
3. **Update** Initial State after go-live
4. **Customise**, **suspend** and **listen**
5. **Manage** in the UI, **migrate** between versions, then the **API**

| Page | Summary |
| ---- | ------- |
| [Providing Initial Adaptable State](https://www.adaptabletools.com/docs/dev-guide-adaptable-state-initial-state/index.md) | Design-time objects for first use — `Layout` is required |
| [AdapTable State Persistence Guide](https://www.adaptabletools.com/docs/dev-guide-adaptable-state-persistence/index.md) | localStorage by default, or your own `loadState` / `persistState` |
| [Updating Initial AdapTable State](https://www.adaptabletools.com/docs/dev-guide-adaptable-state-updating-initial-state/index.md) | Ship section `Revision`s after go-live without wiping User State |
| [Custom AdapTable State](https://www.adaptabletools.com/docs/dev-guide-adaptable-state-custom/index.md) | Store your own key / value pairs in the Application section |
| [Suspending Adaptable Objects](https://www.adaptabletools.com/docs/dev-guide-adaptable-state-suspending/index.md) | Turn objects off with `IsSuspended` without deleting them |
| [Listening to AdapTable State](https://www.adaptabletools.com/docs/dev-guide-adaptable-state-events/index.md) | `AdaptableStateChanged`, `BeforeAdaptableStateChange` and reload |
| [Managing AdapTable State at Run-Time](https://www.adaptabletools.com/docs/dev-guide-adaptable-state-management/index.md) | Import, export and clear State in the Settings Panel (hidden by default) |
| [Migrating Adaptable State](https://www.adaptabletools.com/docs/dev-guide-adaptable-state-migrating-state/index.md) | Automatic migration on load, or `migrateAdaptableState` by hand |
| [State Migration Tool](https://www.adaptabletools.com/docs/dev-guide-adaptable-state-migration-tool/index.md) | Paste State for one major version and migrate it to another |
| [Adaptable State Technical Reference](https://www.adaptabletools.com/docs/technical-reference-adaptable-state/index.md) | State Options, State API and Event Info |

<!-- framework: react -->
### React

In React, read and react to State with [AdapTable React Hooks](https://www.adaptabletools.com/docs/react-adaptable-hooks/index.md) (`useAdaptableState`, `useCurrentLayout`, `useAdaptableApi`).

<!-- /framework -->

### FAQ

**Where is AdapTable State stored?**
By default it is stored in the browser's local storage, under `adaptableStateKey` (which defaults to `adaptableId` if you omit it). Use the State Options functions to save State in any location you specify (and to enrich it en route).

**Do you provide data adapters to fetch / save AdapTable State?**
No we don't, you will need to provide the mechanism to store your State in a remote location.
There are simply too many different storage locations and mechanisms for us to provide connectors.

**Does AdapTable persist everything in the Redux store?**
No. `Internal`, `Popup`, `Comment` and `Plugins` are transient and never written by `persistState`.

**Can a coding agent author or migrate State?**
Use [adaptable-dev](https://www.adaptabletools.com/docs/getting-started-ai-skills-dev/index.md) for day-to-day `initialState` work and [adaptable-upgrade](https://www.adaptabletools.com/docs/getting-started-ai-skills-upgrade/index.md) for major upgrades; both rely on [`check state`](https://www.adaptabletools.com/docs/getting-started-ai-cli/index.md). For a live Grid on a ticket, use [adaptable-debug](https://www.adaptabletools.com/docs/getting-started-ai-skills-debug/index.md).
