Features

Webhooks

Shopify webhooks make supported Admin changes appear on the storefront without waiting for cached data to expire. The template accepts Shopify notifications at POST /api/webhooks/shopify and refreshes the affected product, collection, recommendation, sitemap, or metaobject content.

Webhooks are disabled by default. Without SHOPIFY_WEBHOOK_SECRET, the endpoint returns 404. Edits appear when cached content refreshes or the site is redeployed; cache eviction can make them appear sooner.

Set up Shopify webhooks

  1. Open Shopify Admin → Settings → Notifications → Webhooks.
  2. Set the destination to https://your-domain.com/api/webhooks/shopify.
  3. Choose JSON as the format.
  4. Register the product, collection, and metaobject topics you need.
  5. Copy the webhook signing secret into SHOPIFY_WEBHOOK_SECRET for that environment.
SHOPIFY_WEBHOOK_SECRET="your-webhook-secret-here"

Register these supported topics:

  • products/create, products/update, and products/delete
  • collections/create, collections/update, and collections/delete
  • metaobjects/create, metaobjects/update, and metaobjects/delete

You can register only the topics your store uses. Changes without a registered topic have no event-driven refresh.

See Environment Variables for the full variable reference.

Behavior and security

Every configured request must carry a valid Shopify signature. Missing, malformed, or incorrect signatures return 401. The handler rejects the request before using its topic or payload.

Product notifications refresh the affected product wherever it appears, including recommendations and sitemap content. Product creation and deletion also refresh catalog membership.

Collection notifications refresh the affected collection and collection listings by handle and by ID, so a deleted collection, or the old URL of a renamed one, renders the not-found page. Collection creation and deletion also refresh collection membership and sitemap content.

Metaobject notifications refresh metaobject-backed content only when your custom reads participate in the template's metaobject invalidation behavior. The base template does not read metaobjects by default.

Refresh content without a webhook

Shopify sends no webhook when pages, blogs, articles, store policies, navigation menus, or Search & Discovery filters change. To show those edits right away, send a refresh request with a tag for each kind of content you changed.

  1. Generate a secret with openssl rand -base64 32 and set it as REVALIDATE_SECRET for that environment.
  2. After publishing an edit, send the request with the secret as a Bearer token:
curl -X POST "https://your-domain.com/api/revalidate?tag=pages&tag=policies" \
  -H "Authorization: Bearer $REVALIDATE_SECRET"
After editingTags
Pagespages
Blogs or articlesblogs and articles
Store policiespolicies
Navigation menus, with Shopify menus enabledmenus
Search & Discovery filtersproducts-index

The response lists the refreshed tags, and the next visit loads fresh content from Shopify. Without REVALIDATE_SECRET, the endpoint returns 404; a wrong token returns 401. Send up to 20 tags per request.

Limits

The included handler does not refresh inventory-level changes. Stock shown for the default variant can lag until the product cache refreshes; selecting a variant reads its current availability from Shopify. A product with every variant sold out is the exception: it can keep showing sold out after a restock until its product cache refreshes.

This handler does not refresh Online Store pages, blogs, articles, or store policies; send a refresh request after editing them. See Content pages for publishing guidance.

Navigation menu edits are also outside this handler.

Malformed product or collection update payloads cannot identify a specific resource, so they do not refresh the full catalog. Valid Shopify deliveries include the expected identifiers.

After registering a topic, use Send test notification in Shopify Admin and confirm the delivery succeeds before relying on it for storefront freshness.

What’s next

Add a topic only when Shopify offers a webhook for the resource and the storefront has a safe way to refresh the affected data. Prefer targeted refreshes for frequently changing catalog data. Use broader refreshes only when an event cannot be scoped or after an intentional bulk change.

To keep content without a webhook current without a manual step, have a scheduler send the refresh request. Each run reloads that content from Shopify on the next visit, so choose a schedule that matches how often merchants edit it.