Connection and credential options.
The live connection.
import { connect } from 'edgeport/nats';
await using nc = await connect({ hostname: 'nats.example.com', token: 'secret' });
await using sub = nc.subscribe('updates.>');
await nc.publish('updates.temp', '21.5');
for await (const msg of sub) {
console.log(msg.subject, new TextDecoder().decode(msg.data));
break;
}
Connects to a NATS server, authenticates, and returns a live connection.
Dials the core transport (implicit TLS when
tls: 'implicit', otherwise plaintext that may be upgraded), reads the serverINFO, performs aSTARTTLS-style upgrade when requested or required, sendsCONNECT+PING, and waits forPONGso an auth failure surfaces here as AuthError. A background pump then routes incoming messages to subscriptions.