Netlify Create supports two-way data sync between Netlify Create and DatoCMS. Here is an example that uses a page
content type to represent pages:
1
2
3
4
5
6
7
8
9
10
11
12
13
Prerequisites
To be able to work with DatoCMS, you must first have the following:
- A DatoCMS project with models and content.
- A full-access API token and ID of the project, both stored as environment variables. (See options below.)
Installed
@stackbit/cms-datocms
package as a development dependency. (We also recommend@stackbit/types
to help with configuration.)1
Usage
1
2
3
4
5
6
Options
Storing Sensitive Values
Sensitive values can be stored in a .env
file, which will then be available when the Netlify Create configuration file is loaded.
1
2
Local Development
DatoCMS uses webhooks to synchronize data. To work with Netlify Create in local development, the easiest method is to use an ngrok tunnel and pass the tunnel URL when running stackbit dev
.
Install ngrok
After signing up for an ngrok account, install the agent on your machine.
Start ngrok Agent
With your development server running in another terminal window, start the ngrok agent on port 8090
.
1
This will output a publicly-accesible URL from which you can access localhost:8090.
1
2
3
4
Start stackbit dev
When starting stackbit dev
, use the ngrok URL as part of the csi-webhook-url
option, being sure to maintain the path /_stackbit/onWebhook
.
1
Now you are good to open localhost:8090/_stackbit and start developing locally.
Restarting ngrok
When restarting the ngrok agent, you will typically receive a different URL.
This will result in an error saying that a webhook with a name stackbit-webhook-local
already exists. If this happens, delete the stackbit-webhook-local
webhook in your DatoCMS project settings.