JavaScript SDK
@inverge/nexus — one isomorphic package for the browser (React, Vue, Angular, Svelte…) and Node (Express, Fastify, Nest, serverless), plus Telescope for Node.
The same package runs in the browser and on the server. It ships ESM + CommonJS + TypeScript types and has no required runtime dependencies.
- npm
@inverge/nexus1.4 · Node 18+ (globalfetch) · modern browsers · source - Entry points:
@inverge/nexus,@inverge/nexus/react,@inverge/nexus/telescope(Node only) - API reference
Install
npm install @inverge/nexus
npm install socket.io-client # only for nexus.realtime
npm install rrweb # only for browser session replayInitialise
import { Nexus } from '@inverge/nexus';
const nexus = Nexus.init({
apiKey: 'nxs_live_xxx',
appVersion: '2.1.0',
remoteConfigEnabled: true,
});
await nexus.identify('user_123', { email: 'ada@example.com' });
nexus.events.track('page_view', { path: '/pricing' });
Nexus.instance; // the same client, anywhereServices: sessions · events · logs · errors · flags · remoteConfig ·
links · realtime · surveys · replay · push · inApp · liveActivities.
Configuration
| Option | Default | |
|---|---|---|
apiKey | — | |
appVersion, defaultProperties | — / {} | |
autoTrackSessions | true | |
autoCaptureErrors | true | Browser error / unhandledrejection; Node uncaughtException / unhandledRejection |
flushOnHide | true | Page hide / process exit |
flushIntervalMs, maxBatch | 10000, 50 | |
logLevel | warn | silent · error · warn · info · debug |
remoteConfigEnabled, remoteConfigRealtime, remoteConfigDefaults | false, false, {} | |
replayEnabled, replayMaskAllInputs, replayBlockClass, replayMaskTextClass | false, true, nexus-block, nexus-mask | Browser only |
services, enabled | all on | Switching services off |
fetch | global fetch | Custom fetch |
Frameworks
import { NexusProvider, useNexus, useFlag, useRemoteConfig, useTrackEvent } from '@inverge/nexus/react';
export function Root() {
return (
<NexusProvider config={{ apiKey: 'nxs_live_xxx', remoteConfigEnabled: true }}>
<App />
</NexusProvider>
);
}
function App() {
const rc = useRemoteConfig(); // re-renders when config changes
const promo = useFlag('promo_banner');
const track = useTrackEvent();
return <button onClick={() => track('cta_click')}>{rc.getString('cta_label', 'Buy now')}</button>;
}Hooks: useNexus(), useTrackEvent(), useFlag(key), useRemoteConfig(),
useRemoteConfigValue(key, fallback). Pass an existing client with
<NexusProvider client={nexus}>.
Server-side sends
From Node you can drive the server products — push, Live Activities, in-app fetches — with the same client:
await nexus.push.notification().title('Shipped').toUser('u_1').send();
await nexus.liveActivities.template('order_tracking', 'order_42').step('pending').toUser('u_1').start();Lifecycle
await nexus.flush(); // everything, now
nexus.dispose();Telemetry flushes automatically on page hide / tab switch and on SIGTERM,
SIGINT and beforeExit.
