---
editLink: false
lastUpdated: false
---

[@salesforce/b2c-tooling-sdk](../../modules.md) / [plugins](../index.md) / invokeHook

# Function: invokeHook()

> **invokeHook**\<`TResult`\>(`hookFilePath`, `context`, `hookOptions`, `logger?`): `Promise`\<`TResult` \| `undefined`\>

Defined in: [packages/b2c-tooling-sdk/src/plugins/loader.ts:72](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/e7c16f1ae423da0aa47b3e10be88f9770b53619b/packages/b2c-tooling-sdk/src/plugins/loader.ts#L72)

Dynamically imports a hook file and invokes its default export.

## Type Parameters

### TResult

`TResult`

## Parameters

### hookFilePath

`string`

Absolute path to the hook JS file

### context

[`HookContext`](../interfaces/HookContext.md)

Hook context (`this` inside the hook)

### hookOptions

`Record`\<`string`, `unknown`\>

Options passed as the first argument to the hook function

### logger?

[`Logger`](../../logging/interfaces/Logger.md)

Optional logger for warnings on failure

## Returns

`Promise`\<`TResult` \| `undefined`\>

The hook function's return value, or `undefined` on error
