# @delight-rpc/child-process

> ```sh npm install --save @delight-rpc/child-process # or yarn add @delight-rpc/child-process ```

Latest version **0.7.5** (published 2026-02-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @delight-rpc/child-process
pnpm add @delight-rpc/child-process
yarn add @delight-rpc/child-process
bun add @delight-rpc/child-process
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.7.5 |
| Published | 2026-02-26 |
| First published | 2021-12-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 7 |
| Unpacked size | 30.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | BlackGlory |
| Maintainers | black_glory |

## Links

- npm: https://www.npmjs.com/package/@delight-rpc/child-process
- Repository: https://github.com/delight-rpc/child-process
- Homepage: https://github.com/delight-rpc/child-process#readme
- Issues: https://github.com/delight-rpc/child-process/issues
- npm.io page: https://npm.io/package/@delight-rpc/child-process

## Dependencies (7)

- [extra-abort](https://npm.io/package/extra-abort.md) ^0.4.1
- [extra-defer](https://npm.io/package/extra-defer.md) ^0.3.1
- [extra-promise](https://npm.io/package/extra-promise.md) ^7.1.1
- [@blackglory/errors](https://npm.io/package/@blackglory/errors.md) ^3.1.0
- [@blackglory/prelude](https://npm.io/package/@blackglory/prelude.md) ^0.4.0
- [@delight-rpc/protocol](https://npm.io/package/@delight-rpc/protocol.md) ^4.0.0
- [@blackglory/structures](https://npm.io/package/@blackglory/structures.md) ^0.14.13

## Recent versions

- 0.7.5 (latest) — 2026-02-26
- 0.7.4 — 2026-02-25
- 0.7.3 — 2026-02-25
- 0.7.2 — 2026-02-25
- 0.7.1 — 2026-02-25
- 0.7.0 — 2026-02-25
- 0.6.6 — 2026-02-25
- 0.6.5 — 2026-02-25
- 0.6.4 — 2026-02-12
- 0.6.3 — 2025-11-03
- 0.6.2 — 2023-06-10
- 0.6.1 — 2023-03-19
- 0.6.0 — 2023-03-19
- 0.5.2 — 2023-02-11
- 0.5.1 — 2023-02-05
- … 20 more at https://npm.io/package/@delight-rpc/child-process/versions

## README

# @delight-rpc/child-process
## Install
```sh
npm install --save @delight-rpc/child-process
# or
yarn add @delight-rpc/child-process
```

## Usage
### Main as Client, ChildProcess as Server
```ts
// api.d.ts
interface IAPI {
  echo(message: string): string
}

// child-process.ts
import { createServer } from '@delight-rpc/child-process'

const api: IAPI = {
  echo(message: string): string {
    return message
  }
}

createServer(api, process)

// main.ts
import { fork } from 'child_process'
import { createClient } from '@delight-rpc/child-process'

const childProcess = fork('./child-process.js', { serialization: 'advanced' })
const [client] = createClient<IAPI>(childProcess)

await client.echo('hello world')
```

### ChildProcess as Client, Main as Server
```ts
// api.d.ts
interface IAPI {
  echo(message: string): string
}

// main.ts
import { fork } from 'child_process'
import { createServer } from '@delight-rpc/child-process'

const api: IAPI = {
  echo(message: string): string {
    return message
  }
}

const childProcess = fork('./child-process.js', { serialization: 'advanced' })
createServer(api, childProcess)

// child-process.ts
import { createClient } from '@delight-rpc/child-process'

const [client] = createClient<IAPI>(process)
await client.echo('hello world')
```

## API
### createClient
```ts
function createClient<IAPI extends object>(
  process: ChildProcess | NodeJS.Process
, options?: {
    parameterValidators?: DelightRPC.ParameterValidators<IAPI>
    expectedVersion?: string
    channel?: string
    timeout?: number
  }
): [client: DelightRPC.ClientProxy<IAPI>, close: () => void]
```

### createBatchClient
```ts
function createBatchClient<DataType>(
  process: ChildProcess | NodeJS.Process
, options?: {
    expectedVersion?: string
    channel?: string
    timeout?: number
  }
): [client: DelightRPC.BatchClient<DataType>, close: () => void]
```

### createServer
```ts
function createServer<IAPI extends object>(
  api: DelightRPC.ImplementationOf<IAPI>
, process: ChildProcess | NodeJS.Process
, options?: {
    parameterValidators?: DelightRPC.ParameterValidators<IAPI>
    version?: `${number}.${number}.${number}`
    channel?: string | RegExp | AnyChannel
    ownPropsOnly?: boolean
  }
): () => void
```

---
_Source: https://npm.io/package/@delight-rpc/child-process · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
