Skip to main content
@rewritetoday/edge is the Rewrite adapter for edge-native runtimes that expose the standard Request and Response APIs. Repository: github.com/RewriteToday/adapters

When to use it

  • You run on workers or edge functions with the standard Web API request model.
  • You want a runtime-first webhook handler without a framework dependency.
  • You need signature verification and typed event callbacks at the route boundary.
  • You want one small integration point that works well in constrained execution environments.

Key capabilities

Runtime-first

Works directly with the standard Request and Response APIs exposed by edge runtimes.

Verified payloads

Invalid webhook signatures are rejected before your event handler runs.

Typed callbacks

Handle webhook payloads generically with onPayload or route specific event families with named hooks.

Minimal glue

Mount the handler directly in your fetch entrypoint without extra parsing middleware.

Install

Basic example

Best practices

Avoid hardcoding the webhook secret. Inject it through your worker bindings, edge config, or runtime environment.
Webhook endpoints should acknowledge delivery fast. Push expensive work into queues, durable objects, or background jobs.
Persist the event id and make downstream processing idempotent so retries do not create duplicate side effects.
The adapter supports onSMSOTP, onMessageSent, onMessageBatch, onMessageQueued, onMessageDelivered, onMessageScheduled, onMessageFailed, onMessageCanceled, and the generic onPayload hook.

Adapters overview

Compare every official adapter and decide when adapters fit better than base packages.

Webhook overview

Signature validation, delivery format, retries, and webhook registration basics.

Webhook event types

Event families and payload references for each supported Rewrite webhook.