Strapi v5 CMS Integration, Webhooks, and Terminal-Free Auto-Sync
The Strapi v5 CMS system is responsible for storing data for page layouts, global site settings, banners, sliders, and blog articles.
1. Why are Next.js 16 routes Force-Cached?
In Next.js 16 App Router, all fetch requests are aggressively cached by default (Force-Cache) to ensure millisecond page loads. To invalidate and clear the cache when content is updated in Strapi or Medusa, an On-Demand Cache Revalidation architecture is used.
2. Step-by-Step Guide to Configuring Webhooks in the Strapi CMS Panel
So that saving or publishing a page in Strapi immediately clears the frontend cache without restarting the server:
- Log into the Strapi panel and navigate to Settings > Webhooks.
- Click the Create new Webhook button.
- Name: Choose a custom name, such as
Next.js Revalidation Webhook. - URL: Enter the address
http://storefront:3000/api/revalidate(within the internal Docker network) orhttps://yourdomain.com/api/revalidate. - Events: Check the
Entryevents (create, update, delete, publish, and unpublish).
Security Header and Secret Code Configuration
- Name (Header Name): Be sure to type the exact phrase
x-strapi-secret. - Value (Header Value): Insert the secret key value of the
REVALIDATE_SECRETvariable found in the.envfile. - *(Alternative method: Send the secret at the end of the URL like
?secret=YOUR_REVALIDATE_SECRET)*.
- Request Authenticity Verification: Receiving the secret from the dedicated
x-strapi-secretheader or query parameter. - Selective Cache Management: Clearing the cache tags corresponding to the Strapi model (e.g.,
strapi-homepage).
Required Webhooks Checklist
For the site to function and cache correctly, you must define the following webhooks in Strapi. For all of them, the x-strapi-secret header must be set:
- ✔1. home page: URL
/api/revalidate/home-page— Used to clear the homepage cache when the main page settings change. Events:Delete,Publish,Unpublish. - ✔2. menu: URL
/api/revalidate/menu— Clears the navigation menu cache. Important Note: This webhook does not need any Events checked. Whenever you make changes in the Strapi Navigation plugin, you must manually click the Trigger button on this webhook to apply changes (header and footer). - ✔3. blog: URL
/api/revalidate/blog— Used to update the blog articles cache and blog list when an article is published or edited. Events:Delete,Publish. - ✔4. pages: URL
/api/revalidate— A general webhook for other collections (like dynamic pages) to clear caches based on tags. Events:Create,Update,Delete. - ✔5. settings (Global Settings & Dictionary): URL
/api/revalidate/strapi-settings— Instantly clears cache for global storefront settings (theme colors, header, footer, styles) and dictionary translations (modelsstorefront-settinganddictionary-entry). Events:Delete,Publish,Unpublish.
import crypto from "node:crypto"import { revalidateTag } from "next/cache"import { NextRequest, NextResponse } from "next/server" function isValidSecret(providedSecret: string | null): boolean { if (!providedSecret || !process.env.REVALIDATE_SECRET) return false const actual = new Uint8Array(crypto.createHash("sha256").update(providedSecret).digest()) const expected = new Uint8Array(crypto.createHash("sha256").update(process.env.REVALIDATE_SECRET).digest()) return crypto.timingSafeEqual(actual, expected)} export async function POST(request: NextRequest) { const secret = request.headers.get("x-strapi-secret") || request.nextUrl.searchParams.get("secret") if (!isValidSecret(secret)) { return NextResponse.json({ message: "Invalid secret" }, { status: 401 }) } const body = await request.json() if (body.model) { revalidateTag(`strapi-${body.model}`) } return NextResponse.json({ revalidated: true, now: Date.now() })}3. Automatic Product Cache Revalidation from Medusa
When a product is edited in the Medusa panel, the corresponding Subscriber or Workflow processes the product.updated event and sends an HTTP request to `/api/revalidate` to expire the products and product-[id] cache tags.
4. Storefront Management & Remote Style Sync in Strapi
Strapi includes a custom Storefront Management administration page built with the Strapi Design System. From this page, content managers and developers can select any block component, specify a style (or sync all styles), view pending queued updates, and trigger automated builds via GitHub Actions dispatch without needing SSH or server access.
# Trigger component style sync via Strapi Admin API:POST /api/storefront/sync-component{ "componentName": "home/components/ProductShowcase", "style": "style-2", "action": "add", "autoDeploy": false} # Trigger batch production build to GitHub Actions:POST /api/storefront/buildChanges are queued in .sync-history.json, allowing multiple changes to be batched together before triggering the production build action.
Product Options Translation and Color Key Rule
Color Key Naming Rule and Multilingualism
color or Color for the UI color swatch system and visual filters to work properly. Translating its title for all target languages (like English, Persian, Arabic, German, Turkish, etc.) is handled correspondingly via the Strapi CMS.