Skip to content

Datasources

A datasource is a collection of key-value pairs that can be used throughout your space (for example, as the choices in an options field or fetched directly through the API for general-purpose usage). It's ideal for storing data that is reused by various components but requires centralized management.

For example, if your website has multiple widgets that support various background color options, Colors could be a datasource that holds values such as red, green, and blue.

To create a datasource, open DatasourcesNew Datasource. Provide a name and a slug for the datasource. The ID is used to access the datasource via the Content Delivery API.

Once created, provide a name and value for each entry in the datasource.

A Datasource with various entries.

A datasource dimension in Storyblok allows you to store multiple values under a specific key.

In a basic implementation, each datasource key has one value. However, in some cases, a key needs to store multiple values. An example of this would be internationalization. Each key requires language-specific values. Each supported language would be a dimension of the datasource.

To create datasource dimensions, open the datasource settings, enter a name and a value, and save.

Once created, the new dimension is available in a separate tab. Now, use dimension-specific values for each key.

Dimension specific tab and values

You can export and import datasources as .csv files. This can be useful if you want to edit the entries in an external editor or if you want to move datasources across spaces.

To import or export a datasource, open the datasource settings, and import or export each dimension individually.

One of the main use of datasources is that they can be used as input data for a Single-Option or Multi-Options field. In the field settings, define Datasource as the Source and select an existing datasource under Internal datasource.

Once completed, choose from the options in your datasource while authoring content. This can be done across a space. This has the advantage of using one source of data across multiple components without having to redefine it for each component.

You can fetch the contents of a datasource directly in your frontend code using the Content Delivery API. The API response can be used for navigation menus, footer menus, etc.

Manage configuration options for a field plugin

Section titled “Manage configuration options for a field plugin”

Datasources can be used to store information relevant for field plugins or tools, such as API endpoints, account names, and more.