# Function: useReferral()

> **useReferral**(): `object`

Defined in: ../../../../plandalf/numi/packages/react/src/hooks/useReferral.ts:23

The visitor's affiliate referral (captured by the SDK from `?via=` etc.).

  const { referral, loading, decorate } = useReferral();
  <a href=../_media/hooks{decorate('https://buy.stripe.com/abc')}>Buy</a>

Re-renders on `captured` / `changed` / `expired`. `decorate(url)` is a
no-op until a referral exists.

## Returns

`object`

### decorate

> **decorate**: (`url`) => `string`

#### Parameters

##### url

`string`

#### Returns

`string`

### loading

> **loading**: `boolean`

### metadata

> **metadata**: () => `Record`\<`string`, `string`\>

#### Returns

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

### referral

> **referral**: [`Referral`](https://plandalf.com/docs/packages/react/referenced-types/Referral) \| `null`

Source: https://plandalf.com/docs/packages/react/functions/useReferral
