#Trigger builds with webhooks
Use a webhook to start a new build of your site whenever content changes in Hygraph. Without one, publishing content in Hygraph does not update your deployed site, which continues to show the version built at the last deployment.
This works with any hosting platform that gives you a build hook or deploy hook URL. If you use Vercel or Netlify, you can also use the Vercel integration or the Netlify integration instead.
Webhooks are environment specific. This means their configuration is applied per environment. Take this into consideration if you're working with a project using more than one environment.
#1. Get a build hook URL
Before you configure the webhook in Hygraph, generate a build hook URL on your hosting platform. Hygraph sends a request to this URL whenever the webhook fires.
#Vercel
-
Go to your project in Vercel and navigate to Settings > Git > Deploy Hooks.
-
Enter a name for the hook, for example
Deploy from Hygraph. The name is only a reference for you. -
Enter the Git branch you want to deploy, for example
main. -
Click Create Hook.
Vercel Deploy Hooks form -
Copy the generated URL.
Vercel deploy hook URL
#Netlify
- Go to your site in Netlify and navigate to Project configuration > Build & deploy > Continuous deployment > Build hooks.
- In the Build hook name field, enter a name, for example
Deploy from Hygraph. - In the Branch to build dropdown, select the branch you want to build, for example
main. - Click Save.
- Copy the generated URL.
#Other platforms
Check your hosting platform's documentation for how to create a build hook or deploy hook. You need a URL that starts a new build of your site when it receives a request.
Webhook URLs in Hygraph must start with https://.
Keep your build hook URL private. Build hook URLs don't require any authentication, so anyone with the URL can trigger a build of your site. If the URL is exposed, revoke or delete it on your hosting platform and create a new one.
#2. Configure the webhook in Hygraph
-
Navigate to Project Settings > Automation > Webhooks in your Hygraph project.
-
Click Add webhook.
-
Enter a Name for your webhook, and paste the build hook URL into the URL field. Set Method to POST. You can turn off Include payload, because build hooks don't use it.
Hygraph webhook configuration -
Under Triggers, choose what starts a build. Selecting none in a field acts as a wildcard.
- Content Model: The content models that trigger this webhook. If you don't select any, every content model triggers it.
- Stage: The content stage to watch. For example, select
Publishedso that a build only starts when content is published, and not when someone saves a draft. To build a staging site from theDraftstage, create a separate project on your hosting platform connected to the same repository, and repeat step 1 for it. - Action: The actions that trigger the webhook. Leave this empty to start a build whenever content is published or unpublished.
- Source: Which source of changes triggers the webhook: a Permanent Auth Token, a project member editing content in Studio, or the Public API. Leave this empty to start a build whenever content changes, whatever the source.
Hygraph webhook triggers -
Click Add webhook to save.
For a description of every webhook setting, see Automate with webhooks.
#3. Publish content and check the build
- Open a content entry that matches your triggers, make a change, and click Save & Publish.
- Check your hosting platform for a new build:
- Vercel: Navigate to Deployments in your Vercel project.
- Netlify: Navigate to Deploys in your Netlify site.
If no build starts, check the following:
- The webhook URL matches the build hook URL exactly, with no trailing spaces or missing characters.
- The content entry you published belongs to a content model you selected in the triggers.
- The entry moved to the stage you selected. For example, if you selected
Published, saving an entry does not trigger the webhook.