> ## Documentation Index
> Fetch the complete documentation index at: https://armory.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Hooks

> Create custom Armory hooks for advanced flow control

Use custom hooks to implement project-specific behavior in payment lifecycle phases.

```typescript theme={null}
import type { ClientHook } from '@armory-sh/client-hooks';

const customHook: ClientHook = {
  name: 'require-premium-route',
  onPaymentRequired: async (context) => {
    const url = typeof context.url === 'string' ? context.url : context.url.toString();

    if (!url.includes('/premium')) {
      return;
    }
  },
  onError: async (context) => {
    console.error('[hook-error]', context.phase, context.error);
  }
};
```

For custom x402 extension payload fields, use `createCustomHook` from `@armory-sh/extensions`.
