Storyblok
Search Storyblok's Documentation
  1. Datasources

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 is ideal for storing data that is reused by various components but needs to be centrally managed.

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

Setup

To create a datasource, navigate to Datasources and use the New Datasource button. Provide a name and a slug for the datasource. The ID is used to programmatically access the datasource via the Content Delivery API.

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

A Datasource with various entries.

Datasource dimensions

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, there are use cases where a key needs to store multiple values. An example of this would be internationalization. For each key, language-specific values should exist. Each supported language would be a dimension of the datasource.

To create datasource dimensions, go to the datasource settings, enter a name and a value, and click Save.

Once created, the new dimension will be available as a separate tab. Now, you can use dimension specific values for each key.

Dimension specific tab and values

Import/Export

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

To import or export a datasource, navigate to the datasource Settings. Each dimension can be imported or exported individually.

Example usage

Store properties for an options field

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.

Fetch directly in your application

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

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, etc.

Related resources