Xuda logo Xuda Docs User Guides
/
xuda.io
← All guides Xuda JS Framework

Xuda JavaScript Framework API Reference

Source file: xuda-javascript-framework-api-reference.md

Xuda JavaScript Framework API Reference

This reference covers the full programmable surface of the Xuda JS Framework: the browser runtime constructor and every option it accepts, the 18 xu-* attributes and the two attribute families, the 15-method xu script API, the reactive primitives, the three xuda-cli commands with their configuration file, and the platform methods that a framework app or the CLI actually touches. It is written for developers building with Xuda Slim on a plain HTML page, building a project with the Xuda CLI, or calling the app data methods from their own backend. Every option name, attribute, parameter, type and required flag below is taken from the shipped runtime, the shipped CLI and the platform method contract.

The Framework Itself Has No Self-Serve API

Read this before anything else, because this product is shaped differently from the rest of the Xuda catalog.

The Xuda JS Framework is not a CPI module. There is no framework API you buy, key or call. What you program against is:

  • The browser runtime, meaning the xuda() constructor, its options, the xu-* attributes, the xu script API and the reactive primitives. This runs in the page. No credential is involved, so the sections that document it carry no availability line.
  • The CLI, meaning xuda-cli dev, xuda-cli sync and xuda-cli clean-readmes, plus xuda.config.js. This runs on your machine. No credential is involved except for sync, which reads a developer API key out of your config file.

The platform methods documented at the end are not framework methods. They are the platform methods a framework app or the CLI reaches for, and they are listed here so you know exactly which ones you can call yourself and which ones you cannot. Only four of them, the app data methods, are reachable with a developer API key. Everything else in that list is a dashboard-session method or an in-process function.

The framework has no price, no plan gate and no credit cost anywhere. Developing with Slim or the CLI locally costs nothing and needs no plan, because nothing in the local path calls a plan-gated method.

How To Call These Methods

The runtime and the CLI need no transport at all. You load a script tag, or you run a command.

The platform methods in the last part of this reference are CPI methods. CPI methods are dispatched by name over the Xuda API and MCP layer, and the normal credential for that layer is the account API key. For the transport-level detail, including how requests are framed and how the MCP layer exposes methods, see /api-mcp-integration.

From inside an app you do not need any of that plumbing. A javascript prog calls xu.call_system_api('<method>', payload) and the runtime attaches app_id, app_id_query and app_token for you.

Two things about the platform surface are worth knowing up front.

  • private: true in this codebase is a hard wall, not a soft default. A private method is excluded from the API-key method catalog and refused for API-key callers, and even a full-access key is refused. It is a dashboard-session method.
  • Some functions the CLI calls are not registered as HTTP methods at all. The /cpi/<method> router looks the method up in the platform method catalog and answers method "<x>" not exist when it is absent. Those cases are called out explicitly, method by method, rather than glossed over.

What The Availability Labels Mean

Every platform method below carries one explicit availability line. Read it first, because it tells you whether you can call the method from your own code today.

  • Availability: API key means an external developer API key or the MCP layer can call it. Four framework-adjacent methods carry this label: the four app data methods.
  • Availability: Dashboard session means a signed-in user in the Xuda dashboard can call it, and an API key cannot. Nine methods here carry this label. They are documented in full because the CLI and the API Keys screens depend on them and because their behavior defines what the connected path does.
  • Availability: Public endpoint means no authentication at all. No framework platform method carries this label. The dev server's own local /rpi/* routes are unauthenticated but they are served by the CLI on your machine, not by the platform, so they are documented separately as local routes.
  • Availability: Operator only means Xuda staff or in-process callers, listed only for completeness. Four entries carry this label, and none of them is reachable over /cpi/ with the configuration in the repo.

Two further endpoints, xu_server_build and xu_server_session, carry no label at all because they have no server-side implementation anywhere. They are documented at the end so you do not waste a day building against them.

The runtime and CLI sections deliberately carry no availability line. There is no credential involved in any of them.

Runtime And CLI Surface Index

Section What It Covers
xuda(element, options, callback) The single global constructor that boots the runtime into a DOM element.
Constructor options Every key the constructor accepts, with types.
Startup value resolution The six-step precedence chain every startup value passes through.
The xu-* attribute surface All 18 attributes, what each does and what its value must look like.
Attribute families and shorthands xu-on:<event>, xu-exp:<attr> and the 8 shorthand event attributes.
Authored tags and reserved names The 4 authored xu-* tags and the 9 reserved variable names.
Attribute execution phases Which attributes run before the node is built and which run after.
The xu script API The 15-method object injected into every javascript prog.
Workflow actions The 24 actions available inside event handlers and workflows.
Reactive primitives func.reactive.*, an implementation detail of the platform bundle.
Render profiles Computing mode, render mode and client activation, and how they normalize.
Slim mode differences Exactly what changes when you run the Slim bundle.
xuda-cli dev The local dev server command.
xuda-cli sync The cloud sync command.
xuda-cli clean-readmes The scaffolded readme cleanup command.
xuda.config.js fields Every configuration key and its default.
Source folder mapping Which folder compiles to which unit type.
Local endpoints served by xuda-cli dev The five /rpi/* routes the dev server answers itself.

Platform Method Index

Method What It Does
dbs_read Reads records from an app table with filtering, sorting and row ranges.
dbs_create Creates one record in an app table from key-value table data.
dbs_update Replaces the data of one existing record, identified by row id.
dbs_delete Soft-deletes or permanently deletes listed record ids, and broadcasts the change.
get_app_system_api_methods Lists the app-level system API methods available for one app.
get_app_api_keys Lists an application's API keys by status.
create_app_session Creates an application session and mints the app token.
get_plugin_setup Reads plugin setup for a named plugin on an app.
create_app_api_key Creates an application-scoped API key.
update_app_api_key Updates an application API key's name, status, methods and domains.
create_account_api_key Creates an account-scoped API key.
get_account_api_keys Lists the account's API keys by status.
get_account_system_api_methods Lists the account-level system API methods, the data behind the allow list UI.
get_project_docs Reads an app's project documents of one menu type.
update_app_info_doc_to_db_couch Writes or refreshes the app info document inside the app's own database.
api_module.validate_api_key The API-key gatekeeper that decides whether a key may call a method.
session_module.create_gtp_session Creates the pending platform session the CLI opens before it syncs.

xuda(element, options, callback)

Xuda runtime constructor

The single entry point of the framework. It boots the runtime into a DOM element. The global on the page is window.xuda; the Slim ES package also exposes it as xuda.xuda and as the module default.

Arguments are matched by type, not by position, so any of them may be omitted and any of them may be passed in any order. An HTML element becomes the mount target, a plain object becomes the options, a function becomes the ready callback. That is why new xuda(document.body, { prog_id: 'counter' }) and new xuda({ prog_id: 'counter' }, document.body) are equivalent.

If element is omitted the runtime errors out in the full bundle and silently falls back to body with a warning in the Slim bundle. callback, when supplied, is invoked as callback("xuda_ready", SESSION_ID, SESSION_OBJ). The call returns an object with a single method, on_mounted(fn), which registers fn against the on_mounted event dispatched on document.body.

Parameters

Name Type Required Description
element HTMLElement or CSS selector string No in Slim, Yes in the full bundle Mount target. Slim falls back to body and logs a warning.
options object No Runtime and session options, see the next section.
callback function No Called with ("xuda_ready", SESSION_ID, SESSION_OBJ) when the app is ready.

Notes

  • The returned on_mounted(fn) helper is the supported way to know the app finished booting. Listening for the on_mounted event on document.body once does the same job.
  • No credential is required in Slim isolated mode, meaning when you supply project_data inline or author your UI in a <template>.

Constructor options

Every key below is accepted on the options object. Defaults: domain is the current host, engine_mode is miniapp, app_id is unknown.

Parameters

Name Type Required Description
prog_id string Yes in practice Id of the program to render first. Must exist in project_data.programs or match a <template id="...">. In Slim template mode it defaults to the first template's id.
project_data object No Inline project definition with globals, tables and programs. Slim's main non-template input mode.
domain string No Host used to resolve runtime assets and platform calls. Defaults to the current host. localhost and 127.0.0.1 are rewritten to <subdomain>.xuda.ai or xuda.ai.
app_id string No Platform app id. Defaults to unknown. Required for the full remote project loader path, optional in Slim when you supply project_data.
engine_mode string No Defaults to miniapp. live_preview is used by the Studio preview.
gtp_token string No Platform session token.
app_token string No App session token.
route_id string No Route-driven startup.
menu_id string No Route menu entry to open.
params object No Supplemental session values by key, consulted third in the resolution chain.
url_params object No Extra program input values merged into the session's url_params.
debug_js boolean No Enables debug behavior and switches glb.worker_type to Dev or Debug.
crawler boolean or string No Crawler mode flag, copied onto the session.
local_live_preview any No Local live-preview flag.
app_computing_mode main | worker | server No Where program logic executes. Normalized at boot.
app_render_mode csr | ssr_first_page | ssr_full No Render strategy. Forced to csr when computing mode is main or worker.
app_client_activation none | takeover | hydrate No What the client does with server markup. Derived from render mode.
ssr_payload object or JSON string No Server render payload. Also read from window.__XUDA_SSR__ when absent.
app_build_id number No Build number, used for asset cache busting.
app_version string No Printed in the runtime banner.

Startup value resolution

Startup values are not read only from options. Eleven of them resolve through a fixed six-step precedence chain, in this order:

  1. URL query parameter
  2. Root element attribute
  3. options.params[key]
  4. options[key]
  5. Cookie
  6. localStorage

The keys resolved this way are gtp_token, app_token, prog_id, domain, engine_mode, crawler, app_id, route_id, menu_id, local_live_preview and project_data.

Notes

  • A URL query parameter beats everything, which is why a Slim page can be reconfigured from a query string with no code change.
  • options.params[key] is consulted before options[key]. If you set the same key in both places, params wins.

The xu-* attribute surface

The framework's whole vocabulary is 18 attributes plus two suffixed families. There are no others. Each one below has a live handler in the runtime.

Parameters

Name Type Required Description
xu-bind string No Two-way binding between an input element and a field. Value is the bare field_id, with no @ prefix.
xu-render expression string No Conditional render. The element is removed from the DOM when falsy. Empty value defaults to true.
xu-show expression string No Conditional visibility via CSS display. The element stays in the DOM. Empty value defaults to true.
xu-for expression string No Repeats the element per item of an array or object. Current item is @_FOR_VAL, key or index is @_FOR_KEY.
xu-for-key string No Renames the iterator key variable.
xu-for-val string No Renames the iterator value variable.
xu-class JSON5 string or object No Class name keys mapped to condition expressions.
xu-store JSON5 string or object No Parses the object and stores its key/values as dynamic fields in the dataset. The easiest way to seed local state.
xu-text string No Sets inner text, usually driven via xu-exp:xu-text.
xu-html string No Sets raw inner HTML, usually via xu-exp:xu-html.
xu-content string No Sets text content, usually via xu-exp:xu-content. Static text belongs in the node's content property instead.
xu-ref string No Registers the element under SYS_GLOBAL_OBJ_REFS.<name> so expressions and scripts can target it.
xu-style string No Scoped CSS whose selectors are auto-prefixed with the node's [xu-ui-id]. Must contain no quote characters.
xu-style-global string No Same as xu-style but injected globally, without scoping. Same no-quotes rule.
xu-script string No A bare function (el) { ... } expression, evaluated and called with the DOM element when the node first becomes visible. Must contain no quote characters.
xu-cdn string No Loads an external CSS or JS resource by URL before the node renders.
xu-ui-plugin string No Attaches and configures an installed UI plugin on the element.
xu-viewport string No Viewport-conditional rendering logic.

Notes

  • xu-style, xu-style-global and xu-script all reject quote characters in their value. Write them quote-free.
  • xu-store and xu-class are parsed as JSON5, not strict JSON, so single-quoted keys and trailing commas are accepted.
  • Two attributes on the marketing landing page do not exist in the runtime: xu-route has no handler, schema entry or reference anywhere, and neither does xu-prog. Routing is done with route progs and their routeMenu, plus the route_id and menu_id session values. The mechanism behind the counter example is <template id="...">.
  • xu-if, xu-else-if and xu-else sibling chains exist in the reactive renderer, but they are not in the validator's attribute registry, so Studio's checker reports them as unknown attributes. They are also absent from Slim and from the CLI's bundled runtime.

Attribute families and shorthands

Two attribute families take a suffix. Their value shape is fixed and it is the thing most people get wrong on day one.

Parameters

Name Type Required Description
xu-on:<event> array No Event listener. The value is always an ARRAY of handler objects [{ handler, props, workflow }]. workflow is an array of action steps.
xu-exp:<attr> expression string No Evaluates the expression and applies the result to <attr>. Works for HTML attributes and for xu-* attributes.

Notes

  • xu-exp:class REPLACES the static class attribute entirely rather than merging with it. If you need both, put the static classes inside the expression.
  • Eight shorthand event attributes are normalized into full xu-on:* update workflows at render time: xu-click, xu-dblclick, xu-contextmenu, xu-focus, xu-keyup, xu-change, xu-blur, xu-init. The shorthand value is wrapped as a one-step update workflow, which is why a value like xu-click="count++" works with no handler JSON at all.
  • There is one xu-attrs handler in the runtime alongside the 18 registered attributes.

Authored tags and reserved names

Four xu-* tags are meant to appear in an authored tree: xu-single-view, xu-multi-view, xu-panel and xu-teleport. xu-widget also has a runtime handler.

Runtime-internal tags (xu-nav, xu-modal-controller, xu-popover-controller*, xu-popover-content*) are not for authored trees and the validator flags them if you write one by hand.

Nine variable names are reserved and must never be used as field ids: _NULL, _THIS, _FOR_KEY, _FOR_VAL, _ROWNO, _ROWID, _ROWDOC, _KEY, _VAL.

Attribute execution phases

Attributes on one element run in three ordered phases, and the order matters when two attributes touch the same node.

Phase Attributes
Before the node is built xu-cdn, xu-style, xu-render, xu-for-key, xu-for-val
After the node is built xu-bind, xu-class, xu-script, xu-ui-plugin, xu-ref

Notes

  • xu-cdn running first is what lets an external stylesheet or library be present before the node renders.
  • xu-ref running last is what makes the element available to later expressions and scripts under SYS_GLOBAL_OBJ_REFS.

The xu script API

The in-app runtime API object

xu is injected as the second argument of every javascript prog. A javascript prog executes as async function (params, xu, SESSION_ID, SESSION_OBJ, jobNoP, $container, func, glb, APP_OBJ, evt). Fifteen methods are available, and all of them are async.

Parameters

Name Type Required Description
xu.get_field_value(field_id) async field_id required Reads a field of the calling context. Returns the value, or false plus a logged error when the field does not exist.
xu.set_field_value(field_id, value, avoid_refresh?) async field_id, value required Writes a field; the datasource updates and bound UI refreshes. The idiomatic way to hand results back to a component.
xu.invoke_event(event_name, options?) async event_name required Triggers a user_defined progEvents entry by name.
xu.dbs_create(table_id, row_obj) async both required Inserts one row into a table prog. Keys are the table field_ids. Returns {code, data}.
xu.dbs_read(table_id, selector?, fields?, sort?, limit?, skip?) async table_id required Queries a table with a Mongo-style selector ({} = all). Returns the rows ARRAY, default limit 999. Rows are { id, value }. Leave fields empty; passing a projection breaks the server read.
xu.dbs_update(table_id, row_id, changes_obj) async all required Updates one row by its id.
xu.dbs_delete(table_id, row_id) async both required Deletes one row by its id.
xu.call_javascript(prog_id, params?, evaluate?) async prog_id required Runs another javascript prog with parameters. Unlike call_native_javascript workflow steps, these parameters DO arrive as passed.
xu.call_project_api(prog_id, params?) async prog_id required Executes an api prog of this project and returns its rendered output, parsed when the api outputs json.
xu.call_system_api(method, payload?) async method required POSTs a platform cpi method. app_id, app_id_query and app_token are added automatically.
xu.call_external_api(method, url, payload?) async method, url required HTTP request to an external host. The url is passed WITHOUT the https:// prefix.
xu.alert(type, display, message, details?) async type, display, message required type: error | warn | info | log. display: console | modal | toast | browser.
xu.log(type, message, details?) async type, message required Reports to the runtime issue log. type: E | W | I.
xu.read_drive(filename) async filename required Fetches a file from the app workspace drive, JSON-parsed.
xu.write_drive(stream, filename, make_public?) async stream, filename required Uploads a file to the app workspace drive.

Notes

  • xu.call_system_api POSTs straight to https://<domain>/cpi/<method>. It inherits the clearance of whatever method it targets, so a private method is still refused if the session behind the call is not entitled to it.
  • xu.dbs_read defaults to a limit of 999 rows. Ask for what you need rather than relying on the default.
  • xu.call_external_api takes the url without the https:// prefix. Passing a full url is the most common mistake with this method.
  • Writes made from a script during a Studio live preview land in the real database, but preview reads come from a local draft store, so a table can look empty immediately after a write. This is a preview quirk, not a data loss.

Workflow actions

Twenty-four actions are available inside xu-on:* handlers, inside progEvents[].workflow and inside a field's workflow array:

update, invoke_action, raise_event, emit_event, call_page, call_modal, call_popover, get_data, set_data, batch, call_native_javascript, call_evaluate_javascript, execute_native_javascript, execute_evaluate_javascript, call_project_api, call_system_api, call_external_api, alert, call_alert, call_library, loader_on, loader_off, delay, comment.

Notes

  • There are 9 lifecycle event types and 9 invoke_action values.
  • Seven deprecated imperative DOM actions are hard-rejected by the validator. If you are porting older markup, they will not silently degrade, they will fail validation.

Reactive primitives

func.reactive.*, an implementation detail rather than a customer surface

The platform bundle ships a second, signal-based rendering engine alongside the legacy renderer. It is documented here so you can reason about what your screen is doing, not because you should call it. Treat it as internal.

It is present only in the full platform bundle. It is not in Slim and not in the CLI's bundled runtime, so xuda-cli dev runs the legacy renderer.

Parameters

Name Type Required Description
func.reactive.signal(initialValue, options?) function initialValue required Creates a writable reactive value with .get(), .set() and .subscribe().
func.reactive.computed(fn, options?) function fn required Derived value; recomputes before propagating and only notifies downstream when the value actually changed.
func.reactive.effect(fn, options?) function fn required Auto-tracking effect. Child effects are owned by the parent and disposed with it unless { detached: true }.
func.reactive.batch(fn) function fn required Defers effect execution until the batch closes.
func.reactive.untrack(fn) function fn required Runs fn without registering dependencies.
func.reactive.scheduler.queueJob(job, priority?) function job required Priorities: SYNC 0 (drained at the end of the notification wave), NORMAL 1 (microtask), LOW 2 (deferred).
func.reactive.listdiff.diff(oldKeys, newKeys) function both required Keyed list diff used for xu-for reconciliation.

Notes

  • The engine is ON by default for every screen and every visitor. It performs a post-render takeover after the legacy render, so a screen renders twice on open by design. The source calls that an accepted pilot cost.
  • There is a per-browser kill switch and no server-side one: set localStorage.XUDA_ENGINE_SCREENS = 'off', or call window.__XUDA_PILOT.revert().
  • A job that re-runs more than 100 times inside one notification wave is treated as circular and dropped.

Render profiles

Three settings decide where logic runs and how the page is delivered. They are normalized from one function, server side and client side, so an invalid combination cannot survive boot.

Name Type Required Description
app_computing_mode main | worker | server No Where program logic executes.
app_render_mode csr | ssr_first_page | ssr_full No Render strategy.
app_client_activation none | takeover | hydrate No What the client does with server-rendered markup.

Notes

  • main and worker force app_render_mode to csr and app_client_activation to none.
  • Anything else becomes server, with takeover for first-page SSR and hydrate for full SSR.
  • In the CLI you do not set these three by hand. You set ssr in xuda.config.js and the CLI derives them.

Slim mode differences

Slim is the same runtime with a smaller build and three concrete behavior changes.

  • The mount element becomes optional. Slim falls back to document.body and logs a warning instead of failing.
  • Every <template> on the page becomes a program. The HTML parser turns each one into progUi and registers it under _session.project_data.programs, keyed on the template id, or template_<index> when it has none. The first template becomes the default prog_id.
  • Boot short-circuits into the embed loader instead of running the full remote project loader.

Notes

  • Slim carries no reactive engine. The reactive files are excluded from the Slim build, so signal-based updates, keyed list diffing and xu-if / xu-else-if / xu-else are platform-bundle only.
  • Slim also drops xuda_actions.js and the Firebase web push module.
  • Slim ships 51 runtime files plus 2 vendored libraries, the CSS parser and JSON5. The full platform bundle ships 53 runtime files plus 8 vendored libraries plus the 7 reactive engine files.
  • The same HTML parser module is used by the browser runtime in Slim template mode, by the CLI compiler and by the Studio designer canvas. That is why a Slim page, a CLI component and a Studio-authored component all produce the same document.
  • The ES module package for Slim is @xuda.io/xuda-runtime-slim-es.

xuda-cli dev

Xuda CLI dev server

Loads the project from the current working directory, compiles every .xu and .json5 source into runtime docs in node_modules/.project_data/, serves the app over Express, opens a socket.io reload channel at /ws/socket.io, and watches the project directory with chokidar, excluding node_modules, .git and the project data directories.

Parameters

This command takes no arguments beyond -h and --help. All configuration comes from xuda.config.js.

Notes

  • Any extra token is a hard error: Unexpected arguments for "dev". The CLI has no flags at all.
  • On start it prints the listening URL, xuda-cli listening on http://localhost:3000 (index.html) by default.
  • On save the watcher recompiles the project, regenerates node_modules/.project_data/, and emits xu:reload over the socket so the browser reloads itself.
  • In local isolated mode the dev server answers five /rpi/* routes itself, so an app runs with no cloud connection at all. See Local endpoints served by xuda-cli dev.
  • Stale generated files are deleted on every compile, so node_modules/.project_data/ always matches your sources.
  • Component <style> blocks are collected into one stylesheet served at /__xu/components.css. A component <script> block is compiled to a client mount module served at /__xu/components/<id>.js, whose default export receives a context object and may return a disposer.
  • Everything under /cpi/*, /db/*, /plugins/*, /dist/plugins/* and any other /rpi/* path is proxied upstream with the api key and session tokens attached. With no api_key configured, those paths answer { code: -404, data: 'Connected upstream mode is disabled' }.
  • The CLI's own npm dependency list is three packages: express, socket.io and chokidar.

xuda-cli sync

Xuda CLI cloud sync

Connects a local CLI project to its cloud project. It opens a session, verifies access, downloads cloud docs for 11 menu types into node_modules/.project_data/, writes any missing .xu and .json5 source files, recompiles, and uploads changed docs. The 11 menu types are globals, component, get_data, set_data, batch, api, javascript, alert, table, route and ai_agent.

The upload is a direct CouchDB _bulk_docs write to <upstream>/db/<app_id>_db/_bulk_docs, followed by one call to update_app_info_doc_to_db_couch.

Parameters

This command takes no arguments. It reads api_key from xuda.config.js.

Notes

  • Idempotency: sync never overwrites an existing local source file. Files that already exist are skipped and counted separately. Only missing sources are written.
  • On success it prints five lines: the app id, the pulled-docs directory, the generated-docs directory, the count of created versus skipped source files, and the count of uploaded documents.
  • Known limitation, stated honestly. Sync's own precondition check requires all four of get_app_system_api_methods, get_app_api_keys, get_project_docs and update_app_info_doc_to_db_couch to appear in the get_app_system_api_methods response and in the key's allowed-method list. The first two are private, and a private method never appears in that response, so they cannot satisfy their own check. The last two are not in the platform method catalog in the repo at all. Verify against your own environment before you plan around this flow.
  • Connected mode needs the platform's CPI modules on disk. The session is created by importing cpi/api_module/index.mjs and cpi/session_module/index.mjs from the package root or the workspace root. A published xuda-cli install outside the Xuda monorepo fails with Unable to load local CPI modules for api_key mode. Anything requiring api_key, meaning upstream proxying and sync, is monorepo-only as shipped.

xuda-cli clean-readmes

Xuda CLI readme cleanup

Deletes the folder guide README files that create-xuda-cli generated when it scaffolded the project. Custom READMEs are left untouched.

Parameters

This command takes no arguments.

Notes

  • It reports removed, skipped and missing counts, so you can see exactly which files it left alone.
  • The scaffolded package.json exposes it as npm run clean:readmes.

xuda.config.js fields

Project configuration

The only configuration file a CLI project has. Every value the CLI needs comes from here, because no command takes flags.

Parameters

Name Type Required Description
entry string No The app entry. An .html filename serves that file as the shell; anything else is treated as a program id. Defaults to app.
port number No Local dev port. Must be an integer 1 to 65535. Defaults to 3000.
ssr none | first_page | full No Render mode. Defaults to none. Any other value throws at load.
api_key string No Developer API key. Required for sync. Also accepted as apiKey.
build_id string No Remote build target. If set, api_key is mandatory, otherwise the CLI throws build_id requires api_key. Also accepted as buildId.

Notes

  • An invalid ssr value throws Invalid SSR mode at load. There is no fallback.
  • With ssr set to first_page or full, the CLI renders the entry program to a string in a sandboxed VM context, injects the markup into the shell, and hands the client an ssr_payload. The client then takes over on first_page or hydrates on full.
  • One environment variable is read: XUDA_UPSTREAM_ORIGIN overrides the upstream origin, which defaults to https://xuda.ai.
  • Do not set build_id today. The remote build path targets /cpi/xu_server_build and /cpi/xu_server_session, and neither has a server-side implementation. See the last section.
  • A component that references a uiFramework not present in your package.json dependencies is a hard error at load. Any @xuda.io/* dependency is auto-registered as a purchased plugin.

Source folder mapping

The CLI maps source folders to unit types deterministically. There is no configuration for this and no ambiguity.

Source path Compiles to
App.xu component, always with program id app
components/**/*.xu component
globals/** globals
data/get/** get_data
data/set/** set_data
data/batch/** batch
apis/** api
scripts/** javascript
alerts/** alert
tables/**.table.json5 table
routes/**.route.json5 route
ai-agents/**.agent.json5 ai_agent

Notes

  • A .xu file is a block file, not a JS module. Component blocks are <meta>, <params>, <fields>, <actions>, <events>, <datasource>, <template>, <script>, <style> and <mount>. Object blocks are parsed as JSON5-style literals in a sandboxed VM context with a 250 ms timeout.
  • The template compiler rewrites friendly aliases into runtime markup: <single-view>, <multi-view> and <panel> become xu-single-view, xu-multi-view and xu-panel; bind= becomes xu-bind; if= becomes xu-exp:xu-render; for= becomes xu-for plus xu-exp:xu-for; :attr= becomes xu-exp:attr; @event= becomes xu-on:event, with .stop and .prevent mapping to stopPropagation and preventDefault.
  • Generated runtime docs live in node_modules/.project_data/. That is the canonical location. project_data/ and a root .project_data/ are legacy input paths, still read during migration, resolved in the order hidden, preferred, legacy.
  • create-xuda-cli scaffolds all eleven folders plus App.xu, index.html, xuda.config.js and a first globals.json, and writes a README guide into each folder.

Local endpoints served by xuda-cli dev

These are not platform methods and they are not on the internet. They are HTTP routes the dev server answers itself so an app can run with no cloud connection.

Route What it returns
POST /rpi/get_app_build The local buildInfo object: build, master_build, src_app_id, server_ts, last_changed_ts, app_db_name, progs_changed, tables_changed.
POST /rpi/get_rt_info The runtime info document, including rpi_http_methods.
POST /rpi/get_doc_obj_from_build One prog document by doc_id, or the globals doc for system and global_<app_id>.
POST /rpi/get_plugin_setup Default setup values extracted from the installed plugin's tabs() export.
POST /rpi/write_log A no-op acknowledgement, { saved: false, source: 'xuda_cli_local_noop' }.

Notes

  • In local isolated mode get_rt_info advertises get_doc_obj_from_build, get_plugin_setup, write_log, dbs_read, dbs_create, dbs_update and dbs_delete as locally handled. In connected mode it advertises only the first three, and the data methods go upstream.
  • Every other path is proxied upstream, or refused with Connected upstream mode is disabled when no api_key is set.

dbs_read

DBS Read

Reads records from an app table, with optional row range, single-row lookup, sorting, filtering and archived-record selection. This is the HTTP form of what xu.dbs_read does from inside an app, so it is the method you call when your own backend needs to read app data. Microservice data_module.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes Unique identifier of the application this request targets.
table_id string Yes The specific table to query, as listed in the Xuda Studio database repository.
from number No Starting row number, 0-based, from which to begin reading.
to number No Ending row number, 0-based, inclusive.
row_id string No Unique identifier of a single row. When supplied, only that row is returned.
sortModel array of {colId, sort} No Sorting rules. colId is the field name, sort is asc or desc.
query object No Field-based filters. Each key is a column id whose value defines filterType, type (operator such as blank, notBlank, equals, contains, notContains, startsWith, endsWith) and filter (the value).
archived boolean No Return only archived records. False or absent returns active records.

Notes

  • Clearance: user_access. Not private, so a full-access key reaches it and a custom key reaches it once dbs_read is on its allowed-method list.
  • No min_plan. There is no plan gate on this method.
  • The in-app equivalent, xu.dbs_read, takes a Mongo-style selector rather than the query object above, and returns rows as { id, value } with a default limit of 999.

dbs_create

DBS Create

Creates a new record in the specified app table from the provided key-value table data. Microservice data_module.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes Unique identifier of the application this request targets.
table_id string Yes The table to write to, as listed in the Studio database repository.
table_data object Yes Key-value pairs, for example {'user_name': 'John', 'last_name': 'Smith'}.

Notes

  • Clearance: admin. Not private. No min_plan.
  • The keys of table_data are the table's field_id values.

dbs_update

DBS Update

Replaces the data of an existing record, identified by row_id, in the specified app table. Microservice data_module.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes Unique identifier of the application this request targets.
table_id string Yes The table that holds the record.
row_id string Yes The row id uniquely identifying the document to update.
table_data object Yes Key-value pairs that will replace the current data in the document.

Notes

  • Clearance: admin. Not private. No min_plan.
  • This replaces the document's data rather than merging into it. Send the full record.

dbs_delete

DBS Delete

Soft-deletes, or permanently deletes when permanent is set, the listed record ids from an app table. Microservice data_module.

Availability: API key

Parameters

Name Type Required Description
app_id string Yes Unique identifier of the application this request targets.
table_id string Yes The table that holds the records.
ids array of string Yes Document ids marked for deletion.
permanent boolean No Irreversible deletion. Restoration is not possible.

Notes

  • Clearance: admin. Not private. No min_plan.
  • This method broadcasts the change to connected clients, which is what drives the realtime datasource refresh. A datasource declared with realtime: true picks up the change without a page reload.
  • permanent: true is irreversible. There is no restore path.

get_app_system_api_methods

Get App System Api Methods

Returns the application-level system API methods available for the specified app. The implementation filters the platform method catalog down to the entries that are not private and whose clearance is admin, studio or user_group, returning {description, fields, category} per method. xuda-cli sync calls it first as its capability probe. Microservice api_module.

Availability: Dashboard session

Parameters

Name Type Required Description
app_id string Yes Unique identifier of the application this request targets.

Notes

  • Clearance: admin. Private, so an API key cannot call it. No min_plan.
  • Because the response excludes private methods and this method is itself private, it can never list itself. The same is true of get_app_api_keys. That is the root of the sync precondition problem described under xuda-cli sync.

get_app_api_keys

Get App Api Keys

Retrieves the application's API keys from the xuda_api_keys database, filtered by status and sorted by creation date. sync uses it to find the key document matching the configured api_key and to read its api_allow_methods. Microservice api_module.

Availability: Dashboard session

Parameters

Name Type Required Description
app_id string Yes Unique identifier of the application whose API keys are listed.

Notes

  • Clearance: admin. Private. No min_plan.
  • The CLI also sends stat: 3 in the body to select active keys. stat is not declared in the method's field list, so treat it as undocumented rather than guaranteed.

create_app_session

Create App Session

Creates an application session for the specified app. It validates the gtp_token against xuda_sessions, loads the app from xuda_master, fingerprints the request headers, and writes a session_log document plus, for source: 'app', a visit_log document. Microservice session_module.

Availability: Dashboard session

Parameters

Name Type Required Description
app_id string Yes Unique identifier of the application the session token should be associated with.

Notes

  • Clearance: user. Private. No min_plan.
  • The CLI calls this in-process rather than over HTTP, to mint the app_token its dev server proxy uses.
  • The in-process call also passes gtp_token, headers and source, which are not declared in the registered field list.

get_plugin_setup

Get Plugin Setup

Retrieves plugin setup for a named plugin on an app. Microservice plugins_module.

Availability: Dashboard session

Parameters

Name Type Required Description
app_id string Yes Unique identifier of the application this request targets.
plugin_name string Yes Name of the plugin to process.

Notes

  • Clearance: admin. Private. No min_plan.
  • xuda-cli dev serves an equivalent /rpi/get_plugin_setup locally by importing the plugin's own index.mjs and extracting default field values from its tabs() export, which is why plugins work offline in local isolated mode.

create_app_api_key

Create App Api Key

Creates an application-scoped API key document in xuda_api_keys and broadcasts the change. This is the method behind the Create button on a project's API Keys tab, and it is how you obtain the api_key that xuda-cli sync needs. Microservice api_module.

Availability: Dashboard session

Parameters

Name Type Required Description
app_id string Yes Unique identifier of the application that owns this API key.

Notes

  • Clearance: admin. Private. No min_plan.
  • The creation handler also persists api_key_name, scope, api_access (full or custom), api_allow_methods and api_allow_domains. Those are read from the request body but are not declared as fields in the catalog entry.
  • The key document id is the key itself, prefixed api_pk.

update_app_api_key

Update App Api Key

Updates an existing application API key's name, status, allowed methods and allowed domains in xuda_api_keys, and broadcasts the change. Microservice api_module.

Availability: Dashboard session

Parameters

Name Type Required Description
api_key string Yes Identifier of the API key document to update.

Notes

  • Clearance: admin. Private. No min_plan.
  • stat must be 1 draft, 2 suspended, 3 active or 4 delete.

create_account_api_key

Create Account Api Key

Creates an account-scoped API key document in xuda_api_keys and broadcasts the change. This is the Developers, API Keys equivalent of create_app_api_key. Microservice api_module.

Availability: Dashboard session

Parameters

Name Type Required Description
uid string Yes Unique identifier of the account that owns this API key.

Notes

  • Clearance: user. Private. No min_plan.
  • An account key is scoped to the account rather than to one app, so it is the right key for tooling that touches more than one project.

get_account_api_keys

Get Account Api Keys

Retrieves the account's API keys from xuda_api_keys, filtered by status and sorted by creation date. Microservice api_module.

Availability: Dashboard session

Parameters

Name Type Required Description
uid string Yes Unique identifier of the account whose API keys are listed.

Notes

  • Clearance: user. Private. No min_plan.

get_account_system_api_methods

Get Account System Api Methods

Retrieves the account-level system API methods available to the caller. Unlike the app variant it returns every non-private method regardless of clearance. It is the data source for the per-method Allow and Deny list in the API Keys screen. Microservice api_module.

Availability: Dashboard session

Parameters

This method takes no parameters.

Notes

  • Clearance: user. Private. No min_plan.
  • The response is cached.
  • Private methods are excluded from the output, which is why they never appear as options when you build a Custom access allow list.

get_project_docs

Get Project Docs

Resolves the project app id, then reads the app's CouchDB view studio_docs_by_type keyed on the menu type with include_docs: true, returning { code: 870, data: body }. xuda-cli sync calls it once per menu type, 11 times per sync run. It is also called internally by the marketplace module. Microservice app_module.

Availability: Operator only

Parameters

Name Type Required Description
app_id string Yes Application whose project docs are listed.
menu_type string Yes One of the 12 menuType values; the CLI iterates 11 of them, all but folder.

Notes

  • It has no display name, no clearance and no privacy flag, because it is not registered in the platform method catalog. A call to /cpi/get_project_docs answers method "get_project_docs" not exist.
  • The 12 menuType values are globals, table, get_data, set_data, batch, alert, javascript, folder, route, api, component and ai_agent.
  • The repo's configuration is known to diverge from the live platform configuration, so re-verify against your own environment before you treat this as permanent.

update_app_info_doc_to_db_couch

Update App Info Doc To Db Couch

Loads the app object, then writes or updates the app info document inside the app's own CouchDB database. sync calls it exactly once, after a successful upload, to refresh that document. Microservice app_module.

Availability: Operator only

Parameters

Name Type Required Description
app_id string Yes Application whose info doc is refreshed.

Notes

  • Like get_project_docs, it has no catalog entry, so it is not reachable over /cpi/ with the configuration in the repo.

api_module.validate_api_key

The API-key gatekeeper

Given an api key, a method name, request headers and an app id, it loads the key document and enforces access. For a full key it refuses any method whose catalog entry is private. For a custom key it refuses any non-public method absent from api_allow_methods. It returns { code: 200, data: api_doc, app_id } on success, or { code: -401, data: <reason> } on refusal, and writes an api_log entry on failure. Microservice api_module.

Availability: Operator only

Parameters

This function has no catalog entry and therefore no declared parameter contract. It is called in process.

Notes

  • This is the function that makes private: true a hard wall. Understanding it is the fastest way to understand why an API key gets a refusal.
  • The CLI reaches it by importing cpi/api_module/index.mjs from disk, which is why connected mode only works inside the Xuda monorepo.

session_module.create_gtp_session

Create GTP session

Creates a gtp_session document in xuda_sessions with stat: 1 (pending), the caller's headers, the uid, a geo lookup from cf-connecting-ip, and a source tag. The CLI passes source: 'xuda_cli'. Microservice session_module.

Availability: Operator only

Parameters

This function has no catalog entry and therefore no declared parameter contract. It is called in process.

Notes

  • Session status values are 1 pending, 2 active, 3 close and 4 deleted.
  • A gtp_session created here is what create_app_session validates before it mints an app token.

Endpoints the CLI calls that have no server implementation

Two endpoints deserve their own section because they carry no availability label at all. They are not private, not operator only and not gated. They do not exist. There is no implementation anywhere in the platform code and no catalog entry, so setting build_id in xuda.config.js will fail.

Endpoint What the CLI sends What it expects back
POST /cpi/xu_server_build { build_id } with Authorization: Bearer <api_key> { app_meta, project_data, code_files }
POST /cpi/xu_server_session { build_id, app_id } with a bearer api key A remote session

build_id is a string and is optional on both. app_id is a string and is optional on the session call. Neither field is worth memorizing until the endpoints exist.

API key access modes

A developer API key has one of two access modes, and neither costs anything.

Mode What it allows
full Every non-private method the account can call, evaluated at call time, so methods added later are included automatically.
custom Only the methods on the key's explicit api_allow_methods list.

Private methods are excluded from both modes. A full key does not mean every method, it means every method that is not private.

Keys are created and managed in two places: the account-wide screen at /dashboard/developers/keys, and a project's own API Keys tab, which is the same screen scoped to one app. Both let you name the key, restrict Allowed Domains, choose Full access or Custom access, pick per-method permissions, and reveal and copy the key.

Errors

Platform method errors.

Code or message Meaning
method "<x>" not exist The method name is not in the platform method catalog. The /cpi/ router refuses before any module runs.
-401 from validate_api_key The key is invalid, or the key is not permitted to call that method. A failure also writes an api_log entry.
-404 with Connected upstream mode is disabled The dev server tried to proxy a request upstream with no api_key configured.
870 from get_project_docs Success. This method answers with code 870 rather than 200.

CLI errors, thrown at load or at parse time.

Message Cause
Unexpected arguments for "dev" You passed an argument to a command. No xuda-cli command takes flags.
Invalid SSR mode ssr in xuda.config.js is something other than none, first_page or full.
build_id requires api_key build_id is set without api_key.
Unable to load local CPI modules for api_key mode Connected mode was requested from a published xuda-cli install that has no platform CPI modules on disk.

Runtime error behavior.

  • xu.get_field_value returns false and logs an error when the field does not exist rather than throwing. Check the return value.
  • A component that names a uiFramework which is not a dependency in package.json is a hard error, not a warning.
  • xu.alert types are error, warn, info and log; displays are console, modal, toast and browser. xu.log types are E, W and I.
  • If a Slim page renders nothing, the four things to check are that the bundle loaded, that prog_id matches a real template id or program key, that project_data.programs[prog_id] exists, and that the mount element is real.

Rate limits

No rate limit is defined anywhere for the framework, the CLI or the four app data methods. There is no per-unit fee, no quota and no free-tier usage limit on framework usage.

Two internal limits are worth knowing because they change behavior rather than refuse a call.

Limit Value
Default row limit on xu.dbs_read 999 rows
Circular-update cutoff in the reactive scheduler 100 re-runs of one job inside a single notification wave, after which the job is dropped

Idempotency rules

  • xuda-cli sync is non-destructive on the way down. Existing local source files are skipped and never overwritten. Only missing sources are written, and created versus skipped counts are printed at the end.
  • Compiling is idempotent. Stale files in node_modules/.project_data/ are deleted on every compile, so the generated folder always matches your sources exactly, with no leftovers from a renamed program.
  • App.xu always compiles to program id app. Renaming the file is not how you change that.
  • dbs_update replaces rather than merges. Repeating the same update is safe, but sending a partial record is not the same as patching it.
  • dbs_delete with permanent: true is not repeatable in any meaningful sense. The record is gone and cannot be restored.
  • The upload leg of sync writes through CouchDB _bulk_docs, so document revisions are what decide the outcome of a concurrent write, not a sync-level lock. Do not run two syncs against one project at once.

Plans and gates

No framework method carries a plan gate. None of dbs_read, dbs_create, dbs_update, dbs_delete, get_app_system_api_methods, get_app_api_keys, create_app_session or get_plugin_setup has a min_plan value. There is no framework plan ladder, no framework price and no credit cost. Across the whole platform method catalog only 30 methods carry a min_plan at all, and none of them is a framework method.

What the account membership plan actually decides is deployment. The ladder is free, pro, team, agency and three enterprise tiers, and it governs project count, team members, drive storage, AI credits and marketplace access. The deploy feature is not available on free and is available from pro upward. Studio is included on free.

So the honest summary is: building with Slim or the CLI on your own machine costs nothing and needs no plan, because nothing in the local path calls a plan-gated method. Shipping the result to the Xuda platform is what the membership plan buys.

One plan feature flag named xuda sdk exists and is available only on the highest enterprise tier. Whether it refers to this framework, to the worker bundle packages, or to something else is not stated anywhere, so do not treat it as a framework gate.

The npm packages are free and public: xuda-cli, create-xuda-cli, @xuda.io/xuda-runtime-slim-es, @xuda.io/xuda-worker-bundle and @xuda.io/xuda-worker-bundle-min. The first three are pre-1.0.

Webhooks and scheduled jobs

This product publishes no webhooks. There are none owned by the framework, the runtime or the CLI.

There are no crons and no queue workers owned by this product either.

The only push mechanism in the framework is realtime document change events. dbs_delete broadcasts, and a datasource declared with realtime: true refreshes itself when its underlying table changes, without a page reload. The realtime path identifies the changed table by parsing the table id out of the changed row's document id. In the CLI, the same socket channel carries the xu:reload live-reload event on /ws/socket.io.

Known gaps

Everything in this section is a real limitation, stated so you do not spend a day discovering it.

  • xuda-cli sync cannot pass its own precondition check as shipped. It requires four methods to be visible in the app method catalog and on the key's allowed list. Two of them are private and can never appear in that catalog, and the other two are not registered as platform methods at all. Verify against your own environment before planning around this flow.
  • Connected mode is monorepo-only as shipped. The CLI creates its session by importing the platform's CPI modules from disk, and the published package does not include them. Anything requiring api_key, meaning upstream proxying and sync, fails outside the Xuda monorepo with Unable to load local CPI modules for api_key mode.
  • The build_id remote build path targets endpoints that do not exist. Leave build_id unset.
  • Slim carries no reactive engine. Signal-based updates, keyed list diffing and xu-if / xu-else-if / xu-else are platform-bundle features. The CLI's bundled runtime also has no reactive files, so xuda-cli dev runs the legacy renderer.
  • xu-if, xu-else-if and xu-else are not in the validator's attribute registry, so Studio's checker reports them as unknown attributes even where they work.
  • xu-route and xu-prog do not exist. Both appear on the framework's marketing page. Neither has any implementation in the runtime. Use route progs with a routeMenu and the route_id and menu_id session values for routing, and <template id="..."> for Slim programs.
  • The reactive engine renders a screen twice on open by design, because it takes over after the legacy render. That is deliberate and documented in the source as an accepted cost, not a bug you can configure away. The only switch is the per-browser kill switch.
  • Live preview reads and writes disagree briefly. A write from a script lands in the real database, but the preview reads from a local draft store, so the table can look empty right after the write.
  • Older Slim documentation points at a development host for the runtime bundle and at absolute paths on a developer machine. Use the published @xuda.io/xuda-runtime-slim-es package or your own deployment's runtime URL rather than copying those links.