---
title: Extensions
project: Tables
version: 7.0
section: development
language: en
license: Total.js Enterprise
url: https://totaljs.es/docs/tables/7-0/development/extensions/
updated: 2026-11-20T06:39:52.622Z
---

# Extensions

> Add your own server code and buttons to Tables with extension files.

An extension is an HTML file that adds your own code to Tables: server code, for example an action that an [action button](../../guides/actions/) calls, and browser code, for example a button in the record window.

## Where extensions live

1. Create a folder named `extensions` in the folder of the app.
2. Put your extension files in it, for example `extensions/orders.html`.
3. Restart Tables. It loads every `.html` file of the folder at the start.

Files whose name contains `-bk` or `_bk` are skipped, so you can keep a disabled copy next to the active one.

## The parts of an extension file

An extension has up to two parts:

- `<script total>`: server code. It runs once in Tables at the start, with the full Total.js 5 API, for example `NEWACTION()` and `ON()`.
- `<script>`: browser code. Tables adds it to the page of every user.

```html
<script total>
	// Server: an action that the browser part calls
	NEWACTION('Orders|hello', {
		route: '+API ?',
		action: function($, model) {
			$.callback('Hello ' + (model.name || ''));
		}
	});
</script>

<script>
	// Browser: a button in the detail of every record
	ON('detail', function(meta) {
		meta.columns.push({ type: 'custom', html: '<button class="exec" data-exec="?/sayhello">Say hello</button>' });
		meta.plugin.sayhello = function() {
			let payload = meta.plugin.collect();
			meta.plugin.tapi('Orders|hello', payload, function(response) {
				alert(response);
			});
		};
	});
</script>
```

The button appears at the end of the fields of each record. Clicking it sends the values of the record to the server action, which answers with a text:

![A record with the Say hello button added by an extension](/files/JasskG1uv61f.webp)

## React to saved records

Server code can listen to the operations of Tables. Put `@` before the name of the operation:

```html
<script total>
	ON('@Data|save', function($) {
		let model = $.payload;
		if (model.tableid === 't118h7') {
			// an order was saved
		}
	});
</script>
```

## Call your action from an action button

A server action of an extension can be the **Endpoint** of an [action](../../guides/actions/): enter its name, for example `Orders|approve`, instead of an address. The action receives the data described in [Hook and action data](../../reference/hook-and-action-data/), and the text it returns is shown to the user.

```html
<script total>
	NEWACTION('Orders|approve', {
		action: function($, model) {
			// model.id, model.data, model.user ...
			$.callback('Order approved');
		}
	});
</script>
```

All the events and helpers are in [Extension reference](../extension-reference/).
