Index of every page on this site: llms.txt
All skills
jeremylongshore avatar

/supabase-webhooks-events

@0d57af8
Run it yourself

Implement Supabase database webhooks, pg_net async HTTP, LISTEN/NOTIFY, and Edge Function event handlers with signature verification. Use when setting up database webhooks for INSERT/UPDATE/DELETE events, sending HTTP requests from PostgreSQL triggers, handling Realtime postgres_changes as an event source, or building event-driven architectures. Trigger with phrases like "supabase webhook", "database events", "pg_net trigger", "supabase LISTEN NOTIFY", "webhook signature verify", "supabase event-driven", "supabase_functions.http_request".

Use this Skill: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesevent-handler-pattern.md

≈689 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Event Handler Pattern

Typed Event Dispatcher

A registry-based pattern for routing Supabase webhook events to typed handlers. This eliminates switch statements and makes adding new event handlers declarative.

// types.ts
type EventType = "INSERT" | "UPDATE" | "DELETE";

interface WebhookPayload<T = Record<string, unknown>> {
  type: EventType;
  table: string;
  schema: string;
  record: T;
  old_record: T | null;
}

type EventHandler<T = Record<string, unknown>> = (
  payload: WebhookPayload<T>
) => Promise<void>;

interface HandlerRegistration {
  table: string;
  event: EventType | "*";
  handler: EventHandler;
}

Dispatcher Implementation

// event-dispatcher.ts
class EventDispatcher {
  private handlers: HandlerRegistration[] = [];

  on(table: string, event: EventType | "*", handler: EventHandler): void {
    this.handlers.push({ table, event, handler });
  }

  async dispatch(payload: WebhookPayload): Promise<void> {
    const matched = this.handlers.filter(
      (h) =>
        h.table === payload.table &&
        (h.event === "*" || h.event === payload.type)
    );

    if (matched.length === 0) {
      console.warn(
        `No handler for ${payload.type} on ${payload.table}`
      );
      return;
    }

    // Run all matched handlers concurrently
    const results = await Promise.allSettled(
      matched.map((h) => h.handler(payload))
    );

    for (const result of results) {
      if (result.status === "rejected") {
        console.error("Handler failed:", result.reason);
      }
    }
  }
}

Usage

// Register handlers
const dispatcher = new EventDispatcher();

dispatcher.on("orders", "INSERT", async (payload) => {
  await sendOrderConfirmationEmail(payload.record.email);
  await updateInventoryCount(payload.record.product_id, -1);
});

dispatcher.on("orders", "UPDATE", async (payload) => {
  if (payload.old_record?.status !== payload.record.status) {
    await notifyStatusChange(payload.record);
  }
});

dispatcher.on("profiles", "*", async (payload) => {
  await syncToExternalCRM(payload.record);
});

// In your Edge Function serve() handler:
serve(async (req) => {
  const payload: WebhookPayload = await req.json();
  await dispatcher.dispatch(payload);
  return new Response(JSON.stringify({ ok: true }));
});

Benefits

  • Type safety: each handler receives typed payloads
  • Separation of concerns: one handler per side effect
  • Testable: handlers are pure async functions, easy to unit test
  • Extensible: add new handlers without modifying dispatch logic

Tons of Skills by Intent Solutions | jeremylongshore.com

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill provides production-ready templates for Supabase event-driven architectures, including webhooks, Realtime subscriptions, and Postgres LISTEN/NOTIFY. It correctly emphasizes security best practices such as HMAC signature verification and the use of secrets management for sensitive keys. A minor risk is noted regarding the inherent attack surface for indirect prompt injection via external event data.

  • Socket2mo

    2 alerts: gptAnomaly

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 0d57af8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last month
What it can do
Edits files Runs commands
version
1.55.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
compatibility
Designed for Claude Code
All 4 allowed tools
WriteBash(supabase:*)Bash(curl:*)Bash(psql:*)
Other metadata
tags
[
  "saas",
  "supabase",
  "webhooks",
  "events",
  "triggers",
  "pg_net",
  "realtime"
]

README badge

README badge for jeremylongshore/tons-of-skills-marketplace/supabase-webhooks-events