Skip to content

API Reference & Compatibility

The inventory is generated from the package source exports across ., ./next, and ./testing.

Functions

createRevalidateHandler

Source
createRevalidateHandler(options: ReceiverOptions) => (request: Request) => Promise<Response>

Exported from: @nexload-sdk/payload-revalidate/next

Creates a Next.js App Router POST handler that verifies and applies cache revalidation requests.

createRevalidator

Source
createRevalidator(options: RevalidatorOptions) => Revalidator

Exported from: @nexload-sdk/payload-revalidate

Creates a Payload revalidator that normalizes, chunks, and POSTs cache invalidations.

createTestRevalidator

Source
createTestRevalidator(options?: Partial<RevalidatorOptions>) => { revalidator: Revalidator; calls: WireBatch[]; clear(): void; }

Exported from: @nexload-sdk/payload-revalidate/testing

Creates an in-memory test revalidator that records dispatched batches.

signRevalidateRequest

Source
signRevalidateRequest(input: { body: string; secret: string; timestamp?: number; }) => { timestamp: string; signature: string; }

Exported from: @nexload-sdk/payload-revalidate

Signs a revalidation request body with an HMAC-SHA256 base64url signature.

verifyRevalidateRequest

Source
verifyRevalidateRequest(input: { body: string; timestamp: string | null; signature: string | null; secret: string | readonly string[]; now?: number; }) => boolean

Exported from: @nexload-sdk/payload-revalidate

Verifies a revalidation request signature and timestamp window using timing-safe comparison.

Constants

MAX_BODY_BYTES

Source
MAX_BODY_BYTES: 8192

Exported from: @nexload-sdk/payload-revalidate

Public constant exported by @nexload-sdk/payload-revalidate.

MAX_TARGETS

Source
MAX_TARGETS: 50

Exported from: @nexload-sdk/payload-revalidate

Public constant exported by @nexload-sdk/payload-revalidate.

REVALIDATE_ENDPOINT

Source
REVALIDATE_ENDPOINT: "/api/revalidate"

Exported from: @nexload-sdk/payload-revalidate

Public constant exported by @nexload-sdk/payload-revalidate.

SIGNATURE_HEADER

Source
SIGNATURE_HEADER: "x-revalidate-signature"

Exported from: @nexload-sdk/payload-revalidate

Public constant exported by @nexload-sdk/payload-revalidate.

TIMESTAMP_HEADER

Source
TIMESTAMP_HEADER: "x-revalidate-timestamp"

Exported from: @nexload-sdk/payload-revalidate

Public constant exported by @nexload-sdk/payload-revalidate.

TIMESTAMP_WINDOW_SECONDS

Source
TIMESTAMP_WINDOW_SECONDS: 60

Exported from: @nexload-sdk/payload-revalidate

Public constant exported by @nexload-sdk/payload-revalidate.

Types

type Ctx<D> = {
  doc: D;
  previousDoc?: D;
  locale: TypedLocale | null;
  locales: TypedLocale[];
  operation: "create" | "update" | "delete";
  req: PayloadRequest;
};

Exported from: @nexload-sdk/payload-revalidate

Public type exported by @nexload-sdk/payload-revalidate.

PathTarget

Source
type PathTarget = string | { path: string; type?: "layout" | "page" };

Exported from: @nexload-sdk/payload-revalidate

Public type exported by @nexload-sdk/payload-revalidate.

ReceiverOptions

Source
type ReceiverOptions = (
  | { secret: string | readonly string[]; allowUnsigned?: never }
  | { allowUnsigned: true; secret?: never }
) & { logger?: Logger };

Exported from: @nexload-sdk/payload-revalidate/next

Public type exported by @nexload-sdk/payload-revalidate.

Revalidator

Source
type Revalidator = {
  hooks<S extends CollectionSlug>(
    slug: S,
    rules: Rules<DataFromCollectionSlug<S>>,
  ): {
    afterChange: CollectionAfterChangeHook[];
    afterDelete: CollectionAfterDeleteHook[];
  };
  globalHooks<S extends GlobalSlug>(
    slug: S,
    rules: Rules<DataFromGlobalSlug<S>>,
  ): {
    afterChange: GlobalAfterChangeHook[];
  };
  send(targets: Targets): Promise<void>;
  flush(): Promise<void>;
};

Exported from: @nexload-sdk/payload-revalidate

Public type exported by @nexload-sdk/payload-revalidate.

RevalidatorOptions

Source
type RevalidatorOptions = {
  url: string | undefined;
  secret?: string;
  enabled?: boolean;
  logger?: Logger;
  endpoint?: string;
  timeoutMs?: number;
  retries?: number;
};

Exported from: @nexload-sdk/payload-revalidate

Public type exported by @nexload-sdk/payload-revalidate.

Rules

Source
type Rules<D> = {
  tags?: string[] | ((ctx: Ctx<D>) => string[]);
  paths?: PathTarget[] | ((ctx: Ctx<D>) => PathTarget[]);
  isPublic?: (doc: D) => boolean;
};

Exported from: @nexload-sdk/payload-revalidate

Public type exported by @nexload-sdk/payload-revalidate.

Targets

Source
type Targets = { tags?: string[]; paths?: PathTarget[] };

Exported from: @nexload-sdk/payload-revalidate

Public type exported by @nexload-sdk/payload-revalidate.

WireBatch

Source
type WireBatch = { tags: string[]; paths: WirePath[] };

Exported from: @nexload-sdk/payload-revalidate

Public type exported by @nexload-sdk/payload-revalidate.

WirePath

Source
type WirePath = { path: string; type?: "layout" | "page" };

Exported from: @nexload-sdk/payload-revalidate

Public type exported by @nexload-sdk/payload-revalidate.

  • Module format: Dual ESM (import) and CJS (require).
  • @nexload-sdk/payload-revalidate: Runs in Node.js on the Payload CMS server and never imports next or next/*.
  • @nexload-sdk/payload-revalidate/next: Uses next/cache (revalidateTag(tag, "max"), revalidatePath) and requires the Next.js Node.js runtime. Do not configure runtime = "edge".
  • @nexload-sdk/payload-revalidate/testing: Exports createTestRevalidator(options?) returning { revalidator, calls, clear } for zero-network in-memory tests.

Requests are sent as POST {url}{endpoint} with content-type: application/json, x-revalidate-timestamp (TIMESTAMP_HEADER), x-revalidate-signature (SIGNATURE_HEADER, base64url HMAC-SHA256 over `${timestamp}.${rawBody}` in signed mode), and x-trace-id. Limits: MAX_TARGETS = 50 per request, MAX_BODY_BYTES = 8192 UTF-8 bytes, and TIMESTAMP_WINDOW_SECONDS = 60.

All logs use @nexload-sdk/logger with child bindings { module: "payload-revalidate" }: revalidate.client.disabled (debug), revalidate.batch.flushed (info), revalidate.batch.dropped (warn), revalidate.target.dropped (warn), revalidate.hook.failed (error), revalidate.request.sent (info), revalidate.request.retried (warn), revalidate.request.failed (error), revalidate.request.handled (info), and revalidate.request.rejected (warn).