Framework Integrations API
Vite, React Router, Next.js, Electron, and browser-worker helpers for configuring and hosting @taucad/runtime.
Framework helpers package Tau's required build, header, worker, and host-process invariants behind stable configuration seams that hold across every qualified framework version.
Vite and React Router
tauRuntime(options?) returns an array of Vite plugins. Vite flattens nested plugin arrays, so place the result directly in plugins without spreading it:
import { reactRouter } from '@react-router/dev/vite';
import { tauRuntime } from '@taucad/runtime/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [tauRuntime(), reactRouter()],
});Prop
Type
Prop
Type
tauRuntime() includes cross-origin-isolation middleware by default. Set crossOriginIsolation: false only when the production host owns those headers; the lower-level crossOriginIsolation() export installs only Vite dev/preview headers.
React Router SSR response code applies the canonical headers:
import { applyHandleRequestHeaders } from '@taucad/runtime/react-router';
export function applyRuntimeHeaders(responseHeaders: Headers): void {
applyHandleRequestHeaders(responseHeaders);
}Express and Connect hosts mount the server adapter without a cast:
import express from 'express';
import { coiMiddleware } from '@taucad/runtime/cross-origin-isolation/express';
const app = express();
app.use(coiMiddleware());@taucad/runtime/cross-origin-isolation also exports the raw header maps and appliers — documentHeaders, subresourceHeaders, applyDocumentHeaders, applySubresourceHeaders — plus the IsolationStatus / IsolationFailureReason diagnostic types for custom hosts.
Next.js
withTauRuntime() composes application headers and bundler configuration into a NextRuntimeConfig. The same call configures Next.js 15's supported Webpack production path and Next.js 16's Turbopack path.
import { withTauRuntime } from '@taucad/runtime/nextjs/config';
export default withTauRuntime({
output: 'standalone',
});Prop
Type
Prop
Type
Prop
Type
Use nextRuntimeHeaders(options?) only as the low-level header-rule escape hatch; it configures neither browser-worker assets nor Node builtin aliases.
@taucad/runtime/nextjs/browser-node-builtins is the browser alias target withTauRuntime() wires for Node builtins; its stubs (accessSync, createReadStream, createWriteStream, dirname, existsSync, fileURLToPath, mkdirSync, readFileSync, readdirSync, statSync, unlink, unlinkSync, writeFileSync, webcrypto, …) are not for direct use.
Electron config
electronRuntimeConfig() composes electron-vite's main, preload, and renderer config, supporting electron-vite 5/Vite 7 and electron-vite 6 beta/Vite 8 through the same call:
import { electronRuntimeConfig } from '@taucad/runtime/electron/vite';
export default electronRuntimeConfig({
main: {},
preload: {},
renderer: {},
});Prop
Type
The adapter installs Tau's Vite invariants in main and renderer and the native dependency externalizer in main and preload. See Bundling for utility-process entries.
Electron process boundaries
The public Electron topology has one helper at each process boundary:
| Process | Import | Helper |
|---|---|---|
| Main | @taucad/runtime/electron/main | installElectronRuntimeHeaders, registerElectronRuntimeMain |
| Preload | @taucad/runtime/electron/preload | exposeElectronRuntime |
| Utility | @taucad/runtime/electron/utility | serveElectronRuntime |
| Renderer | @taucad/runtime/electron/renderer | createElectronClientOptions |
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Application renderer code needs only the high-level options provider:
import { createRuntimeClient } from '@taucad/runtime/client';
import { createElectronClientOptions } from '@taucad/runtime/electron/renderer';
const provideClientOptions = createElectronClientOptions();
const client = createRuntimeClient({ ...(await provideClientOptions()), operationTimeout: 60_000 });requestElectronRuntimePort(), getElectronRuntimeBridge(), awaitElectronRuntimePort(), and the bridge types are escape hatches for alternate globals or host adapters, as are the wire pieces electronRuntimeChannel, electronUtilityTransport (ElectronUtilityTransportOptions), electronUtilityClient, electronUtilityClientDescribe, and electronUtilityHost (ElectronUtilityHostOptions). Application code should not handle opaque host IDs or call releaseRuntimeHost() directly.
Browser-worker transport
Use the paired high-level helpers for the app-owned Web Worker topology:
import { createRuntimeClient } from '@taucad/runtime/client';
import { createWebWorkerClientOptions } from '@taucad/runtime/transport/web';
const clientOptions = createWebWorkerClientOptions({
createWorker: () => new Worker(new URL('./runtime.worker.ts', import.meta.url), { type: 'module' }),
});
const client = createRuntimeClient({ ...clientOptions, operationTimeout: 60_000 });Prop
Type
The app-owned worker entry serves its executable runtime definition:
import { esbuild } from '@taucad/esbuild';
import { replicad } from '@taucad/replicad';
import { defineRuntime } from '@taucad/runtime/worker';
import { serveWebWorkerRuntime } from '@taucad/runtime/worker/web';
const runtime = defineRuntime({
plugins: [replicad(), esbuild()],
});
await serveWebWorkerRuntime({ runtime });Prop
Type
Use webWorkerTransport and webWorkerHost directly only when authoring a custom host composition — see Transport API.