The lightweight Node.js framework for modern web applications
const Nova = require('novaxjs2');
const app = new Nova();
// Simple route
app.get('/', (req, res) => {
res.send('Hello World!');
});
// Cookie example
app.get('/set-cookie', (req, res) => {
res.cookie('user', 'john', { maxAge: 900000, httpOnly: true });
res.send('Cookie set!');
});
// Start server
app.at(3000, () => {
console.log('Server running on port 3000');
});
Minimal overhead and optimized routing for high performance applications with built-in minification
Extensible plugin system lets you add functionality without bloat. Supports custom methods and middleware
Built-in CORS, file upload validation, cookie security, and protection against common web vulnerabilities
Intuitive syntax that's easy to learn with comprehensive routing and middleware support
Advanced multipart form parsing with configurable file size limits, types, and naming options
Powerful built-in templating with new @ syntax, includes, variables, and custom helpers
Built-in cookie parsing and management with secure cookie options and automatic parsing
Built-in minification for HTML, CSS, and JavaScript with intelligent content preservation
npm install novaxjs2
yarn add novaxjs2
Then create your first app:
index.js
// index.js
const Nova = require('novaxjs2');
const app = new Nova();
const posts = [
{
id: "1",
title: "Hello Novax!",
content: "This is my very first post using Novaxjs2 🚀",
author: "Admin",
createdAt: "2025-08-21T09:00:00Z"
},
{
id: "2",
title: "Getting Started",
content: "Novaxjs2 makes building web apps super simple with built-in routing and templates.",
author: "Jane Doe",
createdAt: "2025-08-21T10:15:00Z"
},
{
id: "3",
title: "Why Novax?",
content: "Because it's lightweight, modern, and designed for both frontend and backend flexibility.",
author: "John Smith",
createdAt: "2025-08-21T11:30:00Z"
}
];
// Using built-in engine with new syntax
app.setViewEngine('novax', {
viewsPath: 'views',
viewsType: 'html'
});
app.get('/', async (req, res) => {
const html = await app.render('home', { posts });
res.send(html);
});
// Cookie example
app.get('/profile', (req, res) => {
const userToken = req.cookies.token;
if (userToken) {
res.send('Welcome back!');
} else {
res.cookie('token', 'guest-session', { maxAge: 3600000 });
res.send('Welcome new user! Cookie set.');
}
});
app.at(3000, () => console.log('Server is running on port 3000'));
views/home.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My First Novax App</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f9f9f9;
margin: 0;
padding: 20px;
color: #333;
}
h1 {
text-align: center;
color: #222;
}
ul {
list-style: none;
padding: 0;
max-width: 600px;
margin: 20px auto;
}
li {
background: #fff;
border-radius: 12px;
padding: 16px;
margin-bottom: 16px;
box-shadow: 0 2px 6px rgba(0,0,0,0.1);
transition: transform 0.2s ease;
}
li:hover {
transform: translateY(-3px);
}
h2 {
margin: 0 0 10px;
color: #0078d7;
}
p {
margin: 0 0 8px;
line-height: 1.5;
}
small {
color: #666;
font-size: 0.9em;
}
</style>
</head>
<body>
<h1>📌 My First Novax App</h1>
<ul>
@each(posts)
<li>
<h2>@title</h2>
<p>@content</p>
<small>By @author - @createdAt</small>
</li>
@end
</ul>
</body>
</html>
// Advanced example showing multiple features
const Nova = require('novaxjs2');
const app = new Nova();
// Enable CORS
app.cors({
origins: ['https://yourdomain.com', 'http://localhost:3000'],
methods: 'GET, POST, PUT, DELETE, OPTIONS',
headers: 'Content-Type, Authorization',
credentials: true
});
// Configure file uploads
app.setFileConfig({
maxSize: 10,
allowedTypes: ['image/jpeg', 'image/png', 'application/pdf'],
maxFiles: 5,
keepOriginalName: false
});
// Add custom middleware
app.useMiddleware((req, res, next) => {
console.log(`${req.method} ${req.url} - ${new Date().toISOString()}`);
next();
});
// Route with parameters and middleware
app.get('/user/:id', (req, res) => {
const userId = req.params.id;
return `User Profile: ${userId}`;
});
// File upload route
app.post('/upload', (req, res) => {
if (!req.files || Object.keys(req.files).length === 0) {
return res.status(400).json({ error: 'No files uploaded' });
}
return res.json({
message: 'Files uploaded successfully',
files: req.files
});
});
// Cookie management example
app.get('/login', (req, res) => {
res.cookie('session', 'user-123', {
maxAge: 24 * 60 * 60 * 1000, // 24 hours
httpOnly: true,
secure: process.env.NODE_ENV === 'production'
});
res.send('Logged in successfully!');
});
app.get('/logout', (req, res) => {
res.clearCookie('session');
res.send('Logged out successfully!');
});
// Group routes with router modules
const apiRouter = {
'/users': {
get: (req, res) => res.json({ users: [{ id: 1, name: 'John' }] }),
post: (req, res) => res.json({ message: 'User created', user: req.body })
},
'/posts': {
get: (req, res) => res.json({ posts: [] })
}
};
app.useRouter(apiRouter);
// Start server with custom host
app.at(3000, '0.0.0.0', () => {
console.log('Server running on http://0.0.0.0:3000');
});
Automatic cookie parsing with req.cookies
and secure cookie management
Cleaner @
syntax with @if
, @each
, @var
, and @include
Better code organization with app.useRouter()
for modular applications
Faster routing, improved template rendering, and better memory management