Configuration
The Nodus constructor takes a single options object. Only a container is
required to get started; everything else has sensible defaults.
import { Nodus } from '@kortexya/nodus';
const nodus = new Nodus({ container: document.getElementById('graph'), // ...additional options});The container
container accepts either an HTMLElement or the id of one. The element must
have a non-zero width and height — Nodus sizes its drawing surface to the
container and observes it for resizes.
// By elementnew Nodus({ container: document.getElementById('graph') });
// By idnew Nodus({ container: 'graph' });You can run Nodus headless (without a container) to build and analyze a graph in memory, then attach a view later. Most rendering and camera calls require a container.
Choosing a renderer
Nodus picks a renderer automatically: the GPU renderer when WebGPU is available, and the Canvas 2D renderer otherwise. You can request one explicitly:
import { Nodus, isWebGpuSupported } from '@kortexya/nodus';
const nodus = new Nodus({ container: 'graph', renderer: isWebGpuSupported() ? 'wasm' : 'canvas',});The available renderer names are 'wasm' (the Rust/wgpu GPU renderer) and
'canvas' (Canvas 2D). Requesting an unknown renderer throws an error listing
the available ones. See The Rendering Pipeline
for the full selection and fallback behaviour.
Runtime options
Options can also be read and updated after construction through the settings API:
const current = nodus.getOptions();nodus.setOptions({ /* option overrides */ });These control engine-wide behaviour (interaction defaults, rendering toggles, and similar). Visual appearance is controlled separately, through styling, not through constructor options.
Lifecycle
nodus.onReady((n) => { // Runs once the instance is fully initialized.});
nodus.isDestroyed(); // false until destroyednodus.reset(); // clear graph + view state, keep the instancenodus.destroy(); // tear down and release resourcesBundler setup for WebAssembly
The published bundle includes the compiled WebAssembly and its loader. Your
bundler only needs to be able to serve .wasm files as assets.
- Vite / Astro / SvelteKit — works with the published bundle. When building
the engine from source, add
vite-plugin-wasm. - webpack 5 — enable
experiments.asyncWebAssembly. - No bundler — import the ESM bundle directly from a static path, or use the
<script>global build. See Installation.
Optional peer features
Some integrations are optional and only loaded if you use them — for example map backgrounds (Leaflet) and spreadsheet import/export. They are declared as optional dependencies, so a base install stays lean; install the relevant package only when you need that feature.