Adapters
The bunAdapter and nodeAdapter values that connect Arcton to a runtime.
Overview
Pick a runtime by passing an adapter to app.listen(). bunAdapter is the default; pass nodeAdapter to run under Node.js instead. Both implement the RuntimeAdapter interface.
import { nodeAdapter } from '@arcton/adapter-node'
import { Arcton } from '@arcton/core'
const app = Arcton()
app.get('/', () => 'Hello from Node')
app.listen({ adapter: nodeAdapter })bunAdapter
Purpose — runs an Arcton app on Bun.
Signature
const bunAdapter: RuntimeAdapterBehavior — name is 'bun'. version is a live getter returning Bun.version. capabilities.websocket is true. It wraps Bun.serve(): it serves the app's fetch handler, exposes port/url on the returned server, auto-upgrades any registered ws() route, and turns an uncaught error thrown from the handler into a 500 response, logged with console.error. stop() returns void synchronously.
Example
import { bunAdapter } from '@arcton/adapter-bun'
import { Arcton } from '@arcton/core'
const app = Arcton()
app.get('/', () => 'Hello from Bun')
app.listen({ adapter: bunAdapter })nodeAdapter
Purpose — runs an Arcton app on Node.js.
Signature
const nodeAdapter: RuntimeAdapterBehavior — name is 'node'. version is a live getter returning process.version with its leading v stripped, so it matches Bun's bare-number format (e.g. '20.11.0', not 'v20.11.0'). capabilities.websocket is true. It wraps node:http's createServer for HTTP and the ws package for WebSocket upgrades: it serves the app's fetch handler, exposes port/url on the returned server, auto-upgrades any registered ws() route, and turns an uncaught error thrown from the handler into a 500 response, logged with console.error. stop() returns a Promise<void>.
Example
import { nodeAdapter } from '@arcton/adapter-node'
import { Arcton } from '@arcton/core'
const app = Arcton()
app.get('/', () => 'Hello from Node')
const server = app.listen({ adapter: nodeAdapter, port: 0 })
await server.stop()Real differences between the two
Both adapters serve the same fetch handler and the same ws() routes, but two details differ in ways worth knowing before you rely on them:
stop()returns aPromise<void>onnodeAdapterandvoidonbunAdapter.await server.stop()is safe with either — awaiting a non-Promisevalue is a no-op.bunAdapter.versionis exactlyBun.version;nodeAdapter.versionis the Node version string with its leadingvremoved.
See Runtime support for guidance on choosing between them.