Total.js Framework v5

0.0.16 · active · verified Sun Apr 19

Total.js v5 is a full-stack, server-side MVC framework for Node.js, written entirely in pure JavaScript. It is designed to build web, desktop, service, and IoT applications, providing a comprehensive, dependency-free ecosystem (excluding specific database connectors). The current stable version on npm is 0.0.15 (as of late 2025), representing the fifth major iteration of the Total.js platform. Initially released in beta around November 2023, it was declared 'almost stable' by January 2024. Total.js differentiates itself by embracing a 'pure JavaScript' philosophy, explicitly discouraging TypeScript usage, and integrating core functionalities like a web server, robust routing, an embedded NoSQL database (TextDB), WebSockets, and cron job management directly into the framework. It targets Node.js version 19 or higher, aiming for high performance and minimal external tooling.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up a basic Total.js v5 web server with a 'Hello world' GET route and a simple WebSocket chat endpoint.

const framework = require('total5');

// Register a simple GET route
ROUTE('GET /', function($) {
    // $ represents the controller instance
    $.json({ message: 'Hello world from Total.js v5!' });
});

// Register a WebSocket route
ROUTE('SOCKET /chat/', function($) {
    $.on('open', function(client) {
        console.log('Client connected:', client.id);
        client.send({ message: 'Welcome to the chat!' });
    });

    $.on('message', function(client, message) {
        console.log(`Message from ${client.id}:`, message);
        // Broadcast the message to all connected clients
        $.send({ sender: client.id, text: message.text || message });
    });

    $.on('close', function(client) {
        console.log('Client disconnected:', client.id);
    });
});

// Launch the web server on port 8000
Total.http({
    port: process.env.PORT ?? 8000,
    load: 'none' // 'none' for minimal setup, 'release' for production
});

console.log(`Total.js v5 server running at http://127.0.0.1:${process.env.PORT ?? 8000}/`);
console.log(`WebSocket server running at ws://127.0.0.1:${process.env.PORT ?? 8000}/chat/`);

view raw JSON →