
Bun Ffi
Lets you call C and C++ libraries directly from Bun using the bun:ffi module. You get dlopen for loading shared libraries, FFI type definitions for mapping JavaScript to native types, and helpers for working with pointers and strings. The skill covers function definitions, struct handling, callbacks, and memory management. Most useful when you need to integrate existing native libraries without writing Node.js addons or when performance matters enough to justify the pointer juggling. The SQLite example is solid if you want to see a real use case. Just remember FFI calls are synchronous and block the main thread, so move heavy work to Web Workers.
- skills.sh installs
- 326
- GitHub stars
- 248
- last updated
- Aug 21, 2026
Install
$ npx -y skills add secondsky/claude-skills --skill bun-ffi --agent claude-codeInstalls into .claude/skills of the current project.
Files
Bun FFI
Bun's FFI allows calling native C/C++ libraries from JavaScript.
Quick Start
import { dlopen, suffix, FFIType } from "bun:ffi";
// Load library
const lib = dlopen(`libc.${suffix}`, {
printf: {
args: [FFIType.cstring],
returns: FFIType.int,
},
});
// Call function
lib.symbols.printf("Hello from C!\n");
Loading Libraries
Platform-Specific Paths
import { dlopen, suffix } from "bun:ffi";
// suffix is: "dylib" (macOS), "so" (Linux), "dll" (Windows)
// System library
const libc = dlopen(`libc.${suffix}`, { ... });
// Custom library
const myLib = dlopen(`./libmylib.${suffix}`, { ... });
// Absolute path
const sqlite = dlopen("/usr/lib/libsqlite3.so", { ... });
Cross-Platform Loading
function getLibPath(name: string): string {
const platform = process.platform;
const paths = {
darwin: `/usr/local/lib/lib${name}.dylib`,
linux: `/usr/lib/lib${name}.so`,
win32: `C:\\Windows\\System32\\${name}.dll`,
};
return paths[platform] || paths.linux;
}
const lib = dlopen(getLibPath("mylib"), { ... });
FFI Types
import { FFIType } from "bun:ffi";
Sponsors
Details
- Repository
- github.com/secondsky/claude-skills
- First seen
- Jun 3, 2026
More from secondsky/claude-skills
All 146- Bun Jest Migration326
- Bun Websocket Server326
- Cloudflare Workers Runtime Apis326
- Swift Best Practices326
- Bun Nuxt323
- Bun Macros322
- Cloudflare Workers Frameworks321
- Supabase Postgres Best Practices319
- Cloudflare Workers Ci Cd318
- Cloudflare Workers Dev Experience317
- Cloudflare Workers Observability315
- Cloudflare Workers Migration310
- Cloudflare Workers Multi Lang310
- Verification Before Completion310
- Nuxt Studio308
- Neon Vercel Postgres294
- Chrome Devtools288
- Database Sharding277
- Sveltia Cms277
- Google Gemini File Search272
- Tailwind V4 Shadcn8.2K
- Aceternity Ui1.6K
- Vitest Testing1.3K
- Motion1.1K