How to start developing plugins for DatoCMS
Play video »
Sorry, no results found for "".
Navigate to Settings > Plugins in your project administrative area, press the plus button. At the bottom of the modal, you'll find a link to create a private plugin:
Enter a Name for the plugin — and a small description, if you want;
Enter the Entry point URL, which is the URL of the HTML page that will be embedded into the DatoCMS entry editor as an <iframe>
;
Select the types of field where it will be possible to use the plugin;
Select the type of plugin (field editor, field add-on or sidebar widget);
If needed, enter some parameter definitions;
Click Save to create the plugin.
When building an plugin, you might feel the need to add some configuration options, so that you can reuse the same plugin with slight differences multiple times in different fields.
There are two types of configuration parameters that can be set up:
Global parameters are project-wide settings and are applied to every field within the project that uses the plugin. You can set them up under the Settings > Plugins section;
Instance parameters are field-specific settings. Every time you assign a plugin to a field, you can set different parameters directly within the Presentation tab of the field's settings.
When creating a new plugin, you can define which configuration options it will accept using a specific JSON format:
As you can see, both global and instance parameters take an array of parameter definitions. Every parameter definition is an object constructed as described here:
id
(required): Can contain only letters and numbers, must be expressed in camelCase
or snake_case
label
(required): Human readable name of the parameter
type
(required): The type of field to offer when editing this parameter (can be boolean
, date
, date_time
, float
, integer
, string
, text
, JSON
or color
)
hint
: Further explanation of the purpose of the parameter
required
: Whether the parameter value needs to be provided (defaults to false
)
default
: Default value to use for the parameter. The value must be coherent with the type
of the parameter itself.
As soon as you edit the Parameter definitions field, a preview of the resulting fields will be shown under the field:
WARNING: Configuration parameters can be read by anybody who is allowed to use the plugin. It's not secure to use parameters to inject access tokens that permit data manipulation. Read-only tokens can be used, but keep in mind their value is not hidden.
Learn to build a DatoCMS plugin from scratch with this video tutorial: