DEV Community

Cover image for Build native NodeJS / Bun addons with Nim language, in seconds πŸ‘‘
George Lemon
George Lemon

Posted on

Build native NodeJS / Bun addons with Nim language, in seconds πŸ‘‘

This is DENIM! a little CLI monster and library that provides Nim bindings for writing safe and fast native NodeJS/Bun modules.

import denim

init proc(module: Module):
  proc hello(name: string): string {.export_napi} =
    return %*("Hello, " & args[0].getStr)
Enter fullscreen mode Exit fullscreen mode

In JavaScript:

const {hello} = require('./my.node');
console.log(hello("World!")) // Hello, World!
Enter fullscreen mode Exit fullscreen mode

That's it!

Check GitHub:
https://github.com/openpeeps/denim

Top comments (0)