Skip to content

Installation

Nodus ships as the npm package @kortexya/nodus. It is ESM-first and also provides a standalone bundle you can drop into a page with a <script> tag.

Terminal window
npm install --save @kortexya/nodus
import { Nodus } from '@kortexya/nodus';
const nodus = new Nodus({ container: document.getElementById('graph') });

The default export is the same Nodus class:

import Nodus from '@kortexya/nodus';

Drop the prebuilt bundle into a page; Nodus is exposed as a global.

<script src="path/to/nodus.umd.cjs"></script>
<script>
const nodus = new Nodus({ container: 'graph-container' });
</script>
<script type="module">
import { Nodus } from '/path/to/@kortexya/nodus/nodus.src.bundle.js';
const nodus = new Nodus({ container: 'graph-container' });
</script>

Nodus’s Rust core is compiled to WebAssembly. You do not call an init function — importing the package eagerly initializes the WASM core (via top-level await), so new Nodus(...) is synchronous and ready to use as soon as the module has loaded.

Requirement Notes
Module format ES modules (a <script> global build is also provided)
WebAssembly Required — included in every modern browser
WebGPU Optional — enables the GPU renderer; Nodus falls back to Canvas 2D otherwise
A container element An HTMLElement (or its id) with a non-zero size

WebGPU is not required: when it is unavailable Nodus automatically uses the Canvas 2D renderer. See The Rendering Pipeline for how the renderer is selected.

The package exposes:

  • Nodus — the main class (also the default export).
  • isWebGpuSupported() — a runtime WebGPU capability check.
  • Element wrappers — Node, Edge, NodeList, EdgeList.
  • Helpers & types — BoundingBox, Transformation, StyleRule, StyleClass, NonObjectPropertyWatcher, ObjectPropertyWatcher.
  • Renderers — WasmGraphRenderer, WasmRendererAdapter.
  • Namespaces — geometry, parse, hypergraph.
  • Layout factories — forceFactory, forceLinkFactory, gridFactory, hierarchicalFactory, radialFactory, concentricFactory, sequentialFactory.
  • Backend activation — enableWasmBackend, configureBackends, useWasm.
import { Nodus, isWebGpuSupported } from '@kortexya/nodus';
const nodus = new Nodus({ container: document.getElementById('graph') });
console.log('WebGPU available:', isWebGpuSupported());
await nodus.setGraph({
nodes: [{ id: '1' }, { id: '2' }],
edges: [{ source: '1', target: '2' }],
});
await nodus.layouts.force({ duration: 0 });
await nodus.view.locateGraph();

If you see two connected nodes centered in your container, you’re ready to go. Continue with the Quick Start.