wasmrt

Nim wasm runtime

Pure Nim score 15/100 · tests present · no docs generated

Summary

Latest Version 0.2.0
License MIT
CI Status Failing
Downloads 0
Last Indexed 2026-07-21 05:26

Authors

  • Yuriy Glukhov

Installation

nimble install wasmrt
choosenim install wasmrt
git clone https://github.com/yglukhov/wasmrt

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
wasmrt - - - - - - -

Source

Repository https://github.com/yglukhov/wasmrt
Homepage https://github.com/yglukhov/wasmrt
Registry Source nimble_official

README

wasmrt CI nimble

Compile nim to wasm

import wasmrt
proc consoleLog(a: string) {.importwasmraw: "console.log($0)".}
consoleLog("Hello, world!")
nim c --out:test.wasm test.nim # Special nim config is required, see below
node tests/runwasm.js test.wasm

Prerequisites

  • clang 20.0 or later
  • Special Nim config, like this one
  • [Optional] wasm-opt - a tool to compact your wasm file

Run your wasm

The wasm file generated this way is pretty standalone, and requires only the following JavaScript code to bootstrap:

function runNimWasm(w){for(i of WebAssembly.Module.exports(w))n=i.name,n[0]==';'&&new Function('m',n)(w)}

runNimWasm takes the output of WebAssembly.compile function. E.g. to run a wasm file in nodejs, use smth like runwasm.js

Convert wasm to html

The generated wasm file can be "converted" to a standalone html file with wasm2html tool provided in this package.

nim c --out:test.wasm test.nim # Special nim config is required, see below
wasm2html test.wasm test.html

Why no Emscripten?

The goal of this project is to produce self-contained standalone wasm files from nim code, without any JS glue, or "desktop platform emulation".