Libraries
    Preparing search index...
    • Create a middleware that bridges endpoint cache tags to an external cache.

      The middleware reads endpoint .cacheTag() / .clearsCacheTag() metadata from client requests and calls invalidateTag() after successful mutating requests (POST, PUT, PATCH, or DELETE). Dynamic tags invalidate both the base tag name and the computed key by default.

      Parameters

      Returns Middleware

      A client middleware for createClient().

      import { revalidateTag } from 'next/cache';
      import { externalCacheTags } from '@cleverbrush/client/cache';

      const client = createClient(api, {
      middlewares: [
      externalCacheTags({ invalidateTag: revalidateTag }),
      ],
      });