nexus
Adapters

Choose An Adapter

Select an adapter for Chrome extensions, iframes, or local Node processes.

Install @nexus-js/core in each context, then choose the adapter for the connection between them. Your application owns context startup and target discovery.

Runtime boundaryPackageGuide
Chrome extension contexts@nexus-js/chromeChrome extension
Parent page and browser iframe@nexus-js/iframeIframe
Local daemon and Node clients over Unix sockets@nexus-js/node-ipcNode IPC
Controlled browser, WebView, and Node clients@nexus-js/websocketWebSocket

Adapters provide setup helpers, exact target types, platform channels, and connection metadata. Shared targeting and provider behavior is defined in Core concepts.

Worker And Custom Runtime

For other runtimes, implement IEndpoint<M> with a matching AdapterModel. The following sketch assumes an application-supplied createWorkerEndpoint():

import { Nexus } from "@nexus-js/core";
import type { AdapterModel, IEndpoint } from "@nexus-js/core";

interface WorkerModel extends AdapterModel {
  contextMeta: { context: "worker" | "host" };
  connectionMeta: { readonly transport: "worker-port" };
  connectionTarget: { context: "worker"; workerId: string };
}

const workerNexus = new Nexus<WorkerModel>();
const endpoint: IEndpoint<WorkerModel> = createWorkerEndpoint();

workerNexus.configure({
  endpoint: {
    implementation: endpoint,
    meta: { context: "host" },
  },
});

The driver accepts ports, connects and matches exact targets, and closes platform resources. Core owns service calls, policy, and session lifecycle.

Multiple Graphs

Use separate named Nexus<M> instances for independent transport graphs.

Testing Boundary

Use application mocks for code consuming NexusInstance. Use adapter integration tests for real channels, authorization, reload, and disconnect behavior.

Edit this page on GitHub