docs/docs/en/runjs/index.md
RunJS is the JavaScript execution environment used in NocoBase for scenarios such as JS Blocks, JS Fields, and JS Actions. Code runs in a restricted sandbox, providing safe access to the ctx (Context API) and includes the following capabilities:
awaitRunJS supports top-level await, eliminating the need to wrap code in an IIFE.
Not Recommended
async function test() {}
(async () => {
await test();
})();
Recommended
async function test() {}
await test();
ctx.importAsync() for ESM modules (Recommended)ctx.requireAsync() for UMD/AMD modulesUse ctx.render() to render content into the current container (ctx.element). It supports the following three formats:
ctx.render(<button>Button</button>);
const div = document.createElement('div');
div.innerHTML = 'Hello World';
ctx.render(div);
ctx.render('<h1>Hello World</h1>');
windowdocumentnavigatorctx