Liking cljdoc? Tell your friends :D

babashka.ffi

Clojars Project bb built-in

Call C libraries from Clojure and babashka.

This library is the babashka.ffi namespace that ships inside babashka, extracted so that JVM Clojure programs can use it too. Babashka consumes this repository as a submodule.

Status: experimental. The API can still change.

org.babashka/ffi {:mvn/version "0.1.2"}

Platforms

PlatformRequirementNotes
JVMJDK 25 or newerUses the Java FFM API.
babashka1.13.220 or newerBuilt in, no dependency needed.
GraalVM native imageGraalVM 25 or newerSee Build your own native image.
Node.js26.1 or newerWorks with nbb, ClojureScript and shadow-cljs 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]).

Libraries built on it

None of them expose an arena, a pointer, or a layout: the FFI stays inside the library.

Documentation

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.

clj-kondo

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

License

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.

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close