---
title: App reference
project: UI Builder
version: 1.0
section: development
language: en
license: MIT
url: https://totaljs.es/docs/uibuilder/1-0/development/app-api/
updated: 2026-11-20T06:51:57.969Z
---

# App reference

> The app object of a design and the UIBuilder object of the page, as components and host apps use them.

Every design on a page is an app. A component reaches it as `instance.app`. The page that UI Builder publishes keeps it as `window.app`, so you can try these calls in the console of the browser.

The page also has one `UIBuilder` object for all designs.

## API

### app.input(id, data, [callback])

Type: `method`

Sends data to an input of the design.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `id` | `String` | yes |  | The id of the input, for example `cid6wh0tx52_set`. |
| `data` | `Object` | yes |  | The data. |
| `callback` | `Function` | no |  | Receives an error text when the instance or the input does not exist. |

Example: Set a Stepper to 2
```js
app.input('cid6wh0tx52_set', 2, function(err) {
	err && console.log(err);
});
```

### app.on(name, fn)

Type: `method`

Registers a handler of an event of the design.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `name` | `String` | yes |  | The name of the event. |
| `fn` | `Function` | yes |  | The handler. |

The events are `output`, `change`, `ready` and `io`.

### app.on('output', function(meta) {})

Type: `event`

An instance has sent an output.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `meta` | `Object` | yes |  | The output. |

`meta.id` is the id of the output in the design, `meta.ref` its id in the component, `meta.data` the data, `meta.err` an error or `null`, and `meta.instance`, `meta.component` and `meta.app` the objects.

Example: Log every output
```js
app.on('output', function(meta) {
	console.log(meta.id, meta.data);
});
```

### app.on('change', function(instance) {})

Type: `event`

The state of an instance has changed.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `instance` | `Object` | yes |  | The instance. |

Emitted 50 ms after the last change of each instance.

### app.on('ready', function() {})

Type: `event`

All instances are built.

### app.find(id)

Type: `method`

Finds an instance.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `id` | `String` | yes |  | The id, `@` and the id, or `.` and a path. |

Returns: `Object` The instance.

### app.instances

Type: `property`

All instances of the design.

### app.args

Type: `property`

The **Dynamic arguments** of the design.

### app.query

Type: `property`

The query arguments of the address of the page.

### app.schema

Type: `property`

The design as it was built.

### app.element

Type: `property`

The element of the design, a jQuery object.

### UIBuilder.editor

Type: `property`

`true` in the editor, not set in a published design.

### UIBuilder.on(name, fn)

Type: `method`

Registers a handler for all designs of the page.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `name` | `String` | yes |  | The name of the event. |
| `fn` | `Function` | yes |  | The handler. |

`output` receives the outputs of every design, with the same `meta` as `app.on('output')`. `app` runs when a design is built.

### UIBuilder.build(target, design, [callback])

Type: `method`

Builds a published design into an element.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `target` | `Element` | yes |  | Where to put the design. |
| `design` | `Object` | yes |  | The published design, as in `_render.json`, or its JSON text. |
| `callback` | `Function` | no |  | Receives the app. |

Returns: `Object` The app.

The published page calls it with the content of the design. The design needs `components` and `children`; a design that is already on the page is removed first.

Example: Build a design
```js
AJAX('GET /designs/demo_render.json', function(design) {
	UIBuilder.build('#design', design, function(app) {
		app.on('output', console.log);
	});
});
```
