# Get started with Total.js 5

> Install Total.js 5, create the start script and the first route, action and view, and run the application.

Framework: total5
Product: Total.js 5 (total5@0.0.19)
Language: en
Content-SHA256: 5f7bf99c3dc733b1a14f49c26a40d678238c8c9e2e60d732ca14763a7eab43e7
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: total5-installed@total5@0.0.19
Review: not-recorded

Total.js 5 is the npm package `total5`. You need Node.js (the examples of this site run on Node.js 24) and an empty folder. Create the project and install the package:

```bash
mkdir hello && cd hello
npm init -y
npm install total5
```

The start script is a file named `index.js` in the root of the project. It loads the framework and starts the server:

```js
require('total5');

Total.run({ port: 8000 });
```

That is all the code you write to start. The files in the folders of the project (see the project structure page) are loaded automatically. Create these three files.

A **controller** declares the routes. `ROUTE('GET /')` with no handler would show the view with the same name; here the handler renders `views/index.html` with a model:

```js controllers/index.js
exports.install = function() {
	ROUTE('GET /', home);
	ROUTE('POST /greet/ --> *Greet/say');
};

function home($) {
	$.view('index', { title: 'Hello Total.js' });
}
```

An **action** has its own validation. The route above runs `Greet/say` with the JSON body of the request, and the framework rejects a body that does not match `input`:

```js definitions/greet.js
NEWACTION('Greet/say', {
	name: 'Say hello',
	input: '*name:String',
	action: function($, model) {
		$.callback({ message: 'Hello, ' + model.name + '!' });
	}
});
```

A **view** is HTML with `@{...}` blocks. `views/layout.html` wraps every view and `@{body}` is the place of the view:

```html views/layout.html
<!DOCTYPE html>
<html>
<head><meta charset="utf-8" /><title>Hello</title></head>
<body>@{body}</body>
</html>
```

```html views/index.html
<h1>@{model.title}</h1>
```

Start the application with `node index.js`. In `debug` mode (the default) the application restarts when you change a file and the address is printed in the terminal. To run it like on a server use `node index.js --release`, and read the `release` mode page for what changes.
