> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Context Reference

## Article: Context Reference

## Article Link: https://dev.wix.com/docs/site-extensions/context-providers/context-reference.md

## Article Content:

# Context Reference

The `context` section of a context provider manifest declares the values and functions that the provider exposes through editor binding. It contains an `items` map where each key names an exposed item.

## Example

The following `context` exposes a value and a function:

```ts
context: {
  items: {
    count: {
      dataType: 'number',
      displayName: 'Count',
    },
    increment: {
      dataType: 'function',
      displayName: 'Increment',
      function: {},
    },
  },
}
```

## Context item fields

A context item supports the following fields:

| Field | Required | Description |
| --- | --- | --- |
| `dataType` | Yes | [Type](https://dev.wix.com/docs/site-extensions/context-providers/context-provider-data-types.md) of value or function that the item exposes. |
| `displayName` | No | Item name shown in the editor. |
| `arrayItems` | When `dataType` is `arrayItems` | Definition for each element in an [array](#arrays). |
| `data` | When `dataType` is `data` | Fields in a [nested object](#nested-objects). |
| `function` | When `dataType` is `function` | Parameters and return type of a [function](#functions). |
| `textEnum` | When `dataType` is `textEnum` | Allowed [string options](#text-enums). |

## Arrays

For an array, set `dataType` to `arrayItems` and define each element under `arrayItems.item`:

```ts
context: {
  items: {
    tags: {
      dataType: 'arrayItems',
      displayName: 'Tags',
      arrayItems: {
        item: {
          dataType: 'text',
          displayName: 'Tag',
        },
      },
    },
  },
}
```

<blockquote class="warning">

**Warning:** Arrays in `context` use `arrayItems.item`. Arrays in `data` use `arrayItems.dataItem`.

</blockquote>

## Nested objects

For a nested object, set `dataType` to `data` and define its fields under `data.items`:

```ts
context: {
  items: {
    author: {
      dataType: 'data',
      displayName: 'Author',
      data: {
        items: {
          name: {
            dataType: 'text',
            displayName: 'Name',
          },
          bio: {
            dataType: 'richText',
            displayName: 'Bio',
          },
        },
      },
    },
  },
}
```

## Text enums

For a fixed set of strings, set `dataType` to `textEnum` and list the choices under `textEnum.options`:

```ts
context: {
  items: {
    tier: {
      dataType: 'textEnum',
      displayName: 'Subscription Tier',
      textEnum: {
        options: [
          { value: 'basic', displayName: 'Basic' },
          { value: 'premium', displayName: 'Premium' },
        ],
      },
    },
  },
}
```

## Functions

For a function, set `dataType` to `function` and describe its signature under `function`.

| Field | Required | Description |
| --- | --- | --- |
| `parameters` | No | Up to 10 parameter definitions. Omit this field for a function with no parameters. |
| `returns` | No | Return type definition. Omit this field for a function with no response. |
| `async` | No | Whether the function returns a Promise. Defaults to `false`. |
| `displayName` | No | Function name shown in the editor. |
| `description` | No | Function description shown in the editor. |

For example, the following function takes an ID and an optional quantity:

```ts
context: {
  items: {
    addItem: {
      dataType: 'function',
      displayName: 'Add Item',
      function: {
        parameters: [
          {
            dataType: 'text',
            displayName: 'Item ID',
          },
          {
            dataType: 'number',
            displayName: 'Quantity',
            optional: true,
          },
        ],
        async: true,
      },
    },
  },
}
```

### Parameter fields

Each function parameter supports the following fields:

| Field | Required | Description |
| --- | --- | --- |
| `dataType` | Yes | [Type](https://dev.wix.com/docs/site-extensions/context-providers/context-provider-data-types.md) of value the parameter accepts. |
| `displayName` | No | Parameter name shown in the editor. |
| `description` | No | Parameter description shown in the editor. |
| `optional` | No | Whether the parameter is optional. Only trailing parameters can be optional. |
| `defaultValue` | No | Default shown in the editor when `optional` is `true`. The provider code must handle a missing value. |
| `arrayItems` | When `dataType` is `arrayItems` | Definition for each array element. |
| `data` | When `dataType` is `data` | Fields in a nested object. |
| `textEnum` | When `dataType` is `textEnum` | Allowed string options. |

## Rich text

Many Wix elements accept rich text through editor binding. To expose formatted text, set `dataType` to `richText` and provide a `RichText` object at runtime:

```ts
context: {
  items: {
    description: {
      dataType: 'richText',
      displayName: 'Team Description',
    },
  },
}
```

For the runtime shape, see [Context Provider Data Types](https://dev.wix.com/docs/site-extensions/context-providers/context-provider-data-types.md#rich-text).

## See also

- [About the Context Provider Manifest](https://dev.wix.com/docs/site-extensions/context-providers/about-the-context-provider-manifest.md)
- [Data Reference](https://dev.wix.com/docs/site-extensions/context-providers/data-reference.md)
- [Context Provider Resources Reference](https://dev.wix.com/docs/site-extensions/context-providers/context-provider-resources-reference.md)