GitHub 37
Skip to content
ViteHub is still experimental. Expect bugs and breaking changes.

Webhooks

Call sendWebhook() from any callback. ViteHub stores the delivery, signs it, waits for the debounce, and retries.

server/webhooks/t3.ts
import { defineWebhook } from 'vite-hub/webhooks'

// One file is one webhook. The values are names of server variables.
export default defineWebhook({
  url: 'T3_WEBHOOK_URL',
  secret: 'T3_WEBHOOK_SECRET',
  debounce: '30 minutes',
})
server/webhooks/t3.ts
PartWhat it does
Definitionserver/webhooks/<name>.ts names the target URL and secret by their server variables. The file name is the webhook name, and sendWebhook() types it.
SignatureEach delivery has an HMAC-SHA256 signature in GitHub (x-hub-signature-256) or Stripe (stripe-signature) format.
StorageEach delivery is stored in the Default Database so it survives restarts and deploys.
DebounceWith debounce, sends within the window collapse into one delivery with the latest body.
RetriesQueue retries a failed delivery under the same delivery ID, up to 4 attempts in total.
Inspectionvite-hub/webhooks/runtime lists, flushes, cancels, and redelivers deliveries.

Use Webhooks when the job goes to a URL outside your app. Use Queue when your own code does the job. Webhooks uses Queue to send each delivery. To receive a webhook from Stripe or GitHub, use verifyWebhook().

  • Get started sends a signed webhook from a ViteHub app.
  • Comments to a T3 Code thread starts a T3 Code thread 30 minutes after the last comment.
  • Send events forwards Forms, Blob, Content, and Auth events.
  • Failure alerts posts to Slack when an Agent Invocation, Workflow run, or Schedule run fails.
  • Server API covers defineWebhook(), sendWebhook(), headers, and delivery helpers.