Quick Start
Set up a Nexus daemon and client over local Unix sockets.
Configure a daemon that exposes an echo service, then call it from a client process.
1. Install Packages
pnpm add @nexus-js/core @nexus-js/node-ipcAuthentication is optional
The quick start uses the default local socket setup without a shared secret. Add the adapter’s pre-auth configuration before exposing services when local clients are not already trusted.
2. Start From A Shared Contract
Both processes import EchoToken from shared code using the
shared contract pattern.
Its service exposes echo(input: string): Promise<string>.
3. Configure The Daemon
The daemon owns the listening endpoint and service implementation.
import { usingNodeIpcDaemon } from "@nexus-js/node-ipc";
import { EchoToken } from "./shared";
usingNodeIpcDaemon({ appId: "example-app" }).provide(EchoToken, {
async echo(input) {
return `echo:${input}`;
},
});The daemon’s peer identity is NodeIpcContextMeta; the client connects with an exact NodeIpcConnectionTarget containing appId and optional instance.
4. Configure The Client
The client owns an outgoing endpoint. Connect with the daemon’s exact address.
import { nexus } from "@nexus-js/core";
import { usingNodeIpcClient } from "@nexus-js/node-ipc";
import { EchoToken } from "./shared";
usingNodeIpcClient({
appId: "example-app",
});
const connection = await nexus.connect({
target: { context: "node-ipc-daemon", appId: "example-app" },
});
const echo = connection.get(EchoToken);
console.log(await echo.echo("hello"));Pass timeout to bound acquisition and callTimeout to get to override the
runtime call default:
const connection = await nexus.connect({
target: {
context: "node-ipc-daemon",
appId: "example-app",
},
timeout: 30_000,
});
const echo = connection.get(EchoToken, { callTimeout: 5_000 });Optional Workflows
- For a client that provides services to a daemon and uses one-shot startup dialing, see Node IPC concepts.
- For shared-secret pre-auth and its optional combination with core policy, see Authentication and Authorization and policy.
First Failure Checklist
If the first call fails, check these in order:
- Is the daemon process still running?
- Are daemon and client using the same
appIdandinstance? - Does the socket path resolve where you expect? See Addressing.
- If
authTokenis configured, do both sides use the same non-empty token? - Does
policy.canConnectallow the client? - Does
policy.canCallallow the service name and operation? - Are you reusing an old proxy after daemon restart? Reconnect and get a fresh proxy.