Node.js 26.9 Enables node:ffi by Default

Node.js 26.9.0 landed on September 16, 2026, and one short line in its notable changes rearranges how JavaScript reaches native code: ffi: enable module by default. The module that arrived experimentally in 26.1.0 behind --experimental-ffi now needs no flag at all. A plain import from node:ffi loads a shared library and calls its functions directly.

The problem it removes

Reaching a C library from Node.js has historically meant a long road: write a native addon against Node-API, generate build files with node-gyp, then keep a C++ toolchain on every machine and every architecture in the pipeline. One small dependency drags an entire build stack behind it, and every runtime upgrade means rebuilding. The usual escape hatch — a third-party FFI package — shipped its own native layer, which reintroduced the same problem through the back door.

That layer now lives inside the runtime. No compiler, no build step, no line in package.json.

What actually changed

The API centres on dlopen: hand it a library path and the definitions you want, and it returns callable wrappers. Types are written as strings — int32, uint64, float64, pointer, string, buffer — and 64-bit integers cross the boundary as bigint. The suffix export gives you the correct extension per platform (so, dylib, dll), so no manual branching.

javascript
import { dlopen, suffix } from 'node:ffi';

using libz = dlopen(`libz.${suffix}`, {
  zlibVersion: { arguments: [], return: 'string' },
  crc32: { arguments: ['uint64', 'buffer', 'uint32'], return: 'uint64' },
});

const { zlibVersion, crc32 } = libz.functions;

console.log(zlibVersion());

const payload = Buffer.from('bahashwan.dev');
const checksum = crc32(0n, payload, payload.length);
console.log(checksum.toString(16));

Note using instead of const: the handle closes automatically when the scope exits, which beats calling close() by hand on every exit path.

The reverse direction works too. registerCallback builds a native callback pointer backed by a JavaScript function and returns its address as a bigint, ready to pass to a library that expects a callback:

javascript
const onProgress = libz.registerCallback(
  { arguments: ['int32'], return: 'int32' },
  (value) => value * 2,
);

Real-world caveats

The module is on by default, but the official documentation still marks it experimental. The distinction matters: no flag is not the same as a frozen API.

More importantly, this is a memory-unsafe interface by design, and the docs say so plainly. A bad pointer, a mismatched signature, or access to freed memory will crash the process or corrupt memory. There is no ownership tracking — the caller owns every pointer lifetime. Callbacks carry their own rules: they run on the same thread, must not throw, and must not close the library while executing.

A third point deserves attention before you write your first signature: C type widths are not portable. unsigned long is 64-bit on Linux and macOS and 32-bit on Windows. FFI does not read headers and will not correct you — it trusts the definition you supply. The same signature can work in one place and silently corrupt memory in another.

Operationally: several architectures are unsupported outright (s390x and the mips family among them), and the fast-call path is limited to a bounded argument count before falling back to the slower generic path. With the Permission Model enabled, access still requires --allow-ffi, which is the correct default posture for anything calling native code. (We covered the Node.js permission model CVEs and its practical limits earlier.)

One last constraint: version 26 is Current, not LTS. Teams shipping on LTS are waiting, which makes this a good moment to experiment rather than depend.

Takeaway

Dropping the flag does not make calling native code safe — it makes it cheap. Cases that used to be rejected because a native addon cost more than it returned — binding a crypto library, a codec, an SDK with no JavaScript equivalent — are worth revisiting. The trade-off moved from "is this worth an addon?" to "can we own manual memory management on this path?", and that is a clearer question to answer.

Source: the Node.js 26.9.0 release notes and the official node:ffi documentation.