Skip to content

Commit 0040be7

Browse files
committed
docs: add workflow migration guides and migration skill
Create migration guides for AWS Step Functions, Inngest, and Temporal under docs/content/docs/getting-started/. Each guide provides side-by-side code comparisons and a realistic order-processing saga example. Add skills/migrating-to-vercel-workflow/ with SKILL.md, reference docs for each source platform (aws-step-functions, inngest, temporal), shared patterns, resume routing, runtime targets, and 5 eval scenarios. Update create-webhook API reference with webhook resume choice clarifications. Update getting-started meta.json to include migration guide navigation entries.
1 parent c739b99 commit 0040be7

18 files changed

Lines changed: 2939 additions & 19 deletions

docs/content/docs/api-reference/workflow/create-webhook.mdx

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,25 @@ The returned `Webhook` object has:
5151

5252
- `url`: The HTTP endpoint URL that external systems can call
5353
- `token`: The unique token identifying this webhook
54-
- Implements `AsyncIterable<RequestWithResponse>` for handling multiple requests
54+
- Implements `AsyncIterable<T>` for handling multiple requests, where `T` is `Request` (default) or `RequestWithResponse` (manual mode)
5555

56-
The `RequestWithResponse` type extends the standard `Request` interface with a `respondWith(response: Response)` method for sending custom responses back to the caller.
56+
When using `createWebhook({ respondWith: 'manual' })`, the resolved request type is `RequestWithResponse`, which extends the standard `Request` interface with a `respondWith(response: Response): Promise<void>` method for sending custom responses back to the caller.
57+
58+
<Callout type="info">
59+
Use the simplest option that satisfies the prompt:
60+
61+
- `createWebhook()` — generated callback URL, and the default `202 Accepted` response is fine
62+
- `createWebhook({ respondWith: 'manual' })` — generated callback URL, but you must send a custom body, status, or headers
63+
- `createHook()` + `resumeHook()` — the app resumes from server-side code with a deterministic business token instead of a generated callback URL
64+
</Callout>
65+
66+
<details>
67+
<summary>Common wrong turns</summary>
68+
69+
- Do not use `respondWith: 'manual'` just because the flow has a callback URL.
70+
- Do not use `RequestWithResponse` unless you chose manual mode.
71+
- Do not invent a custom callback route when `webhook.url` is the intended callback surface.
72+
</details>
5773

5874
## Examples
5975

@@ -80,27 +96,29 @@ export async function basicWebhookWorkflow() {
8096
}
8197
```
8298

83-
### Responding to Webhook Requests
99+
### Responding to Webhook Requests (Manual Mode)
100+
101+
Use this section only when the caller requires a non-default HTTP response. If `202 Accepted` is acceptable, use `createWebhook()` without `respondWith: "manual"`.
84102

85-
Use the `respondWith()` method to send custom HTTP responses. Note that `respondWith()` must be called from within a step function:
103+
Pass `{ respondWith: "manual" }` to get a `RequestWithResponse` object with a `respondWith()` method. Note that `respondWith()` must be called from within a step function:
86104

87105
```typescript lineNumbers
88106
import { createWebhook, type RequestWithResponse } from "workflow"
89107

90-
async function sendResponse(request: RequestWithResponse) { // [!code highlight]
91-
"use step"; // [!code highlight]
92-
await request.respondWith( // [!code highlight]
93-
new Response(JSON.stringify({ success: true, message: "Received!" }), { // [!code highlight]
94-
status: 200, // [!code highlight]
95-
headers: { "Content-Type": "application/json" } // [!code highlight]
96-
}) // [!code highlight]
97-
); // [!code highlight]
98-
} // [!code highlight]
108+
async function sendResponse(request: RequestWithResponse): Promise<void> {
109+
"use step";
110+
await request.respondWith(
111+
new Response(JSON.stringify({ success: true, message: "Received!" }), {
112+
status: 200,
113+
headers: { "Content-Type": "application/json" }
114+
})
115+
);
116+
}
99117

100118
export async function respondingWebhookWorkflow() {
101119
"use workflow";
102120

103-
using webhook = createWebhook();
121+
using webhook = createWebhook({ respondWith: "manual" });
104122
console.log("Webhook URL:", webhook.url);
105123

106124
const request = await webhook;
@@ -113,7 +131,7 @@ export async function respondingWebhookWorkflow() {
113131
await processData(data);
114132
}
115133

116-
async function processData(data: any) {
134+
async function processData(data: any): Promise<void> {
117135
"use step";
118136
// Process the webhook data
119137
console.log("Processing:", data);
@@ -161,6 +179,7 @@ export async function eventCollectorWorkflow() {
161179

162180
## Related Functions
163181

164-
- [`createHook()`](/docs/api-reference/workflow/create-hook) - Lower-level hook primitive for arbitrary payloads
165-
- [`defineHook()`](/docs/api-reference/workflow/define-hook) - Type-safe hook helper
166-
- [`resumeWebhook()`](/docs/api-reference/workflow-api/resume-webhook) - Resume a webhook from an API route
182+
- [`createHook()`](/docs/api-reference/workflow/create-hook) — Use when the app resumes from server-side code with a deterministic business token.
183+
- [`resumeHook()`](/docs/api-reference/workflow-api/resume-hook) — Pairs with `createHook()` for deterministic server-side resume.
184+
- [`defineHook()`](/docs/api-reference/workflow/define-hook) — Type-safe hook helper.
185+
- [`resumeWebhook()`](/docs/api-reference/workflow-api/resume-webhook) — Low-level runtime API. Most integrations should call `webhook.url` directly instead of adding a custom callback route.

docs/content/docs/getting-started/meta.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
"nitro",
1010
"nuxt",
1111
"sveltekit",
12-
"vite"
12+
"vite",
13+
"migrating-from-temporal",
14+
"migrating-from-inngest",
15+
"migrating-from-aws-step-functions"
1316
],
1417
"defaultOpen": true
1518
}

0 commit comments

Comments
 (0)