The Settings Store is a flexible system for storing configuration data with support for scoping, permissions, and validation. It allows plugins and the core system to store and retrieve arbitrary JSON data with fine-grained control over access and isolation.
It provides a robust, secure, and flexible system for managing configuration data in your Vendure application. Use it to store user preferences, plugin settings, feature flags, and any other settings data your application needs.
The APIs in this guide were introduced in Vendure v3.4
The Settings Store provides:
Settings fields share some similarities to custom fields, but the important differences are:
Settings fields are best suited to storing config-like values that are global in scope, or which configure data for a particular plugin.
Settings fields are defined in your Vendure configuration using the settingsStoreFields option:
Each field supports the following configuration options:
| Option | Type | Description |
|---|---|---|
name | string | The field name (combined with namespace to create full key) |
scope | SettingsStoreScopeFunction | How the field should be scoped (see scoping section) |
readonly | boolean | If true, field cannot be modified via GraphQL API |
requiresPermission | Permission | Permission[] | { read: Permission, write: Permission } | Permissions required to access this field |
validate | function | Custom validation function for field values |
The Settings Store supports four built-in scoping strategies:
You can also create custom scope functions:
You can control access to the Settings Store entry via the requiresPermission configuration property.
If not specified, basic authentication is required for Admin API access.
Can be either:
read and write properties for granular control. For custom permissions you can use
a RwPermissionDefinition.@example
The Settings Store provides GraphQL queries and mutations in the Admin API:
Any kind of JSON-serializable data can be set as the value. For example: strings, numbers, arrays, or even deeply-nested objects and arrays.
By default, the Settings Store is not exposed in the Shop API.
However, you can expose this functionality via a custom mutations & queries
that internally use the SettingsStoreService (see next section).
For programmatic access within plugins or services, use the SettingsStoreService:
| Method | Description |
|---|---|
get<T>(ctx, key) | Get a single value with optional type parameter |
getMany(ctx, keys) | Get multiple values efficiently in a single query |
set<T>(ctx, key, value) | Set a value with structured result feedback |
setMany(ctx, values) | Set multiple values with individual result feedback |
getFieldDefinition(key) | Get the field configuration for a key |
Prior to v3.4.2, ctx was the last argument to the above methods. However, since
this is contrary to all other method usage which has ctx as the first argument, it was
changed while deprecating (but still supporting) the former signature.
When field definitions are removed from your configuration, the corresponding database entries become "orphaned". The Settings Store includes an automatic cleanup system to handle this.
You can also perform cleanup manually via the service:
requiresPermission for sensitive configuration data