| Luau Web 1.5.0 @741 |
|---|
Luau bindings with dynamic JavaScript interop for web browsers, Node.js, and TypeScript.
Luau Web [1.5.0@741] — Javascript bindings for Luau
This project uses luau-interop which is my fork of Luau with a rewritten WASM execution API.
Features
- Easy to use and you won’t have to call Luau C API functions yourself
- Create and override globals in the Luau runtime
- Luau can interact with all values from JS
- JS can interact with all values from Luau
- Embeddable in websites, and Node.JS without extra setup.
- Sandboxed environment, basically bulletproof
- Near-native performance
Near native performance disclaimer
(around 10% performance loss, still around 40M operations/sec on an average laptop, around the same as Luau’s demo Redirecting to: https://play.luau.org/ if not faster)
Security
The Luau runtime is safe and secure by design, and my fork preserves that safety.
The security is in your hands and you have to make sure the values and functions you expose to the runtime are also secure. You can follow the basic security principles in the wiki.
You could give the runtime access to a node library like fs or any other, but only do it if you are only running your own trusted code, or if you heavily safeguard the exposed functions.
Risky Example
import FS from "fs";
import { LuauState, InternalLuauWasmModule } from "luau-web"
const state = await LuauState.createAsync({
FS
});
state.loadstring(`print(FS.readdirSync('.'))`, "index.ts", true)();
For more info see luau-web/wiki/Security
Example Script
import { LuauState, LuauTable, LuauFunction, Mutable } from "../src"
const writable = Mutable({ });
const state = await LuauState.createAsync({
example: function (str1: string, tbl: LuauTable, luaPrint: LuauFunction) {
luaPrint(tbl, "hi :3");
return str1 + tbl.one;
},
writable: writable
});
const func = state.loadstring(`print(example(..., {one = 2}, print)); writable.a = true; return ...`, "index.ts", true); // prints "hello2"
console.log(await func("hello", "hi"), writable.a); // ["hello", hi], true
It interacts and integrates cleanly with Luau values.
Limitations
- It should be pretty stable, but this is still new - report issues you encounter and I will fix them as best as I can.





