Documentation Technical
Sequential technical quickstart guide featuring breadcrumb navigation, an AI setup prompt card, prerequisites and troubleshooting callouts, synced package-manager and runtime code switchers, checkable step completion progress, onward reading cards, and a responsive sticky table-of-contents rail.
Deploying Signed Edge Webhooks with Kestrel CLI
Provision a workspace HMAC-SHA256 signing secret, verify raw webhook payloads in edge middleware, replay signed test events locally, and promote your endpoint to production in five steps.
Help me deploy signed edge webhooks with Kestrel CLI. Based on my repository: 1. Install @kestrel/cli and @kestrel/webhooks. 2. Add a webhook endpoint at /api/webhooks/kestrel that reads raw request bytes and verifies the x-kestrel-signature header with HMAC-SHA256 and a 300-second replay tolerance. 3. Wire KESTREL_WEBHOOK_SECRET from environment variables and add a local test script using `kestrel webhooks listen`.
Prerequisites
- Node.js 20+ or Bun 1.2+ with Web Crypto (
crypto.subtle) enabled - A Kestrel workspace with Edge Runtime access and a scoped API token
- Local port
8787free for the authenticated webhook tunnel listener
Install CLI & Authenticate
Install @kestrel/cli globally and add @kestrel/webhooks to your service. Switching package managers below updates all CLI commands in this guide automatically.
# Install the Kestrel CLI and verification helper
bun add -g @kestrel/cli
bun add @kestrel/webhooks
# Authenticate with scoped webhook permissions
kestrel login --scope webhooks:write
kestrel whoamiInitialize Signing Secret
Register your webhook route and generate a 256-bit signing secret. Kestrel signs every outgoing delivery with HMAC-SHA256 over ${timestamp}.${rawBody} and attaches the digest in x-kestrel-signature.
# Provision a workspace signing secret and write it to .env.local
bunx kestrel webhooks init \
--endpoint /api/webhooks/kestrel \
--events invoice.paid,subscription.updated \
--env .env.localKESTREL_WEBHOOK_ENDPOINT="/api/webhooks/kestrel"
KESTREL_WEBHOOK_SECRET="whsec_dev_7f9a3e2c41b8d60e9c1b54a72e81f0c4"
KESTREL_TOLERANCE_SECONDS="300"Verify Signatures in Middleware
Validate the raw request payload in constant time before deserializing JSON. Choose the runtime implementation that matches your deployment target:
import { verifyWebhookSignature, WebhookError } from "@kestrel/webhooks";
export async function POST(request: Request, env: Env): Promise<Response> {
// Always read the exact raw bytes before parsing JSON
const rawBody = await request.text();
const signature = request.headers.get("x-kestrel-signature");
try {
const event = await verifyWebhookSignature({
payload: rawBody,
signatureHeader: signature,
secret: env.KESTREL_WEBHOOK_SECRET,
toleranceSeconds: 300,
});
if (event.type === "invoice.paid") {
await markInvoiceSettled(event.data.invoiceId, event.id);
}
return Response.json({ received: true, eventId: event.id });
} catch (err) {
if (err instanceof WebhookError) {
return new Response(err.message, { status: 401 });
}
throw err;
}
}Replay Events Locally
Stream signed payloads straight to your local handler using kestrel webhooks listen, then emit a synthetic invoice.paid event from a second terminal to confirm end-to-end HMAC verification.
# Terminal 1 — open an authenticated local tunnel to your dev server
kestrel webhooks listen --forward http://localhost:8787/api/webhooks/kestrel
# Terminal 2 — emit a signed test event with a deterministic idempotency key
kestrel webhooks trigger invoice.paid \
--idempotency-key evt_test_01 \
--data '{"invoiceId":"inv_01j9x7","amountCents":4900}'Promote to Production
Store a dedicated production signing secret in the edge vault, publish your handler across every PoP, and run a live delivery probe before switching customer traffic.
# Store the production signing key in the encrypted edge vault
kestrel secret set KESTREL_WEBHOOK_SECRET --stage prod
# Deploy the verified handler and switch the live endpoint pointer
kestrel deploy --stage prod --verify-webhooks
# Confirm live edge delivery health and p99 verification latency
kestrel webhooks status --stage prodTroubleshooting
- Ensure no upstream JSON body parser runs before
request.text()orexpress.raw()— re-serializing JSON alters key spacing and invalidates the HMAC digest. - Check host NTP synchronization if errors report
ERR_TIMESTAMP_OUTSIDE_TOLERANCE(default window is 300 seconds). - Verify that your production vault uses a
whsec_live_*secret rather than a localwhsec_dev_*key.
# Inspect raw-body handling, clock skew, and active secret versions
kestrel webhooks doctor --stage prod --trace-last 5Next steps
Continue hardening your webhook pipeline with dual-key rotation, replay queues, and real-time delivery observability.
Install
1npx stylexblocks add documentation-technicalSource
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074import * as stylex from "@stylexjs/stylex";import { useCallback, useMemo, useState } from "react";import { Alert } from "#components/ui/ui-sdk/alert.tsx";import { Badge } from "#components/ui/ui-sdk/badge.tsx";import { Breadcrumb } from "#components/ui/ui-sdk/breadcrumb.tsx";import { Button } from "#components/ui/ui-sdk/button.tsx";import { Card } from "#components/ui/ui-sdk/card.tsx";import { Circle } from "#components/ui/ui-sdk/center.tsx";import { Checkbox } from "#components/ui/ui-sdk/checkbox.tsx";import { Code } from "#components/ui/ui-sdk/code.tsx";import { CodeBlock } from "#components/ui/ui-sdk/code-block.tsx";import { Grid } from "#components/ui/ui-sdk/grid.tsx";import { Heading } from "#components/ui/ui-sdk/heading.tsx";import { Icon } from "#components/ui/ui-sdk/icon.tsx";import { IconBadge } from "#components/ui/ui-sdk/icon-badge.tsx";import { IconButton } from "#components/ui/ui-sdk/icon-button.tsx";import { Link } from "#components/ui/ui-sdk/link.tsx";import { List } from "#components/ui/ui-sdk/list.tsx";import { Menu } from "#components/ui/ui-sdk/menu.tsx";import { Progress } from "#components/ui/ui-sdk/progress.tsx";import { Separator } from "#components/ui/ui-sdk/separator.tsx";import { HStack, Stack, VStack } from "#components/ui/ui-sdk/stack.tsx";import { Tabs } from "#components/ui/ui-sdk/tabs.tsx";import { Text } from "#components/ui/ui-sdk/text.tsx";import { Toast, Toaster } from "#components/ui/ui-sdk/toast.tsx";import { Toc, type TocItemData } from "#components/ui/ui-sdk/toc.tsx";import { semanticColors } from "@stylexblocks/ui/semantic-tokens/colors.stylex.ts";import { semanticRadii } from "@stylexblocks/ui/semantic-tokens/radii.stylex.ts";import { semanticShadows } from "@stylexblocks/ui/semantic-tokens/shadows.stylex.ts";import { accentPalette, amberPalette, bluePalette, emeraldPalette,} from "@stylexblocks/ui/themes/palettes.ts";import { durations } from "@stylexblocks/ui/tokens/durations.stylex.ts";import { fontSizes } from "@stylexblocks/ui/tokens/font-sizes.stylex.ts";import { fontWeights } from "@stylexblocks/ui/tokens/font-weights.stylex.ts";import { fonts } from "@stylexblocks/ui/tokens/fonts.stylex.ts";import { lineHeights } from "@stylexblocks/ui/tokens/line-heights.stylex.ts";import { radii } from "@stylexblocks/ui/tokens/radii.stylex.ts";import { sizes } from "@stylexblocks/ui/tokens/sizes.stylex.ts";import { spacing } from "@stylexblocks/ui/tokens/spacing.stylex.ts";import type { StyleOverrideProps } from "#lib/recipe-props.ts";
// ---------------------------------------------------------------------------// Container breakpoints// ---------------------------------------------------------------------------
const NARROW = "@container documentation-technical (max-width: 900px)";const COMPACT = "@container documentation-technical (max-width: 600px)";
// ---------------------------------------------------------------------------// Types// ---------------------------------------------------------------------------
export type PackageManager = "bun" | "pnpm" | "npm";
export type RuntimeTarget = "edge" | "express" | "cli";
export interface GuideNextStep { id: string; title: string; description: string; readTime: string; href: string; icon: "key" | "repeat" | "shield" | "activity";}
export interface DocumentationTechnicalProps extends StyleOverrideProps { /** Guide headline rendered as the page `<h1>`. */ title?: string; /** Introductory summary shown beneath the title. */ subtitle?: string; /** Product / CLI version badge shown in the header metadata. */ version?: string; /** Last updated date label shown in the header metadata. */ updatedAt?: string; /** Initial package manager tab selection. */ defaultPackageManager?: PackageManager; /** Step IDs pre-marked as completed on mount. */ defaultCompletedSteps?: readonly string[]; /** Onward reading cards shown in the "Next steps" section. */ nextSteps?: readonly GuideNextStep[]; /** Called when a user selects one of the onward next-step cards. */ onNavigateNextStep?: (step: GuideNextStep) => void;}
// ---------------------------------------------------------------------------// Demo data — Deploying Signed Edge Webhooks with Kestrel CLI// ---------------------------------------------------------------------------
const STEP_IDS = [ "step-1-install", "step-2-secret", "step-3-verify", "step-4-replay", "step-5-promote",] as const;
type StepId = (typeof STEP_IDS)[number];
interface OutlineEntry { id: string; label: string; depth: number;}
const OUTLINE_ENTRIES: readonly OutlineEntry[] = [ { id: "prerequisites", label: "Prerequisites", depth: 2 }, { id: "step-1-install", label: "1. Install CLI & Authenticate", depth: 2 }, { id: "step-2-secret", label: "2. Initialize Signing Secret", depth: 2 }, { id: "step-3-verify", label: "3. Verify Signatures", depth: 2 }, { id: "step-4-replay", label: "4. Replay Events Locally", depth: 2 }, { id: "step-5-promote", label: "5. Promote to Production", depth: 2 }, { id: "troubleshooting", label: "Troubleshooting", depth: 2 }, { id: "next-steps", label: "Next steps", depth: 2 },];
const TOC_ITEMS: TocItemData[] = OUTLINE_ENTRIES.map((entry) => ({ value: entry.id, depth: entry.depth,}));
const AI_SETUP_PROMPT = "Help me deploy signed edge webhooks with Kestrel CLI. Based on my repository: 1. Install @kestrel/cli and @kestrel/webhooks. 2. Add a webhook endpoint at /api/webhooks/kestrel that reads raw request bytes and verifies the x-kestrel-signature header with HMAC-SHA256 and a 300-second replay tolerance. 3. Wire KESTREL_WEBHOOK_SECRET from environment variables and add a local test script using `kestrel webhooks listen`.";
const AI_DESTINATIONS = [ { id: "claude", label: "Open in Claude" }, { id: "chatgpt", label: "Open in ChatGPT" }, { id: "cursor", label: "Open in Cursor" }, { id: "v0", label: "Open in v0" },] as const;
const INSTALL_SNIPPETS: Record<PackageManager, { filename: string; code: string }> = { bun: { filename: "terminal · bun", code: `# Install the Kestrel CLI and verification helperbun add -g @kestrel/clibun add @kestrel/webhooks
# Authenticate with scoped webhook permissionskestrel login --scope webhooks:writekestrel whoami`, }, pnpm: { filename: "terminal · pnpm", code: `# Install the Kestrel CLI and verification helperpnpm add -g @kestrel/clipnpm add @kestrel/webhooks
# Authenticate with scoped webhook permissionskestrel login --scope webhooks:writekestrel whoami`, }, npm: { filename: "terminal · npm", code: `# Install the Kestrel CLI and verification helpernpm install -g @kestrel/clinpm install @kestrel/webhooks
# Authenticate with scoped webhook permissionskestrel login --scope webhooks:writekestrel whoami`, },};
const SECRET_INIT_SNIPPETS: Record<PackageManager, string> = { bun: `# Provision a workspace signing secret and write it to .env.localbunx kestrel webhooks init \\ --endpoint /api/webhooks/kestrel \\ --events invoice.paid,subscription.updated \\ --env .env.local`, pnpm: `# Provision a workspace signing secret and write it to .env.localpnpm dlx kestrel webhooks init \\ --endpoint /api/webhooks/kestrel \\ --events invoice.paid,subscription.updated \\ --env .env.local`, npm: `# Provision a workspace signing secret and write it to .env.localnpx kestrel webhooks init \\ --endpoint /api/webhooks/kestrel \\ --events invoice.paid,subscription.updated \\ --env .env.local`,};
const ENV_OUTPUT_SNIPPET = `KESTREL_WEBHOOK_ENDPOINT="/api/webhooks/kestrel"KESTREL_WEBHOOK_SECRET="whsec_dev_7f9a3e2c41b8d60e9c1b54a72e81f0c4"KESTREL_TOLERANCE_SECONDS="300"`;
const VERIFY_SNIPPETS: Record< RuntimeTarget, { label: string; filename: string; code: string }> = { edge: { label: "TypeScript (Edge)", filename: "src/routes/webhooks/kestrel.ts", code: `import { verifyWebhookSignature, WebhookError } from "@kestrel/webhooks";
export async function POST(request: Request, env: Env): Promise<Response> { // Always read the exact raw bytes before parsing JSON const rawBody = await request.text(); const signature = request.headers.get("x-kestrel-signature");
try { const event = await verifyWebhookSignature({ payload: rawBody, signatureHeader: signature, secret: env.KESTREL_WEBHOOK_SECRET, toleranceSeconds: 300, });
if (event.type === "invoice.paid") { await markInvoiceSettled(event.data.invoiceId, event.id); }
return Response.json({ received: true, eventId: event.id }); } catch (err) { if (err instanceof WebhookError) { return new Response(err.message, { status: 401 }); } throw err; }}`, }, express: { label: "Node.js (Express)", filename: "src/server/webhooks.ts", code: `import express from "express";import { verifyWebhookSignature, WebhookError } from "@kestrel/webhooks";
const router = express.Router();
// Mount express.raw() on this route so the raw Buffer stays intactrouter.post( "/api/webhooks/kestrel", express.raw({ type: "application/json" }), async (req, res) => { try { const event = await verifyWebhookSignature({ payload: req.body as Buffer, signatureHeader: req.header("x-kestrel-signature") ?? null, secret: process.env.KESTREL_WEBHOOK_SECRET!, toleranceSeconds: 300, });
res.status(200).json({ received: true, eventId: event.id }); } catch (err) { const status = err instanceof WebhookError ? 401 : 500; res.status(status).json({ error: (err as Error).message }); } },);
export default router;`, }, cli: { label: "CLI Verify", filename: "terminal · ci check", code: `# Verify a recorded webhook fixture and header inside CIkestrel webhooks verify \\ --payload ./fixtures/invoice.paid.json \\ --header "t=1764635400,v1=9e82f4a7c1d6b05e..." \\ --secret "$KESTREL_WEBHOOK_SECRET" \\ --tolerance 300`, },};
const REPLAY_SNIPPET = `# Terminal 1 — open an authenticated local tunnel to your dev serverkestrel webhooks listen --forward http://localhost:8787/api/webhooks/kestrel
# Terminal 2 — emit a signed test event with a deterministic idempotency keykestrel webhooks trigger invoice.paid \\ --idempotency-key evt_test_01 \\ --data '{"invoiceId":"inv_01j9x7","amountCents":4900}'`;
const PROMOTE_SNIPPET = `# Store the production signing key in the encrypted edge vaultkestrel secret set KESTREL_WEBHOOK_SECRET --stage prod
# Deploy the verified handler and switch the live endpoint pointerkestrel deploy --stage prod --verify-webhooks
# Confirm live edge delivery health and p99 verification latencykestrel webhooks status --stage prod`;
const DOCTOR_SNIPPET = `# Inspect raw-body handling, clock skew, and active secret versionskestrel webhooks doctor --stage prod --trace-last 5`;
const DEFAULT_NEXT_STEPS: readonly GuideNextStep[] = [ { id: "secret-rotation", title: "Zero-Downtime Secret Rotation", description: "Roll signing secrets with overlapping dual-key grace windows so in-flight deliveries never fail verification.", readTime: "5 min", href: "#next-secret-rotation", icon: "key", }, { id: "idempotency-queues", title: "Idempotency & Replay Queues", description: "Deduplicate retried deliveries with event IDs and inspect or replay failed payloads from dead-letter storage.", readTime: "7 min", href: "#next-idempotency-queues", icon: "repeat", }, { id: "edge-rate-limits", title: "Edge Rate Limits & IP Allowlists", description: "Combine HMAC-SHA256 verification with per-route token buckets and Kestrel egress CIDR pinning.", readTime: "6 min", href: "#next-edge-rate-limits", icon: "shield", }, { id: "delivery-telemetry", title: "Webhook Delivery Telemetry", description: "Export OpenTelemetry spans, signature failure alerts, and regional p99 handler latency histograms.", readTime: "4 min", href: "#next-delivery-telemetry", icon: "activity", },];
// ---------------------------------------------------------------------------// Inline SVG Icons (zero external icon packages)// ---------------------------------------------------------------------------
function CopyIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.65" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <rect x="7" y="7" width="9" height="9" rx="1.75" /> <path d="M4 13V5.5A1.5 1.5 0 0 1 5.5 4H13" /> </Icon> );}
function CheckIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.9" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="m5 10.5 3.2 3.2L15.5 6.5" /> </Icon> );}
function SparklesIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.65" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="m10 2.75 1.55 4.45 4.45 1.55-4.45 1.55L10 14.75l-1.55-4.45L4 8.75 8.45 7.2 10 2.75Z" /> <path d="M15.25 13.25v3M13.75 14.75h3" /> </Icon> );}
function ChevronDownIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="m5.5 7.75 4.5 4.5 4.5-4.5" /> </Icon> );}
function ChevronRightIcon() { return ( <Icon size="xs" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="m6 3.75 4.25 4.25L6 12.25" /> </Icon> );}
function InfoCircleIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <circle cx="10" cy="10" r="7.5" /> <path d="M10 9.25v4.25" /> <path d="M10 6.5h.01" /> </Icon> );}
function WarningTriangleIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M8.85 3.65a1.3 1.3 0 0 1 2.3 0l6.1 11.2A1.3 1.3 0 0 1 16.1 16.75H3.9a1.3 1.3 0 0 1-1.15-1.9l6.1-11.2Z" /> <path d="M10 8v3.5" /> <path d="M10 14h.01" /> </Icon> );}
function ArrowRightIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M4.5 10h11" /> <path d="M11 5.5 15.5 10 11 14.5" /> </Icon> );}
function TerminalIcon() { return ( <Icon size="xs" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <rect x="2.75" y="4" width="14.5" height="12" rx="2" /> <path d="m6.25 8.25 2.5 2-2.5 2" /> <path d="M10.5 12.25h3.25" /> </Icon> );}
function NextStepIcon({ kind }: { kind: GuideNextStep["icon"] }) { if (kind === "key") { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.65" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <circle cx="7" cy="10" r="3.25" /> <path d="M10.25 10H17" /> <path d="M14.25 10v2.5" /> <path d="M16.75 10v2" /> </Icon> ); } if (kind === "repeat") { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.65" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M14.25 3.75 16.75 6.25l-2.5 2.5" /> <path d="M3.5 9.75V8a1.75 1.75 0 0 1 1.75-1.75h11.5" /> <path d="M5.75 16.25 3.25 13.75l2.5-2.5" /> <path d="M16.5 10.25V12a1.75 1.75 0 0 1-1.75 1.75H3.25" /> </Icon> ); } if (kind === "shield") { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.65" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M10 2.75 16 5.25v4.5c0 3.75-2.55 6.45-6 7.5-3.45-1.05-6-3.75-6-7.5v-4.5l6-2.5Z" /> <path d="m7.75 10.25 1.6 1.6 3.15-3.35" /> </Icon> ); } return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.65" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M3 11h3.25l2-5.25 3.25 8.5 2.25-3.25H17" /> </Icon> );}
// ---------------------------------------------------------------------------// Styles// ---------------------------------------------------------------------------
const styles = stylex.create({ root: { backgroundColor: semanticColors.bg, color: semanticColors.fg, containerName: "documentation-technical", containerType: "inline-size", fontFamily: fonts.body, minHeight: "100%", width: "100%", }, pageFrame: { marginInline: "auto", maxWidth: "74rem", paddingBlockEnd: spacing._16, paddingBlockStart: { default: spacing._8, [COMPACT]: spacing._5, }, paddingInline: { default: spacing._8, [COMPACT]: spacing._4, }, }, layoutGrid: { gap: { default: spacing._10, [NARROW]: spacing._6, }, gridTemplateColumns: { default: "minmax(0, 1fr) 15.5rem", [NARROW]: "minmax(0, 1fr)", }, }, mainColumn: { gap: spacing._7, }, headerSection: { gap: spacing._3_5, }, updatedText: { marginInlineStart: spacing._1, }, pageTitle: { marginBlock: 0, textWrap: "balance", }, pageSubtitle: { maxWidth: "66ch", }, leadingMd: { lineHeight: lineHeights.md, }, leadingSm: { lineHeight: lineHeights.sm, }, fullWidth: { width: "100%", }, inlineTocCard: { backgroundColor: semanticColors.bgPanel, borderColor: semanticColors.border, borderRadius: semanticRadii.panel, borderStyle: "solid", borderWidth: "1px", display: { default: "none", [NARROW]: "flex", }, paddingBlock: spacing._3_5, paddingInline: spacing._4, }, inlineTocList: { listStyleType: "none", marginBlock: 0, marginInline: 0, paddingBlock: 0, paddingInline: 0, }, inlineTocButton: { appearance: "none", backgroundColor: { default: semanticColors.bgMuted, ":hover": semanticColors.bgSubtle, }, borderColor: semanticColors.borderSubtle, borderRadius: semanticRadii.control, borderStyle: "solid", borderWidth: "1px", color: { default: semanticColors.fgMuted, ":hover": semanticColors.fg, }, cursor: "pointer", fontFamily: fonts.body, fontSize: fontSizes.xs, fontWeight: fontWeights.medium, lineHeight: lineHeights.xs, outlineColor: { default: null, ":focus-visible": semanticColors.accentFocusRing, }, outlineOffset: { default: null, ":focus-visible": "2px", }, outlineStyle: { default: "none", ":focus-visible": "solid", }, outlineWidth: { default: null, ":focus-visible": "2px", }, paddingBlock: spacing._1, paddingInline: spacing._2_5, transitionDuration: durations.fast, transitionProperty: "background-color, color, border-color", }, progressCard: { borderStyle: "solid", }, progressCardBody: { display: "flex", flexDirection: "column", gap: spacing._2_5, paddingBlock: spacing._3_5, paddingInline: spacing._4, }, aiCard: { borderStyle: "solid", }, aiCardBody: { display: "flex", flexDirection: "column", gap: spacing._3, paddingBlock: spacing._4, paddingInline: spacing._4, }, anchoredHeading: { marginBlock: 0, scrollMarginTop: spacing._6, }, alertDescriptionBlock: { display: "block", }, prereqList: { gap: spacing._1_5, marginTop: spacing._1_5, }, stepArticle: { gap: spacing._3_5, scrollMarginTop: spacing._6, }, stepHeaderRow: { alignItems: { default: "center", [COMPACT]: "flex-start", }, flexDirection: { default: "row", [COMPACT]: "column", }, }, stepNumberBadge: { backgroundColor: semanticColors.bgMuted, borderColor: semanticColors.borderEmphasized, borderStyle: "solid", borderWidth: "1px", color: semanticColors.fg, fontSize: fontSizes.xs, fontVariantNumeric: "tabular-nums", fontWeight: fontWeights.semibold, height: sizes._7, transitionDuration: durations.fast, transitionProperty: "background-color, border-color, color", width: sizes._7, }, stepNumberBadgeDone: { backgroundColor: semanticColors.successSolid, borderColor: semanticColors.successSolid, color: semanticColors.successContrast, }, stepTitle: { marginBlock: 0, }, stepCheckWrap: { flexShrink: 0, }, stepBody: { gap: spacing._3_5, paddingInlineStart: { default: spacing._10, [COMPACT]: 0, }, }, tabsPanelFlush: { paddingBlockEnd: 0, paddingBlockStart: spacing._3, paddingInline: 0, }, codeBlockRoot: { borderColor: semanticColors.border, borderStyle: "solid", }, codeBlockHeader: { borderBottomColor: semanticColors.borderSubtle, borderBottomStyle: "solid", borderBottomWidth: "1px", marginBottom: 0, }, codeBlockContent: { backgroundColor: semanticColors.bgMuted, borderBottomLeftRadius: radii.md, borderBottomRightRadius: radii.md, color: semanticColors.fg, }, outputNote: { backgroundColor: semanticColors.bgPanel, borderColor: semanticColors.borderSubtle, borderRadius: semanticRadii.control, borderStyle: "solid", borderWidth: "1px", color: semanticColors.fgMuted, fontFamily: fonts.mono, fontSize: fontSizes.xs, lineHeight: lineHeights.xs, paddingBlock: spacing._2, paddingInline: spacing._3, }, outputStatusDot: { backgroundColor: semanticColors.successSolid, height: sizes._2, width: sizes._2, }, troubleshootingList: { gap: spacing._1_5, marginTop: spacing._2, }, nextStepsGrid: { gap: spacing._3_5, gridTemplateColumns: { default: "repeat(2, minmax(0, 1fr))", [COMPACT]: "minmax(0, 1fr)", }, }, nextStepCard: { borderColor: { default: semanticColors.border, ":hover": semanticColors.borderEmphasized, }, borderStyle: "solid", boxShadow: { default: "none", ":hover": semanticShadows.xs, }, transitionDuration: durations.fast, transitionProperty: "border-color, box-shadow", }, nextStepButton: { appearance: "none", backgroundColor: "transparent", borderRadius: semanticRadii.panel, borderStyle: "none", borderWidth: 0, color: "inherit", cursor: "pointer", display: "flex", flexDirection: "column", gap: spacing._2_5, height: "100%", outlineColor: { default: null, ":focus-visible": semanticColors.accentFocusRing, }, outlineOffset: { default: null, ":focus-visible": "2px", }, outlineStyle: { default: "none", ":focus-visible": "solid", }, outlineWidth: { default: null, ":focus-visible": "2px", }, paddingBlock: spacing._4, paddingInline: spacing._4, textAlign: "start", width: "100%", }, nextStepFooter: { alignItems: "center", color: semanticColors.accentFg, display: "inline-flex", fontSize: fontSizes.xs, fontWeight: fontWeights.medium, gap: spacing._1_5, marginTop: "auto", paddingTop: spacing._1, }, docFooter: { paddingTop: spacing._1, }, railColumn: { alignSelf: "start", display: { default: "flex", [NARROW]: "none", }, position: "sticky", top: spacing._6, }, railCard: { backgroundColor: semanticColors.bgPanel, borderColor: semanticColors.border, borderRadius: semanticRadii.panel, borderStyle: "solid", borderWidth: "1px", paddingBlock: spacing._3_5, paddingInline: spacing._3_5, },});
// ---------------------------------------------------------------------------// Internal Copyable Code Block helper// ---------------------------------------------------------------------------
interface GuideCodeBlockProps { id: string; filename: string; code: string; copiedId: string | null; onCopy: (text: string, label: string, key: string) => void;}
function GuideCodeBlock({ id, filename, code, copiedId, onCopy,}: GuideCodeBlockProps) { const isCopied = copiedId === id; return ( <CodeBlock.Root size="sm" style={styles.codeBlockRoot}> <CodeBlock.Header style={styles.codeBlockHeader}> <CodeBlock.Title> <TerminalIcon /> <span>{filename}</span> </CodeBlock.Title> <CodeBlock.Control> <Button variant="ghost" size="2xs" aria-label={`Copy ${filename}`} onClick={() => onCopy(code, filename, id)} > {isCopied ? <CheckIcon /> : <CopyIcon />} {isCopied ? "Copied" : "Copy"} </Button> </CodeBlock.Control> </CodeBlock.Header> <CodeBlock.Content style={styles.codeBlockContent}> <CodeBlock.Code> <CodeBlock.CodeText>{code}</CodeBlock.CodeText> </CodeBlock.Code> </CodeBlock.Content> </CodeBlock.Root> );}
// ---------------------------------------------------------------------------// Main Component// ---------------------------------------------------------------------------
/** * DocumentationTechnical — sequential technical quickstart and walkthrough * guide featuring breadcrumb navigation, prerequisites and troubleshooting * callouts, synced package-manager and runtime code switchers, checkable step * completion progress, AI prompt card, onward next-step cards, and a sticky * table-of-contents rail that collapses cleanly on narrow widths. */export function DocumentationTechnical({ title = "Deploying Signed Edge Webhooks with Kestrel CLI", subtitle = "Provision a workspace HMAC-SHA256 signing secret, verify raw webhook payloads in edge middleware, replay signed test events locally, and promote your endpoint to production in five steps.", version = "Kestrel CLI v2.8", updatedAt = "Updated Nov 28, 2026", defaultPackageManager = "bun", defaultCompletedSteps = ["step-1-install"], nextSteps = DEFAULT_NEXT_STEPS, onNavigateNextStep, palette, style,}: DocumentationTechnicalProps) { const queue = useMemo(() => Toast.createToaster(), []);
const [packageManager, setPackageManager] = useState<PackageManager>( defaultPackageManager, ); const [runtimeTarget, setRuntimeTarget] = useState<RuntimeTarget>("edge"); const [completedSteps, setCompletedSteps] = useState<ReadonlySet<string>>( () => new Set(defaultCompletedSteps), ); const [copiedId, setCopiedId] = useState<string | null>(null); const [helpfulVote, setHelpfulVote] = useState<"yes" | "no" | null>(null);
const completedCount = useMemo( () => STEP_IDS.filter((id) => completedSteps.has(id)).length, [completedSteps], ); const allStepsComplete = completedCount === STEP_IDS.length;
const copyText = useCallback( (text: string, label: string, key: string) => { if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) { void navigator.clipboard.writeText(text).catch(() => {}); } setCopiedId(key); window.setTimeout(() => { setCopiedId((current) => (current === key ? null : current)); }, 1600); queue.success(`Copied ${label}`, { description: text.length > 64 ? `${text.split("\n")[0]?.slice(0, 60)}…` : text, }); }, [queue], );
const toggleStep = useCallback( (stepId: StepId, nextDone: boolean, stepLabel: string) => { setCompletedSteps((prev) => { const next = new Set(prev); if (nextDone) { next.add(stepId); } else { next.delete(stepId); } const nextCount = STEP_IDS.filter((id) => next.has(id)).length; if (nextDone && nextCount === STEP_IDS.length) { queue.success("All 5 quickstart steps completed", { description: "Your signed Kestrel webhook endpoint is production-ready.", }); } else if (nextDone) { queue.info(`Marked "${stepLabel}" complete`, { description: `${nextCount} of ${STEP_IDS.length} steps finished.`, }); } return next; }); }, [queue], );
const handleMarkAllDone = useCallback(() => { setCompletedSteps(new Set(STEP_IDS)); queue.success("All 5 quickstart steps completed", { description: "Every step in this guide has been checked off.", }); }, [queue]);
const handleResetProgress = useCallback(() => { setCompletedSteps(new Set()); queue.info("Walkthrough progress reset"); }, [queue]);
const handleJumpToSection = useCallback((sectionId: string) => { const el = document.getElementById(sectionId); if (el) { el.scrollIntoView({ behavior: "smooth", block: "start" }); } }, []);
const handleCopyAllCommands = useCallback(() => { const combined = [ INSTALL_SNIPPETS[packageManager].code, "", SECRET_INIT_SNIPPETS[packageManager], "", REPLAY_SNIPPET, "", PROMOTE_SNIPPET, ].join("\n"); copyText(combined, `all ${packageManager} CLI commands`, "copy-all-cli"); }, [copyText, packageManager]);
const handleNextStepClick = useCallback( (item: GuideNextStep) => { onNavigateNextStep?.(item); queue.info(`Opening "${item.title}"`, { description: `Demo navigation → /docs/webhooks/${item.id} (${item.readTime} read)`, }); }, [onNavigateNextStep, queue], );
const handleBreadcrumbClick = useCallback( (event: React.MouseEvent<HTMLAnchorElement>, label: string, path: string) => { event.preventDefault(); queue.info(`Navigated to ${label}`, { description: `Demo breadcrumb link → ${path}`, }); }, [queue], );
const handleVote = useCallback( (vote: "yes" | "no") => { setHelpfulVote(vote); queue.success( vote === "yes" ? "Thanks for the feedback" : "Feedback noted — we will improve this guide", { description: vote === "yes" ? "Glad the Kestrel webhook quickstart helped." : "Let us know which step needed more detail via GitHub issues.", }, ); }, [queue], );
const isStepDone = (id: StepId) => completedSteps.has(id);
return ( <div {...stylex.props(palette, styles.root, style)}> <div {...stylex.props(styles.pageFrame)}> <Grid align="start" style={styles.layoutGrid}> {/* Main technical walkthrough column */} <VStack render={<main />} style={styles.mainColumn}> {/* Header & Breadcrumb */} <VStack render={<header />} style={styles.headerSection}> <Breadcrumb.Root aria-label="Documentation breadcrumb" size="sm"> <Breadcrumb.List> <Breadcrumb.Item> <Breadcrumb.Link href="#docs" onClick={(event) => handleBreadcrumbClick(event, "Docs", "/docs") } > Docs </Breadcrumb.Link> </Breadcrumb.Item> <Breadcrumb.Separator aria-hidden="true"> <ChevronRightIcon /> </Breadcrumb.Separator> <Breadcrumb.Item> <Breadcrumb.Link href="#guides" onClick={(event) => handleBreadcrumbClick(event, "Guides", "/docs/guides") } > Guides </Breadcrumb.Link> </Breadcrumb.Item> <Breadcrumb.Separator aria-hidden="true"> <ChevronRightIcon /> </Breadcrumb.Separator> <Breadcrumb.Item> <Breadcrumb.Link href="#webhooks" onClick={(event) => handleBreadcrumbClick( event, "Edge Webhooks", "/docs/guides/edge-webhooks", ) } > Edge Webhooks </Breadcrumb.Link> </Breadcrumb.Item> <Breadcrumb.Separator aria-hidden="true"> <ChevronRightIcon /> </Breadcrumb.Separator> <Breadcrumb.Item> <Breadcrumb.CurrentLink aria-current="page"> Signed Edge Webhooks </Breadcrumb.CurrentLink> </Breadcrumb.Item> </Breadcrumb.List> </Breadcrumb.Root>
<HStack gap="2" wrap="wrap"> <Badge variant="surface" size="sm" palette={accentPalette}> Quickstart </Badge> <Badge variant="outline" size="sm"> {version} </Badge> <Badge variant="subtle" size="sm"> 12 min · 5 steps </Badge> <Text render={<span />} variant="muted" size="xs" style={styles.updatedText}> {updatedAt} </Text> </HStack>
<Heading render={<h1 />} size="4xl" style={styles.pageTitle}> {title} </Heading> <Text variant="muted" size="md" style={styles.pageSubtitle}> {subtitle} </Text>
{/* Inline outline for narrow containers where the sticky rail collapses */} <VStack render={<nav aria-label="On this page" />} gap="2.5" style={styles.inlineTocCard} > <Text variant="overline">On this page</Text> <HStack render={<ul />} gap="1.5" wrap="wrap" style={styles.inlineTocList}> {OUTLINE_ENTRIES.map((entry) => ( <li key={entry.id}> <button type="button" {...stylex.props(styles.inlineTocButton)} onClick={() => handleJumpToSection(entry.id)} > {entry.label} </button> </li> ))} </HStack> </VStack> </VStack>
{/* Interactive step completion progress strip */} <Card.Root variant="outline" size="sm" style={styles.progressCard}> <Card.Body style={styles.progressCardBody}> <HStack gap="2" justify="between" wrap="wrap"> <HStack gap="2" wrap="wrap"> <Text render={<span />} size="sm" weight="semibold"> Walkthrough progress </Text> {allStepsComplete ? ( <Badge variant="subtle" size="xs" palette={emeraldPalette} > Ready for production </Badge> ) : null} <Text render={<span />} variant="muted" size="xs" tabular="true"> {completedCount} of {STEP_IDS.length} steps completed </Text> </HStack>
<HStack gap="1.5"> {completedCount > 0 ? ( <Button variant="ghost" size="2xs" onClick={handleResetProgress} > Reset </Button> ) : null} {!allStepsComplete ? ( <Button variant="surface" size="2xs" onClick={handleMarkAllDone} > Mark all done </Button> ) : null} </HStack> </HStack>
<Progress.Root value={completedCount} max={STEP_IDS.length} size="xs" shape="full" palette={allStepsComplete ? emeraldPalette : accentPalette} aria-label="Walkthrough step completion progress" > <Progress.Track> <Progress.Range /> </Progress.Track> </Progress.Root> </Card.Body> </Card.Root>
{/* AI Setup Assistant Card */} <Card.Root variant="outline" size="md" style={styles.aiCard}> <Card.Body style={styles.aiCardBody}> <HStack gap="2" justify="between" wrap="wrap"> <HStack gap="2"> <SparklesIcon /> <Text render={<span />} size="sm" weight="semibold"> AI Assistance </Text> <Badge variant="subtle" size="xs"> Setup prompt </Badge> </HStack>
<HStack gap="1"> <Button variant="ghost" size="xs" onClick={() => copyText(AI_SETUP_PROMPT, "AI setup prompt", "ai-prompt") } > {copiedId === "ai-prompt" ? <CheckIcon /> : <CopyIcon />} {copiedId === "ai-prompt" ? "Copied" : "Copy prompt"} </Button>
<Menu.Root size="sm"> <Menu.Trigger render={ <IconButton variant="ghost" size="xs" aria-label="Open setup prompt in AI assistant" /> } > <ChevronDownIcon /> </Menu.Trigger> <Menu.Content align="end"> {AI_DESTINATIONS.map((dest) => ( <Menu.Item key={dest.id} onSelect={() => queue.info(dest.label, { description: "Demo action: opens this Kestrel webhook setup prompt in your editor or assistant.", }) } > <Menu.ItemText>{dest.label}</Menu.ItemText> </Menu.Item> ))} </Menu.Content> </Menu.Root> </HStack> </HStack>
<Text variant="muted" size="sm" style={styles.leadingMd}> {AI_SETUP_PROMPT} </Text> </Card.Body> </Card.Root>
{/* Prerequisites Callout */} <VStack render={<section aria-labelledby="prerequisites" />} gap="4"> <Heading id="prerequisites" render={<h2 />} size="xl" style={styles.anchoredHeading} > Prerequisites </Heading>
<Alert.Root status="info" variant="subtle" size="md" palette={bluePalette} > <Alert.Indicator> <InfoCircleIcon /> </Alert.Indicator> <Alert.Content> <Alert.Title>Before you begin</Alert.Title> <Alert.Description style={styles.alertDescriptionBlock}> Confirm your local environment meets these requirements so signature verification and local tunnel replay work out of the box. <List.Root variant="marker" style={styles.prereqList}> <List.Item> Node.js 20+ or Bun 1.2+ with Web Crypto ( <Code size="xs">crypto.subtle</Code>) enabled </List.Item> <List.Item> A Kestrel workspace with Edge Runtime access and a scoped API token </List.Item> <List.Item> Local port <Code size="xs">8787</Code> free for the authenticated webhook tunnel listener </List.Item> </List.Root> </Alert.Description> </Alert.Content> </Alert.Root> </VStack>
<Separator />
{/* Numbered Sequential Walkthrough Steps */} <VStack gap="8"> {/* Step 1 */} <VStack render={<section id="step-1-install" aria-labelledby="step-1-heading" />} style={styles.stepArticle} > <Stack gap="3" justify="between" style={styles.stepHeaderRow}> <HStack gap="3"> <Circle render={<span />} aria-hidden="true" style={[ styles.stepNumberBadge, isStepDone("step-1-install") && styles.stepNumberBadgeDone, ]} > {isStepDone("step-1-install") ? <CheckIcon /> : "1"} </Circle> <Heading id="step-1-heading" render={<h2 />} size="lg" style={styles.stepTitle} > Install CLI & Authenticate </Heading> </HStack>
<div {...stylex.props(styles.stepCheckWrap)}> <Checkbox.Root size="sm" variant="solid" palette={emeraldPalette} > <Checkbox.Control checked={isStepDone("step-1-install")} onCheckedChange={(checked) => toggleStep( "step-1-install", checked === true, "Install CLI & Authenticate", ) } /> <Checkbox.Label> {isStepDone("step-1-install") ? "Completed" : "Mark complete"} </Checkbox.Label> </Checkbox.Root> </div> </Stack>
<VStack style={styles.stepBody}> <Text variant="muted" size="sm" style={styles.leadingMd}> Install <Code size="xs">@kestrel/cli</Code> globally and add{" "} <Code size="xs">@kestrel/webhooks</Code> to your service. Switching package managers below updates all CLI commands in this guide automatically. </Text>
<Tabs.Root value={packageManager} onValueChange={setPackageManager} variant="enclosed" size="xs" palette={accentPalette} > <HStack gap="2.5" justify="between" wrap="wrap"> <Tabs.List aria-label="Select package manager"> <Tabs.Tab value="bun">bun</Tabs.Tab> <Tabs.Tab value="pnpm">pnpm</Tabs.Tab> <Tabs.Tab value="npm">npm</Tabs.Tab> </Tabs.List> <Text render={<span />} variant="muted" size="xs" weight="medium"> Synced across steps 1–2 </Text> </HStack>
{(["bun", "pnpm", "npm"] as const).map((pm) => ( <Tabs.Panel key={pm} value={pm} style={styles.tabsPanelFlush} > <GuideCodeBlock id={`install-${pm}`} filename={INSTALL_SNIPPETS[pm].filename} code={INSTALL_SNIPPETS[pm].code} copiedId={copiedId} onCopy={copyText} /> </Tabs.Panel> ))} </Tabs.Root>
<HStack gap="2" wrap="wrap" style={styles.outputNote}> <Circle render={<span />} aria-hidden="true" style={styles.outputStatusDot} /> <span> Authenticated as <strong>acme-edge</strong> · scopes: webhooks:write · expires in 14d </span> </HStack> </VStack> </VStack>
<Separator />
{/* Step 2 */} <VStack render={<section id="step-2-secret" aria-labelledby="step-2-heading" />} style={styles.stepArticle} > <Stack gap="3" justify="between" style={styles.stepHeaderRow}> <HStack gap="3"> <Circle render={<span />} aria-hidden="true" style={[ styles.stepNumberBadge, isStepDone("step-2-secret") && styles.stepNumberBadgeDone, ]} > {isStepDone("step-2-secret") ? <CheckIcon /> : "2"} </Circle> <Heading id="step-2-heading" render={<h2 />} size="lg" style={styles.stepTitle} > Initialize Signing Secret </Heading> </HStack>
<div {...stylex.props(styles.stepCheckWrap)}> <Checkbox.Root size="sm" variant="solid" palette={emeraldPalette} > <Checkbox.Control checked={isStepDone("step-2-secret")} onCheckedChange={(checked) => toggleStep( "step-2-secret", checked === true, "Initialize Signing Secret", ) } /> <Checkbox.Label> {isStepDone("step-2-secret") ? "Completed" : "Mark complete"} </Checkbox.Label> </Checkbox.Root> </div> </Stack>
<VStack style={styles.stepBody}> <Text variant="muted" size="sm" style={styles.leadingMd}> Register your webhook route and generate a 256-bit signing secret. Kestrel signs every outgoing delivery with{" "} <Code size="xs">HMAC-SHA256</Code> over{" "} <Code size="xs">{`\${timestamp}.\${rawBody}`}</Code> and attaches the digest in{" "} <Code size="xs">x-kestrel-signature</Code>. </Text>
<GuideCodeBlock id={`secret-init-${packageManager}`} filename={`terminal · ${packageManager}`} code={SECRET_INIT_SNIPPETS[packageManager]} copiedId={copiedId} onCopy={copyText} />
<GuideCodeBlock id="secret-env-output" filename=".env.local (generated)" code={ENV_OUTPUT_SNIPPET} copiedId={copiedId} onCopy={copyText} /> </VStack> </VStack>
<Separator />
{/* Step 3 */} <VStack render={<section id="step-3-verify" aria-labelledby="step-3-heading" />} style={styles.stepArticle} > <Stack gap="3" justify="between" style={styles.stepHeaderRow}> <HStack gap="3"> <Circle render={<span />} aria-hidden="true" style={[ styles.stepNumberBadge, isStepDone("step-3-verify") && styles.stepNumberBadgeDone, ]} > {isStepDone("step-3-verify") ? <CheckIcon /> : "3"} </Circle> <Heading id="step-3-heading" render={<h2 />} size="lg" style={styles.stepTitle} > Verify Signatures in Middleware </Heading> </HStack>
<div {...stylex.props(styles.stepCheckWrap)}> <Checkbox.Root size="sm" variant="solid" palette={emeraldPalette} > <Checkbox.Control checked={isStepDone("step-3-verify")} onCheckedChange={(checked) => toggleStep( "step-3-verify", checked === true, "Verify Signatures in Middleware", ) } /> <Checkbox.Label> {isStepDone("step-3-verify") ? "Completed" : "Mark complete"} </Checkbox.Label> </Checkbox.Root> </div> </Stack>
<VStack style={styles.stepBody}> <Text variant="muted" size="sm" style={styles.leadingMd}> Validate the raw request payload in constant time before deserializing JSON. Choose the runtime implementation that matches your deployment target: </Text>
<Tabs.Root value={runtimeTarget} onValueChange={setRuntimeTarget} variant="line" size="sm" palette={accentPalette} > <Tabs.List aria-label="Select verification runtime"> <Tabs.Tab value="edge"> {VERIFY_SNIPPETS.edge.label} </Tabs.Tab> <Tabs.Tab value="express"> {VERIFY_SNIPPETS.express.label} </Tabs.Tab> <Tabs.Tab value="cli"> {VERIFY_SNIPPETS.cli.label} </Tabs.Tab> </Tabs.List>
{(["edge", "express", "cli"] as const).map((target) => ( <Tabs.Panel key={target} value={target} style={styles.tabsPanelFlush} > <GuideCodeBlock id={`verify-${target}`} filename={VERIFY_SNIPPETS[target].filename} code={VERIFY_SNIPPETS[target].code} copiedId={copiedId} onCopy={copyText} /> </Tabs.Panel> ))} </Tabs.Root> </VStack> </VStack>
<Separator />
{/* Step 4 */} <VStack render={<section id="step-4-replay" aria-labelledby="step-4-heading" />} style={styles.stepArticle} > <Stack gap="3" justify="between" style={styles.stepHeaderRow}> <HStack gap="3"> <Circle render={<span />} aria-hidden="true" style={[ styles.stepNumberBadge, isStepDone("step-4-replay") && styles.stepNumberBadgeDone, ]} > {isStepDone("step-4-replay") ? <CheckIcon /> : "4"} </Circle> <Heading id="step-4-heading" render={<h2 />} size="lg" style={styles.stepTitle} > Replay Events Locally </Heading> </HStack>
<div {...stylex.props(styles.stepCheckWrap)}> <Checkbox.Root size="sm" variant="solid" palette={emeraldPalette} > <Checkbox.Control checked={isStepDone("step-4-replay")} onCheckedChange={(checked) => toggleStep( "step-4-replay", checked === true, "Replay Events Locally", ) } /> <Checkbox.Label> {isStepDone("step-4-replay") ? "Completed" : "Mark complete"} </Checkbox.Label> </Checkbox.Root> </div> </Stack>
<VStack style={styles.stepBody}> <Text variant="muted" size="sm" style={styles.leadingMd}> Stream signed payloads straight to your local handler using{" "} <Code size="xs">kestrel webhooks listen</Code>, then emit a synthetic <Code size="xs">invoice.paid</Code> event from a second terminal to confirm end-to-end HMAC verification. </Text>
<GuideCodeBlock id="replay-local" filename="terminal · local tunnel" code={REPLAY_SNIPPET} copiedId={copiedId} onCopy={copyText} />
<HStack gap="2" wrap="wrap" style={styles.outputNote}> <Circle render={<span />} aria-hidden="true" style={styles.outputStatusDot} /> <span> POST /api/webhooks/kestrel → 200 OK · verified in 1.4 ms · sig=v1 · evt_test_01 </span> </HStack> </VStack> </VStack>
<Separator />
{/* Step 5 */} <VStack render={<section id="step-5-promote" aria-labelledby="step-5-heading" />} style={styles.stepArticle} > <Stack gap="3" justify="between" style={styles.stepHeaderRow}> <HStack gap="3"> <Circle render={<span />} aria-hidden="true" style={[ styles.stepNumberBadge, isStepDone("step-5-promote") && styles.stepNumberBadgeDone, ]} > {isStepDone("step-5-promote") ? <CheckIcon /> : "5"} </Circle> <Heading id="step-5-heading" render={<h2 />} size="lg" style={styles.stepTitle} > Promote to Production </Heading> </HStack>
<div {...stylex.props(styles.stepCheckWrap)}> <Checkbox.Root size="sm" variant="solid" palette={emeraldPalette} > <Checkbox.Control checked={isStepDone("step-5-promote")} onCheckedChange={(checked) => toggleStep( "step-5-promote", checked === true, "Promote to Production", ) } /> <Checkbox.Label> {isStepDone("step-5-promote") ? "Completed" : "Mark complete"} </Checkbox.Label> </Checkbox.Root> </div> </Stack>
<VStack style={styles.stepBody}> <Text variant="muted" size="sm" style={styles.leadingMd}> Store a dedicated production signing secret in the edge vault, publish your handler across every PoP, and run a live delivery probe before switching customer traffic. </Text>
<GuideCodeBlock id="promote-prod" filename="terminal · production deploy" code={PROMOTE_SNIPPET} copiedId={copiedId} onCopy={copyText} /> </VStack> </VStack> </VStack>
<Separator />
{/* Troubleshooting Callout */} <VStack render={<section aria-labelledby="troubleshooting" />} gap="4"> <Heading id="troubleshooting" render={<h2 />} size="xl" style={styles.anchoredHeading} > Troubleshooting </Heading>
<Alert.Root status="warning" variant="surface" size="md" palette={amberPalette} > <Alert.Indicator> <WarningTriangleIcon /> </Alert.Indicator> <Alert.Content> <Alert.Title> Receiving 401 Invalid Signature in staging or production? </Alert.Title> <Alert.Description style={styles.alertDescriptionBlock}> Most signature mismatches come from subtle body mutations or clock skew between edge PoPs and your origin: <List.Root variant="marker" style={styles.troubleshootingList} > <List.Item> Ensure no upstream JSON body parser runs before{" "} <Code size="xs">request.text()</Code> or{" "} <Code size="xs">express.raw()</Code> — re-serializing JSON alters key spacing and invalidates the HMAC digest. </List.Item> <List.Item> Check host NTP synchronization if errors report{" "} <Code size="xs">ERR_TIMESTAMP_OUTSIDE_TOLERANCE</Code>{" "} (default window is 300 seconds). </List.Item> <List.Item> Verify that your production vault uses a{" "} <Code size="xs">whsec_live_*</Code> secret rather than a local <Code size="xs">whsec_dev_*</Code> key. </List.Item> </List.Root> </Alert.Description> </Alert.Content> </Alert.Root>
<GuideCodeBlock id="doctor-cmd" filename="terminal · diagnostics" code={DOCTOR_SNIPPET} copiedId={copiedId} onCopy={copyText} /> </VStack>
<Separator />
{/* Onward Next Steps */} <VStack render={<section aria-labelledby="next-steps" />} gap="4"> <Heading id="next-steps" render={<h2 />} size="xl" style={styles.anchoredHeading} > Next steps </Heading> <Text variant="muted" size="sm" style={styles.leadingMd}> Continue hardening your webhook pipeline with dual-key rotation, replay queues, and real-time delivery observability. </Text>
<Grid style={styles.nextStepsGrid}> {nextSteps.map((item) => ( <Card.Root key={item.id} variant="outline" size="sm" style={styles.nextStepCard} > <button type="button" {...stylex.props(styles.nextStepButton)} onClick={() => handleNextStepClick(item)} > <HStack gap="2" justify="between" style={styles.fullWidth}> <IconBadge variant="subtle" size="sm" palette={accentPalette} > <NextStepIcon kind={item.icon} /> </IconBadge> <Badge variant="outline" size="xs"> {item.readTime} </Badge> </HStack> <Text render={<h3 />} size="sm" weight="semibold"> {item.title} </Text> <Text variant="muted" size="xs" style={styles.leadingSm}> {item.description} </Text> <span {...stylex.props(styles.nextStepFooter)}> Read guide <ArrowRightIcon /> </span> </button> </Card.Root> ))} </Grid> </VStack>
<Separator />
{/* Documentation Footer */} <HStack render={<footer />} gap="3" justify="between" wrap="wrap" style={styles.docFooter} > <HStack gap="2" wrap="wrap"> <Text render={<span />} variant="muted" size="xs"> Was this guide helpful? </Text> <Button variant={helpfulVote === "yes" ? "solid" : "surface"} size="2xs" palette={helpfulVote === "yes" ? accentPalette : undefined} onClick={() => handleVote("yes")} > Yes </Button> <Button variant={helpfulVote === "no" ? "solid" : "surface"} size="2xs" palette={helpfulVote === "no" ? accentPalette : undefined} onClick={() => handleVote("no")} > No </Button> </HStack>
<Link href="#edit-on-github" variant="plain" onClick={(event) => { event.preventDefault(); queue.info("Edit page on GitHub", { description: "Demo link → github.com/kestrel-edge/docs/blob/main/webhooks-quickstart.mdx", }); }} > Edit this page on GitHub </Link> </HStack> </VStack>
{/* Right-hand Sticky Outline Rail */} <VStack render={<aside aria-label="Guide outline and progress" />} gap="5" style={styles.railColumn} > <Toc.Root items={TOC_ITEMS} variant="line" size="sm" multiple={false} defaultActiveIds={["prerequisites"]} palette={accentPalette} > <Toc.Nav> <Toc.Title>On this page</Toc.Title> <Toc.List> <Toc.Indicator /> {OUTLINE_ENTRIES.map((entry) => ( <Toc.Item key={entry.id} item={{ value: entry.id, depth: entry.depth }} > <Toc.Link>{entry.label}</Toc.Link> </Toc.Item> ))} </Toc.List> </Toc.Nav> </Toc.Root>
<Separator />
<VStack gap="3" style={styles.railCard}> <HStack gap="2" justify="between"> <Text render={<span />} variant="muted" size="xs" weight="medium"> Checklist </Text> <Text render={<span />} size="xs" weight="semibold" tabular="true"> {completedCount}/{STEP_IDS.length} </Text> </HStack>
<Progress.Root value={completedCount} max={STEP_IDS.length} size="xs" shape="full" palette={allStepsComplete ? emeraldPalette : accentPalette} aria-label="Sidebar completion summary" > <Progress.Track> <Progress.Range /> </Progress.Track> </Progress.Root>
<HStack gap="2" justify="between"> <Text render={<span />} variant="muted" size="xs" weight="medium"> Package manager </Text> <Code size="xs">{packageManager}</Code> </HStack>
<Button variant="surface" size="xs" onClick={handleCopyAllCommands} > {copiedId === "copy-all-cli" ? <CheckIcon /> : <CopyIcon />} {copiedId === "copy-all-cli" ? "Copied CLI steps" : "Copy all CLI steps"} </Button> </VStack> </VStack> </Grid> </div>
<Toaster toaster={queue} /> </div> );}
Inspired by the Documentation Technical template from Astryx (MIT License · Copyright (c) 2026 Meta Platforms, Inc.).