---
title: Installation and first app
project: Total.js V4
version: 0.0.99
section: guides
language: en
license: MIT
url: https://totaljs.es/docs/total-js-v4/0-0-99/guides/installation/
updated: 2026-11-16T15:41:00.817Z
---

# Installation and first app

> Install Total.js 4, write the start script and answer your first requests.

## Requirements

Node.js. Total.js 4 has no dependencies and does not require a specific version of Node.js; use a current LTS release.

## Install

```bash
mkdir myapp
cd myapp
npm init -y
npm install total4
```

## The start script

Create `index.js`. It is the official start script of Total.js 4, reduced to what you need now:

```js
const options = {};

// options.ip = '127.0.0.1';
// options.port = parseInt(process.argv[2]);
// options.config = { name: 'My app' };

var type = process.argv.indexOf('--release', 1) !== -1 ? 'release' : 'debug';
require('total4/' + type)(options);
```

Run it:

```bash
node index.js
```

The app listens on port **8000**. In **debug** mode it restarts by itself when you change a file. In production start it with `node index.js --release`.

## Your first routes

Create `controllers/default.js`:

```js
exports.install = function() {
	ROUTE('GET /', home);
	ROUTE('GET /hello/{name}/', hello);
};

function home() {
	this.plain('Hello world');
}

function hello(name) {
	this.json({ hello: name });
}
```

Open `http://127.0.0.1:8000/` and `http://127.0.0.1:8000/hello/Peter/`. Each action runs with the controller as `this`, and the dynamic parts of the URL arrive as arguments.

## Options of the start script

| Option | What it does |
| --- | --- |
| `ip`, `port` | Address and port of the server (default port `8000`) |
| `unixsocket` | Listens on a Unix socket instead of a port |
| `config` | Values that override the `config` file |
| `sleep` | Waits before starting, in milliseconds |
| `inspector` | Opens the Node.js inspector on a port |
| `watch` | Extra folders that restart the app in debug mode |
| `https` | `key` and `cert` to serve HTTPS directly |
| `cluster`, `cluster_limit` | Runs several processes (`'auto'` scales them) |
| `servicemode` | Starts without the web server (`--servicemode`) |

## Next

Read [Routing](../routing/) to learn the whole syntax of `ROUTE()`.
