Volt v0.1 · TypeScript APIs on Bun · Get started
Docs/Guides/Node.js Adapter

Node.js Adapter

Run the core HTTP app through the Node adapter.

Runtime scope

The native app.listen() implementation targets Bun. On Node use @voltts/core and @voltts/node directly, plus a TypeScript runner such as tsx. Bun-specific facilities such as Bun.SQL and WebSocket upgrades are not supplied by this HTTP adapter.

bash
npm install @voltts/core @voltts/node
npm install --save-dev tsx typescript @types/node

Complete Node entry point

index.ts
import { Volt } from '@voltts/core';
import { serve } from '@voltts/node';

const app = new Volt();
app.get('/health', () => ({ ok: true }));
if (globalThis._importMeta_.main) {
  const server = serve(app, { port: 3000, hostname: '0.0.0.0' });
  process.once('SIGTERM', () => server.close(() => { void app.stop(); }));
}
export default app;

Run on Node

Node's TypeScript runner does not provide Bun's globalThis._importMeta_.main. Replace that guard with a direct server start in a standalone Node entry, or use this separate launcher:

start.ts
import { serve } from '@voltts/node';
import app from './index';
serve(app, { port: 3000 });
bash
npx tsx start.ts
curl http://localhost:3000/health

The adapter converts Node requests into Web Standard Requests and forwards responses. It does not provide automatic parity for Bun server options, cookies with multiple Set-Cookie headers, or stream backpressure. Verify those behaviors for your application.