Call C libraries from Clojure, babashka and Node.js.
Babashka embeds this library as a built-in and consumes the repository as a submodule. The library has no dependencies beyond JDK 25.
Status: experimental. The API can still change (although no changes are planned).
org.babashka/ffi {:mvn/version "0.1.2"}| Platform | Requirement | Notes |
|---|---|---|
| JVM | JDK 25 or newer | Uses the Java FFM API. |
| babashka | 1.13.220 or newer | Built in, no dependency needed. |
| GraalVM native image | GraalVM 25 or newer | See Build your own native image. |
| Node.js | 26.1 or newer | Works with nbb, ClojureScript, shadow-cljs and squint through node:ffi. See On Node.js. |
Bun and Deno are not supported.
On the JVM, start with --enable-native-access=ALL-UNNAMED, or set the
Enable-Native-Access manifest attribute in an uberjar. Without the flag,
modern JDKs warn, and a future JDK release refuses the calls.
In babashka the namespace is built in: (require '[babashka.ffi :as ffi]).
- babashka.sqlite: SQLite
- babashka.postgres: PostgreSQL through libpq
- babashka.duckdb: DuckDB
- filewatcher: file watching through FSEvents, inotify and ReadDirectoryChangesW
None of them expose an arena, a pointer, or a layout: the FFI stays inside the library.
doc/guide.md documents the API: library loading, function binding, memory, arenas, structs, callbacks, and performance limits for each host.
API.md lists every public var with its arities and docstring.
Regenerate it with bb quickdoc.
The library exports a clj-kondo hook for defcfn. Copy the config with:
clj-kondo --lint "$(clojure -Spath)" --copy-configs --skip-lint
In a babashka project, use the built-in classpath:
clj-kondo --lint "$(bb print-deps --format classpath)" --copy-configs --skip-lint
Copyright © 2026 Michiel Borkent
Distributed under the MIT License. See LICENSE.
Babashka embeds this library and is itself EPL licensed. The two licenses apply to their own repositories.