---
url: 'https://adk.nht.io/api/@nhtio/adk/batteries/functions/spawnIsolated.md'
---

# Function: spawnIsolated()

```ts
function spawnIsolated<S>(
  spec: S,
  options: SpawnIsolatedOptions,
): IsolatedService<S>;
```

Defined in: [src/batteries/isolation/browser.ts:285](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/isolation/browser.ts#L285)

Sugar for `createIsolatedService(spec, createWorkerTransport(spec, options), options)` — spawn a
real Worker-backed [IsolatedService](../interfaces/IsolatedService.md) in one call.

## Type Parameters

| Type Parameter                                                                                                                                                                                                     |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `S` *extends* [`IsolatedServiceSpec`](../interfaces/IsolatedServiceSpec.md)<[`MethodMap`](../type-aliases/MethodMap.md), [`StreamMap`](../type-aliases/StreamMap.md), [`EventMap`](../type-aliases/EventMap.md)> |

## Parameters

| Parameter | Type                                                            |
| --------- | --------------------------------------------------------------- |
| `spec`    | `S`                                                             |
| `options` | [`SpawnIsolatedOptions`](../interfaces/SpawnIsolatedOptions.md) |

## Returns

[`IsolatedService`](../interfaces/IsolatedService.md)<`S`>

## Remarks

The transport-only keys (`worker`/`workerOptions`) are stripped before the remaining options reach
`createIsolatedService` — its validator is deliberately strict (unknown keys rejected), accepting
only the base [IsolatedServiceOptions](../interfaces/IsolatedServiceOptions.md) shape; the transport-only keys were already validated
(and consumed) by [createWorkerTransport](createWorkerTransport.md).

## Throws

@nhtio/adk/batteries/isolation!E\_ISOLATION\_UNSUPPORTED\_ENV when no browser `Worker`
global is present.

## Throws

@nhtio/adk/batteries/isolation!E\_INVALID\_ISOLATION\_OPTIONS when `options` fails
validation.
