The Node.js framework that makes API development feel like magic
Building APIs shouldn't require endless boilerplate, complex routing configurations, or juggling between multiple tools. Lithia changes that.
# Create a new Lithia project npx create-lithia-app my-api cd my-api npm run dev
That's it. Your API is running, hot-reloading, and ready to develop with a beautiful web interface.
Traditional Node.js frameworks force you to:
- ❌ Manually configure every route
- ❌ Switch between code editor, terminal, and Postman/Insomnia
- ❌ Lose time with server restarts and debugging
- ❌ Fight with TypeScript configurations
Lithia gives you:
- ✅ File-based routing - folders become routes automatically
- ✅ Lithia Studio - develop, test, and debug in one place
- ✅ Instant hot reload - see changes in milliseconds
- ✅ TypeScript-first - full type safety out of the box
npx create-lithia-app my-api
cd my-api
npm run dev// src/routes/users/route.get.ts export default async (req, res) => { const users = [ { id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }, ]; return res.json(users); };
That's it! GET /users is now live at http://localhost:3000/users
// src/routes/users/[id]/route.get.ts export default async (req, res) => { const { id } = req.params; // Your database logic here const user = await db.users.findById(id); if (!user) { return res.status(404).json({ error: 'User not found' }); } return res.json(user); };
Now GET /users/123 works automatically!
Lithia's killer feature: your folder structure IS your API structure. No configuration needed.
src/routes/
├── users/
│ ├── route.ts # Handles ALL methods on /users
│ ├── route.post.ts # Handles ONLY POST /users
│ └── [id]/
│ ├── route.ts # All methods /users/:id
│ └── route.put.ts # Only PUT /users/:id
├── products/
│ ├── route.get.ts # GET /products
│ └── [slug]/
│ └── route.ts # All methods /products/:slug
└── api/
└── health/
└── route.get.ts # GET /api/health
| File Pattern | What it does | Example URL |
|---|---|---|
route.ts |
Handles all HTTP methods | Any method on /path |
route.get.ts |
Only GET requests | GET /path |
route.post.ts |
Only POST requests | POST /path |
route.put.ts |
Only PUT requests | PUT /path |
route.delete.ts |
Only DELETE requests | DELETE /path |
[param]/ |
Dynamic route parameter | /users/123 → params.id = "123" |
// src/routes/posts/route.post.ts export default async (req, res) => { const { title, content } = req.body; const post = await db.posts.create({ title, content }); return res.status(201).json(post); };
// src/routes/posts/[id]/route.delete.ts export default async (req, res) => { const { id } = req.params; await db.posts.delete(id); return res.status(204).send(); };
The game-changer. Lithia Studio is a complete development environment in your browser.
Monitor your server's health at a glance:
- CPU and memory usage
- Request/response metrics
- Active connections
- Performance graphs
Visualize and test your entire API:
- See all routes in a tree structure
- Click to test any endpoint
- View request/response in real-time
- Inspect headers, body, and status codes
Create routes without touching code:
- Visual interface to build new routes
- Choose HTTP methods (GET, POST, PUT, DELETE)
- Set up dynamic parameters with
[id]syntax - Generate route files automatically
- Preview route structure before creation
- Edit the code before creating the route
Test your API endpoints instantly:
- Send requests with custom headers and body
- Test different HTTP methods
- View real-time responses
- Debug request/response flow
Lithia Studio Live Logs Viewer
Never leave the browser:
- Stream logs in real-time
- Filter by level (info, warn, error)
- Syntax highlighting
- Search and export logs
Lithia Studio Live Configuration Viewer
See your server configuration in real-time:
- View current ports, CORS settings, middleware
- Monitor active configuration
- Inspect all server settings at a glance
The fastest development loop:
- Change a file → see results in milliseconds
- No manual server restarts
- No cache issues
- Just pure speed
Access Lithia Studio: When your server is running, Lithia Studio is automatically available at http://localhost:8473
Full type safety without configuration:
// src/routes/api/users/route.post.ts import type { Request, Response } from 'lithia'; interface CreateUserBody { name: string; email: string; age: number; } export default async (req: Request<CreateUserBody>, res: Response) => { const { name, email, age } = req.body; // Fully typed! // Your logic here return res.json({ success: true }); };
Extend Lithia at every lifecycle point:
// lithia.config.ts import { defineLithiaConfig } from 'lithia'; import type { LithiaConfig, LithiaRequest, LithiaResponse } from 'lithia/types'; const config: LithiaConfig = { server: { port: 3000, }, hooks: { 'request:before': (req: LithiaRequest, res: LithiaResponse) => { console.log(`Incoming: ${req.method} ${req.url}`); }, 'request:after': (req: LithiaRequest, res: LithiaResponse) => { console.log(`Completed: ${res.statusCode}`); }, 'request:error': ( req: LithiaRequest, res: LithiaResponse, error: Error, ) => { console.error('Request error:', error); }, 'middleware:beforeExecute': (middleware, req, res) => { console.log(`Executing middleware: ${middleware.name}`); }, 'middleware:afterExecute': (middleware, req, res) => { console.log(`Middleware completed: ${middleware.name}`); }, 'middleware:error': (middleware, req, res, error) => { console.error(`Middleware error in ${middleware.name}:`, error); }, }, }; export default defineLithiaConfig(config);
Available hooks:
request:before- Before request processingrequest:after- After request completionrequest:error- When request failsmiddleware:beforeExecute- Before each middleware runsmiddleware:afterExecute- After each middleware completesmiddleware:error- When middleware throws error
Change your code and see results instantly:
- No server restarts
- No manual refreshes
- State preservation when possible
- Works with Lithia Studio
Add middleware directly to your routes:
// src/routes/api/users/route.get.ts // Define middlewares for this route export const middlewares = [ async (req, res, next) => { // Authentication middleware if (!req.headers.authorization) { return res.status(401).json({ error: 'Unauthorized' }); } next(); }, async (req, res, next) => { // Logging middleware console.log(`${req.method} ${req.url}`); next(); }, ]; // Your route handler export default async (req, res) => { const users = await db.users.findAll(); return res.json(users); };
| Feature | Lithia | Express | NestJS |
|---|---|---|---|
| File-based Routing | ✅ | ❌ | ❌ |
| Built-in Dev Interface | ✅ | ❌ | ❌ |
| TypeScript-First | ✅ | ✅ | |
| Hot Reload | ✅ | ❌ | ❌ |
| Zero Configuration | ✅ | ❌ | ❌ |
| Learning Curve | Low | Low | High |
| Boilerplate | Minimal | Medium | Heavy |
// src/routes/api/todos/route.get.ts export default async (req, res) => { const todos = await db.todos.findAll(); return res.json(todos); }; // src/routes/api/todos/route.post.ts export default async (req, res) => { const { title } = req.body; const todo = await db.todos.create({ title, completed: false }); return res.status(201).json(todo); }; // src/routes/api/todos/[id]/route.put.ts export default async (req, res) => { const { id } = req.params; const { completed } = req.body; const todo = await db.todos.update(id, { completed }); return res.json(todo); }; // src/routes/api/todos/[id]/route.delete.ts export default async (req, res) => { const { id } = req.params; await db.todos.delete(id); return res.status(204).send(); };
That's a complete CRUD API in 4 files. No routing configuration. No boilerplate.
Visit lithiajs.com for:
- Complete API reference
- In-depth guides and tutorials
- Best practices
- Migration guides
- Examples and templates
We love contributions! Before getting started, please read our Contributing Guidelines.
- Fork the repository
- Clone your fork:
git clone https://github.com/your-username/lithia.git - Install dependencies:
npm install - Create a branch:
git checkout -b feature/amazing-feature - Make your changes
- Test your changes:
npm test - Commit using conventional commits:
git commit -m "feat: add amazing feature" - Push to your branch:
git push origin feature/amazing-feature - Open a Pull Request
- Bug Reports - Use the bug report template
- Feature Requests - Use the feature request template
- Documentation - Improvements always welcome
- Ideas - Share in Discussions
- GitHub Discussions - Ask questions, share ideas
- GitHub Issues - Report bugs
- Email - Direct contact
- OpenCollective - Support the project
If Lithia makes your life easier, consider supporting it:
- Star this repository
- Share on social media
- Sponsor via OpenCollective
- Report bugs and suggest improvements
- Improve documentation
Lithia is MIT licensed. Free for personal and commercial use.
Built with ❤️ by the Lithia community