Skip to main content
Use Bun.spawn() to spawn a child process. When spawning a second bun process, you can open a direct inter-process communication (IPC) channel between the two processes.
This API is only compatible with other bun processes. Use process.execPath to get a path to the currently running bun executable.
parent.ts

The parent process sends messages to the subprocess with the .send() method on the returned Subprocess instance. The ipc handler also receives the subprocess as its second argument.
parent.ts

The child process sends messages to its parent with process.send() and receives messages with process.on("message"). This is the same API used for child_process.fork() in Node.js.
child.ts

All messages are serialized with the JSC serialize API, which supports the same set of transferrable types as postMessage and structuredClone, including strings, typed arrays, streams, and objects.
child.ts

See Child processes.