Content Sync Setup Guide
How to configure content synchronization between your content repository and your deployed site.
Quick Start
ISR (Incremental Static Regeneration) works out of the box with zero configuration beyond the standard data source variables. When your site is deployed with the default settings, it will:
- Clone the content repository at build time
- Serve pages from an in-memory cache at runtime
- Accept webhook notifications to refresh content without a full rebuild
For most deployments, you only need DATA_REPOSITORY (and GH_TOKEN for private repos). Content sync features activate automatically when the corresponding environment variables are set.
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
DATA_REPOSITORY | Yes | — | GitHub URL of your content repository |
GH_TOKEN | No | — | GitHub Personal Access Token (required for private content repos) |
GITHUB_BRANCH | No | main | Branch to sync content from |
ENABLE_ISR | No | true | Set to false for static mode with deploy hooks |
WEBHOOK_SECRET | No | — | Shared secret for webhook HMAC-SHA256 validation |
SYNC_POLL_INTERVAL_MS | No | 0 (disabled) | Polling interval in milliseconds |
SYNC_TIMEOUT_MS | No | 60000 | Maximum time for a single sync operation |
SYNC_MAX_RETRIES | No | 3 | Retry attempts on sync failure |
CONTENT_CACHE_TTL_MS | No | 300000 | Content cache TTL in milliseconds |
VERCEL_DEPLOY_HOOK_URL | No | — | Vercel deploy hook URL (required when ENABLE_ISR=false) |
Setting Up GitHub Webhooks
Webhooks give you near-instant content updates. When you push changes to your content repository, GitHub notifies your site, which then pulls the latest content.
Step-by-Step Setup
- Go to your content repository on GitHub (not the template code repository)
- Navigate to Settings > Webhooks > Add webhook
- Configure the webhook:
- Payload URL:
https://your-site.com/api/webhook - Content type:
application/json - Secret: Enter a strong random string (e.g., generate one with
openssl rand -hex 32) - Which events?: Select Just the push event
- Active: Checked
- Payload URL:
- Click Add webhook
- Add the same secret as the
WEBHOOK_SECRETenvironment variable in your Vercel project:
# Via Vercel CLI
vercel env add WEBHOOK_SECRET
# Or set it in the Vercel dashboard under Settings > Environment Variables
- Redeploy your site so the new environment variable takes effect
Verifying the Webhook
After setup, push a change to your content repository and check:
- GitHub: Go to your webhook settings and click Recent Deliveries. You should see a
200response. - Vercel: Check your function logs in the Vercel dashboard. You should see a log entry for the sync operation.
If you see a 401 response, verify that the WEBHOOK_SECRET values match exactly in both GitHub and your Vercel environment variables.
Setting Up Polling (Alternative to Webhooks)
If webhooks are not an option (e.g., your content repository is behind a firewall), you can use polling instead. The sync manager will periodically check the remote repository for changes.
Set the SYNC_POLL_INTERVAL_MS environment variable to your desired interval:
# Poll every 5 minutes
vercel env add SYNC_POLL_INTERVAL_MS
# Enter: 300000
# Poll every 1 minute (more aggressive)
vercel env add SYNC_POLL_INTERVAL_MS
# Enter: 60000
Polling uses lightweight HEAD ref checks — it compares the local and remote SHA without downloading any content. A full fetch only happens when the SHAs differ.
Note: Webhooks and polling can be used together. The webhook provides instant updates, while polling acts as a safety net for any missed webhook deliveries.
Static Mode
For sites that do not need runtime regeneration, set ENABLE_ISR=false. In this mode, the site is fully static — no server functions run at runtime. Content changes trigger a full rebuild via a Vercel Deploy Hook.
Configuration
- Set the environment variable:
vercel env add ENABLE_ISR
# Enter: false
- Create a Deploy Hook in Vercel (see next section)
- Set the deploy hook URL:
vercel env add VERCEL_DEPLOY_HOOK_URL
# Enter: https://api.vercel.com/v1/integrations/deploy/prj_xxxx/yyyy
- Set up a GitHub webhook pointing to your site's
/api/webhookendpoint (same steps as above). When a push is received, the webhook handler will fire the deploy hook instead of refreshing content in-place.
How to Create a Vercel Deploy Hook
- Go to your project in the Vercel dashboard
- Navigate to Settings > Git > Deploy Hooks
- Enter a name for the hook (e.g.,
content-sync) - Select the branch to deploy (typically
main) - Click Create Hook
- Copy the generated URL — it looks like
https://api.vercel.com/v1/integrations/deploy/prj_xxxx/yyyy - Store this URL as the
VERCEL_DEPLOY_HOOK_URLenvironment variable
Important: Treat the deploy hook URL as a secret. Anyone with the URL can trigger a deployment. Do not commit it to your repository.