{"id":12158,"library":"total5","title":"Total.js Framework v5","description":"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.","status":"active","version":"0.0.16","language":"javascript","source_language":"en","source_url":"https://github.com/totaljs/framework5","tags":["javascript","total.js","total5","framework","web","platform"],"install":[{"cmd":"npm install total5","lang":"bash","label":"npm"},{"cmd":"yarn add total5","lang":"bash","label":"yarn"},{"cmd":"pnpm add total5","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Total.js v5 primarily uses CommonJS `require` for framework initialization and operates with global functions like `ROUTE` and `Total.http`. ESM `import` is not the standard for core framework components.","wrong":"import total5 from 'total5';","symbol":"total5","correct":"require('total5');"},{"note":"Route definitions are made using the global `ROUTE` function, which becomes available after `require('total5')` is called.","wrong":"import { ROUTE } from 'total5';","symbol":"ROUTE","correct":"ROUTE('GET /', function($) { /* ... */ });"},{"note":"The HTTP server is started via the global `Total.http` method, configured with an options object.","wrong":"import { http } from 'total5';","symbol":"Total.http","correct":"Total.http({ load: 'none' });"},{"note":"Data schemas are defined using the global `NEWSCHEMA` function, part of Total.js's built-in data modeling capabilities.","wrong":"import { NEWSCHEMA } from 'total5';","symbol":"NEWSCHEMA","correct":"NEWSCHEMA('Users', function(schema) { /* ... */ });"}],"quickstart":{"code":"const framework = require('total5');\n\n// Register a simple GET route\nROUTE('GET /', function($) {\n    // $ represents the controller instance\n    $.json({ message: 'Hello world from Total.js v5!' });\n});\n\n// Register a WebSocket route\nROUTE('SOCKET /chat/', function($) {\n    $.on('open', function(client) {\n        console.log('Client connected:', client.id);\n        client.send({ message: 'Welcome to the chat!' });\n    });\n\n    $.on('message', function(client, message) {\n        console.log(`Message from ${client.id}:`, message);\n        // Broadcast the message to all connected clients\n        $.send({ sender: client.id, text: message.text || message });\n    });\n\n    $.on('close', function(client) {\n        console.log('Client disconnected:', client.id);\n    });\n});\n\n// Launch the web server on port 8000\nTotal.http({\n    port: process.env.PORT ?? 8000,\n    load: 'none' // 'none' for minimal setup, 'release' for production\n});\n\nconsole.log(`Total.js v5 server running at http://127.0.0.1:${process.env.PORT ?? 8000}/`);\nconsole.log(`WebSocket server running at ws://127.0.0.1:${process.env.PORT ?? 8000}/chat/`);","lang":"javascript","description":"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."},"warnings":[{"fix":"Rewrite route handlers to utilize methods and properties available directly on the `$` controller instance. Refer to `$` documentation for updated API.","message":"Total.js v5 introduces significant changes to routing. Direct access to `request` and `response` instances (`$.req`, `$.res`) is removed. All request/response handling is now abstracted through the `controller` instance (alias `$`).","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Migrate session logic to use `AUTH()` for authentication-related sessions or implement a custom session solution as needed.","message":"The `SESSION()` method for internal session management has been removed in Total.js v5. Developers should now use the `AUTH()` method, which includes predefined session functionality, or implement custom session handling.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Replace all instances of `PREF` with `MEMORIZE(name)` to access or store persistent application data.","message":"The `PREF` global for persistent preferences has been removed. Its functionality is replaced by the `MEMORIZE(name)` method.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Update schema definitions to use `schema.action()` for all operations, migrating existing `schema.define()` calls.","message":"For data schemas, `schema.define()` is no longer supported in Total.js v5. Schema actions should be defined directly using `schema.action()`.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Adhere to the pure JavaScript development model, or consider alternative frameworks if TypeScript is a strict requirement for your project.","message":"Total.js v5 has a strong philosophy of pure JavaScript development and explicitly states that users wanting to use TypeScript will be disappointed. The framework is optimized for direct JavaScript without transpilation.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Ensure your development and production environments are running Node.js v19 or a newer compatible version.","message":"Total.js v5 requires Node.js version 19 or higher. Running on older Node.js versions may lead to unexpected errors or stability issues.","severity":"gotcha","affected_versions":"<0.0.15"},{"fix":"Be prepared to explore examples, join the Total.js Telegram chat, or refer to previous version documentation when current v5 docs are lacking.","message":"The documentation for Total.js v5 is still incomplete, and developers may need to consult source code, community channels, or older documentation (v3/v4) for certain features or patterns.","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure `require('total5');` is at the top of your main application file (e.g., `index.js`) before any `ROUTE` or other global Total.js functions are called. Then run with `node index.js`.","cause":"The Total.js framework was not properly initialized via `require('total5')` at the beginning of the script, or the script is not being run directly by Node.js.","error":"ReferenceError: ROUTE is not defined"},{"fix":"Refactor your code to use the new controller API. For example, use `$.body` for POST/PUT body data, `$.query` for query parameters, or specific helper methods provided by the `$` instance.","cause":"In Total.js v5, direct `request` and `response` objects (`$.req`, `$.res`) have been removed from the controller instance (`$`). You should access data and methods directly on `$` or its helper properties.","error":"TypeError: $.req.body.someProperty is not a function/property"},{"fix":"Update your Node.js environment to version 19 or later. You can use tools like NVM (Node Version Manager) to manage multiple Node.js versions.","cause":"The Node.js runtime version being used is older than the minimum requirement for Total.js v5.","error":"Error: Total.js v5 requires Node.js version >= 19"}],"ecosystem":"npm"}