Signature
Parameters
Configuration options for the hook.
Returns
A hook object that can be awaited or iterated over to receive payloads.
Usage
Basic Hook
Create a hook and await a single payload:Hook with Custom Token
Use a predictable token that external systems can reconstruct:Hook with Metadata
Attach additional context to the hook:Iterate Over Multiple Payloads
Receive multiple payloads using async iteration:Explicit Resource Management
Use theusing keyword for automatic disposal:
Manual Disposal
Release the token early:Notes
- Can only be called inside a workflow function (with
"use workflow") - Hooks implement AsyncIterable and can be used with
for await...of - Hooks implement the TC39 Explicit Resource Management proposal
- The token must be unique across all active hooks in your workflow runs
- Disposing a hook allows another workflow to register a hook with the same token
Related
- createWebhook - Create a webhook for HTTP requests
- defineHook - Define a typed hook with validation