---
title: Add a plugin
project: Pluginable
version: 0.0.1
section: recipes
language: en
license: MIT
url: https://totaljs.es/docs/pluginable/0-0-1/recipes/add-plugin/
updated: 2026-11-19T07:46:16.797Z
---

# Add a plugin

> Create a new plugin with its own menu item, screen and API action.

The quickest way to add a plugin is to copy the sample plugin **Profiles** and rename it. This recipe builds a plugin called **Orders**.

## 1. Copy the sample

Copy the folder `plugins/profiles` to `plugins/orders`, and rename the file `schemas/profiles.js` to `schemas/orders.js`:

```bash
cp -R plugins/profiles plugins/orders
mv plugins/orders/schemas/profiles.js plugins/orders/schemas/orders.js
```

## 2. Describe the plugin

Replace the content of `plugins/orders/index.js` with:

```js
exports.icon = 'ti ti-shopping-cart';
exports.name = '@(Orders)';
exports.position = 3;
exports.permissions = [{ id: 'orders', name: 'Orders' }];
exports.visible = user => user.sa || user.permissions.includes('orders');
exports.routes = [
	{ url: '/orders/{id}/', html: 'detail' }
];

exports.install = function() {
	ROUTE('+API   ?   -orders    --> Orders/list');
};
```

- `icon` and `name` are the menu item. Icons are Total.js icon classes that start with `ti ti-`, such as `ti ti-box`.
- `position` sets the order in the menu.
- The `ROUTE` line makes the API action `orders` available to the screen.

Every option is listed in [Plugin options](../../reference/plugin-options/).

## 3. Write the action

Replace the content of `plugins/orders/schemas/orders.js` with:

```js
NEWACTION('Orders/list', {
	name: 'List of orders',
	permissions: 'orders',
	action: function($) {
		var arr = [];
		for (var i = 0; i < 3; i++)
			arr.push('Demo order ' + (i + 1));
		$.callback(arr);
	}
});
```

Here you read your real data, for example from the database.

## 4. Adapt the screen

In `plugins/orders/public/index.html`, change the three places that name the sample:

- `BREADCRUMB.add('@(Profiles)', NAV.url);` becomes `BREADCRUMB.add('@(Orders)', NAV.url);`
- `REDIRECT('/profiles/{0}/'.format(id));` becomes `REDIRECT('/orders/{0}/'.format(id));`
- `exports.tapi('profiles ERROR', ...` becomes `exports.tapi('orders ERROR', ...`

In `plugins/orders/public/detail.html`, change `@(Profiles)` to `@(Orders)`.

## 5. Restart and check

Restart Pluginable and sign in. **Orders** is in the side menu and on the home screen, and it lists the demo orders.

![The new Orders plugin open in the admin, with three demo orders](/files/JapUTH4ps60f.webp)

Next steps:

- [Add a detail page](../add-detail-page/)
- [Add plugin settings](../add-plugin-settings/)
