docs/docs/en/runjs/index.md
RunJS is the JavaScript execution environment in NocoBase used for JS Block, JS Field, JS Action, and similar scenarios. Code runs in a restricted sandbox with safe access to the ctx (context API) and supports:
awaitawaitRunJS supports top-level await; you do not need to wrap code in an IIFE.
Not recommended
async function test() {}
(async () => {
await test();
})();
Recommended
async function test() {}
await test();
ctx.importAsync() (recommended)ctx.requireAsync()Use ctx.render() to render content into the current container (ctx.element) in three ways:
ctx.render(<button>Button</button>);
const div = document.createElement('div');
div.innerHTML = 'Hello World';
ctx.render(div);
ctx.render('<h1>Hello World</h1>');
windowdocumentnavigatorctx