# MaelstromExtension
Source: https://docs.maelstrom-ai.co/0.2/reference/react/type-aliases/maelstromextension/
Documentation revision: 89a8f5e9d10cedcf0b30376d7846113f06f26120
SDK manifests in this build: @maelstrom-co/react@0.2.1, @maelstrom-co/client@0.2.1, @maelstrom-co/connectors@0.2.1, @maelstrom-co/protocol@0.2.1, @maelstrom-co/engine@0.2.1
These docs follow this source revision. Manifest versions do not prove release compatibility; verify the installed package exports before using an API.

> **MaelstromExtension**<`Out`\> = (`ctx`) => `Out`

Defined in: packages/react/src/lib/extension-types.ts:62

Factory function that receives the extension context and returns additional fields to be merged onto the `MaelstromInstance`.

Extension authors implement this type to create addons (voice, analytics, devtools, etc.) and consumers apply them via `instance.with(extension)`.

Extensions must return a plain object synchronously. Async factories, arrays, and primitive values are rejected at compile time via the `ExtensionOutput` constraint.

## Type Parameters

### Out

`Out` _extends_ `ExtensionOutput`

## Parameters

### ctx

[`MaelstromExtensionContext`](https://docs.maelstrom-ai.co/0.2/reference/react/interfaces/maelstromextensioncontext/)

## Returns

`Out`

## Example

```ts
const myExtension: MaelstromExtension<{ greet: () => string }> = (ctx) => ({
  greet: () => 'Hello from extension!',
});

const m = createMaelstrom({ vessels }).with(myExtension);
m.greet(); // 'Hello from extension!'
```
