Home / Function/ revalidateCustomer() — supabase Function Reference

revalidateCustomer() — supabase Function Reference

Architecture documentation for the revalidateCustomer() function in revalidateCustomer.ts from the supabase codebase.

Entity Profile

Relationship Graph

Source Code

apps/cms/src/collections/Customers/hooks/revalidateCustomer.ts lines 7–40

export const revalidateCustomer: CollectionAfterChangeHook<Customer> = async ({
  doc,
  previousDoc,
  req: { payload, context },
}) => {
  if (!context.disableRevalidate) {
    if (doc._status === 'published') {
      const path = `/customers/${doc.slug}`

      payload.logger.info(`Revalidating event at path: ${path}`)
      try {
        const { revalidatePath, revalidateTag } = await import('next/cache')
        revalidatePath(path)
        revalidateTag('customers-sitemap')
      } catch {
        // no-op when not running inside Next runtime (e.g., during payload migrate)
      }
    }

    // If the event was previously published, we need to revalidate the old path
    if (previousDoc._status === 'published' && doc._status !== 'published') {
      const oldPath = `/customers/${previousDoc.slug}`

      payload.logger.info(`Revalidating old event at path: ${oldPath}`)

      try {
        const { revalidatePath, revalidateTag } = await import('next/cache')
        revalidatePath(oldPath)
        revalidateTag('customers-sitemap')
      } catch {}
    }
  }
  return doc
}

Subdomains

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free