Standalone Session
A standalone session runs everything in the browser: you create VTK objects, build a pipeline, and render to a canvas — all client-side, with no server involved. This is the most common way to use VTK.wasm.
Create one from a runtime:
import { loadAsync } from "@kitware/vtk-wasm";
const runtime = await loadAsync({ url: VTK_WASM_BUNDLE_URL });
const session = runtime.createStandaloneSession();
const vtk = session.vtk; // the namespaceThe vtk namespace
session.vtk is the single object you create everything from. Calling vtk.vtkActor({ ... }) instantiates the corresponding C++ class and returns a proxy you drive with plain JavaScript.
The interaction patterns — creating objects, reading and writing properties, calling methods, observers, and rendering to a <canvas> — are covered in the Primer on VTK.wasm. The primer reaches the namespace through the annotation shortcut (vtkwasm.ready); session.vtk is the exact same namespace obtained explicitly.
Cleaning up
When you are done, call session.dispose() to free the underlying C++ session and every object it owns:
session.dispose();Sessions also implement Symbol.dispose, so a using declaration disposes automatically at the end of the scope:
using session = runtime.createStandaloneSession();
// ... session.dispose() runs automatically hereDisposing a session is what actually reclaims C++ memory — see Releasing a runtime for why disposing the runtime is not enough.
Escape hatch
If you need a C++ API that the namespace does not surface, session.native exposes the raw vtkStandaloneSession. Prefer session.vtk for everyday use.
Reference: StandaloneSession · VtkWasmRuntime