---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/media/type-aliases/EngineSelectionMiddlewareFn.md
description: >-
  A selection-middleware stage — the seam for quality heuristics and implementor
  overrides when several engines can perform the same transform (e.g. route
  complex workbooks past a pure-JS converter to LibreOffice). Same onion shape
  as the battery's `use` interceptors; a fresh runner is minted per dispatch.
  Keep stages cheap or memoized: they run with bytes in hand on every dispatch.
---

# Type Alias: EngineSelectionMiddlewareFn

```ts
type EngineSelectionMiddlewareFn = (
  ctx: EngineSelectionContext,
  next: NextFn,
) => void | Promise<void>;
```

Defined in: [src/batteries/media/registry.ts:111](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/media/registry.ts#L111)

A selection-middleware stage — the seam for quality heuristics and implementor overrides
when several engines can perform the same transform (e.g. route complex workbooks past a
pure-JS converter to LibreOffice). Same onion shape as the battery's `use` interceptors;
a fresh runner is minted per dispatch. Keep stages cheap or memoized: they run with bytes
in hand on every dispatch.

## Parameters

| Parameter | Type                                                                |
| --------- | ------------------------------------------------------------------- |
| `ctx`     | [`EngineSelectionContext`](../interfaces/EngineSelectionContext.md) |
| `next`    | `NextFn`                                                            |

## Returns

`void` | `Promise`<`void`>
