# Overview

Source: https://docs.interop.io/desktop/capabilities/app-preferences/overview/index.html

## Overview

The App Preferences API enables apps to store custom user-specific data and retrieve it when necessary. This allows you to enhance the UX of your apps by instrumenting them to preserve specific user settings and apply them when the app is relaunched.

The App Preferences API provides methods for updating, replacing and clearing user settings stored for the current or a specific app, as well as for all apps of the current user.

## App Preferences Stores

App preferences can be stored locally in a file or remotely by using a REST service or [**io.Manager**](https://docs.interop.io/manager/overview/index.md).

To define a location for storing app preferences, use the `"store"` property of the `"applicationPreferences"` top-level key in the `system.json` [system configuration](https://docs.interop.io/desktop/developers/configuration/system/index.md) file of **io.Connect Desktop**.

The `"store"` object has the following properties:

| Property | Type | Description |
|----------|------|-------------|
| `"newDataCheckInterval"` | `number` | Interval in seconds at which to check for new data from the REST store. Executed only if subscribers are available. Valid only in `"rest"` mode. Defaults to `1800`. |
| `"restBackoffFactor"` | `number` | Exponential backoff factor in milliseconds used for determining the waiting interval between retries when fetching data from the REST store. The waiting interval is calculated with the `<restBackoffFactor>*2^<retry>` formula and is limited to a maximum of 5 minutes between retries. Valid only in `"rest"` mode. Defaults to `1000`. *Available since **io.Connect Desktop** 9.10.* |
| `"restClientAuth"` | `"no-auth"` \| `"negotiate"` \| `"kerberos"` | Authentication configuration. Valid only in `"rest"` mode. |
| `"restRetries"` | `number` | Number of retries when fetching data from the REST store. Valid only in `"rest"` mode. Defaults to `3`. *Available since **io.Connect Desktop** 9.10.* |
| `"restURL"` | `string` | URL pointing to the app preferences store. Valid only in `"rest"` mode. Required if `"type"` is set to `"rest"`. |
| `"type"` | `"file"` \| `"rest"` \| `"server"` | The type of the app preferences store. Set to `"file"` (default) to store and read app preferences from a local file. Set to `"rest"` to store and fetch app preferences from a REST service. Set to `"server"` to store and fetch app preferences from **io.Manager**. |

### Local

By default, app preferences are stored locally in the `<installation_location>/interop.io/io.Connect Desktop/UserData/<ENV>-<REG>/prefs` folder where `<ENV>-<REG>` represents the environment and region of **io.Connect Desktop** (e.g., `DEMO-INTEROP.IO`).

To instruct **io.Connect Desktop** to store app preferences in a local file, set the `"type"` property of the `"store"` object to `"file"`:

```json
{
    "applicationPreferences" : {
        "store": {
            "type": "file"
        }
    }
}
```

### REST

App preferences can also be obtained from remote app preferences stores via a REST service.

> ℹ️ *For a reference implementation of a remote app preferences store, see the [Node.js REST Config](https://github.com/InteropIO/rest-config-example-node-js) example.*

To configure a connection to the REST service providing the app preferences store, set the `"type"` property of the `"store"` object to `"rest"` and provide the URL of the REST service:

```json
{
    "applicationPreferences": {
        "store": {
            "type": "rest",
            "restURL": "https://my-rest-service.com/app-preferences",
            "restClientAuth": "no-auth",
            "newDataCheckInterval": 2000
        }
    }
}
```

The remote store must return an [`AppPreferences`](https://docs.interop.io/desktop/reference/javascript/app%20preferences/apppreferences/index.md) object as a response.

### io.Manager

You can also use [**io.Manager**](https://docs.interop.io/manager/overview/index.md) for hosting and retrieving app preferences.

To configure **io.Connect Desktop** to fetch app preferences from **io.Manager**, set the `"type"` property of the `"store"` object to `"server"`:

```json
{
    "applicationPreferences" : {
        "store": {
            "type": "server"
        }
    }
}
```

> ℹ️ *For details on how to configure **io.Connect Desktop** to connect to **io.Manager**, see the [io.Manager](https://docs.interop.io/desktop/capabilities/manager/index.md) section.*
