Embedding API

Embed VexaScript editors in your own pages

Use the generated website bundle to embed a single-file editor, a multi-tab editor, or a full workbench with a workspace tree and toolbar directly into tutorials, docs, and demos.

Drop editors into any lesson page.

Simple editor

<div id="lesson-editor"></div>
<script src="/assets/generated/vexa-embed.js"></script>
<script>
  VexaScriptEmbeds.createSimpleEditor("#lesson-editor", {
    content: "fun add(a: int, b: int): int { return a + b }",
    inlayHints: false
  })
</script>

Workspace editor

VexaScriptEmbeds.createWorkspaceEditor("#workspace", {
  activePath: "/main.vx",
  files: [
    { path: "/main.vx", content: "import { greet } from './greeter.vx'\nconsole.log(greet('VexaScript'))" },
    { path: "/greeter.vx", content: "export fun greet(name: string): string { return $\"Hello {name}\" }" }
  ]
})

Full workbench

VexaScriptEmbeds.createWorkbenchEditor("#workbench", {
  activePath: "/src/main.vx",
  allowWorkspaceWrites: true,
  inlayHints: true,
  files: [
    { path: "/src/main.vx", content: "import { greet } from './greeter.vx'\nconsole.log(greet('VexaScript'))" },
    { path: "/src/greeter.vx", content: "export fun greet(name: string): string => $\"Hello {name}\"" }
  ]
})

Embedded Monaco

Use the compiler and editor directly in lessons.

The website bundle exposes three helpers: a simple single-file editor, a multi-tab editor, and a full workbench editor with a workspace tree, toolbar, formatting, and save controls.

Embeds also support an inlayHints flag so each host can turn hints on or off, while workbench embeds additionally support allowWorkspaceWrites to enable or disable editing, saving, and workspace mutations plus a reset button that restores the original embedded files.

Single-file snippet
Multi-file workspace
Full workbench