- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
Menu
- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
createHook - Workflows SDK Reference
This documentation provides a reference to the createHook
. It belongs to the Workflows SDK.
Expose a hook in your workflow where you can inject custom functionality as a step function.
A handler hook can later be registered to consume the hook and perform custom functionality.
Learn more in this documentation.
Example#
1import {2 createStep,3 createHook,4 createWorkflow,5 WorkflowResponse,6} from "@medusajs/framework/workflows-sdk"7import { createProductStep } from "./steps/create-product"8 9export const myWorkflow = createWorkflow(10 "my-workflow",11 function (input) {12 const product = createProductStep(input)13 const productCreatedHook = createHook(14 "productCreated",15 { productId: product.id }16 )17 18 return new WorkflowResponse(product, {19 hooks: [productCreatedHook],20 })21 }22)
Type Parameters#
Name
stringOptionalTInvokeInput
objectOptionalParameters#
name
NameThe hook's name. This is used when the hook handler is registered to consume the workflow.
input
TInvokeInputThe input to pass to the hook handler.
Returns#
Hook
Hook<Name, TInvokeInput>A workflow hook.
Was this page helpful?