Rivet Framework
The Ultimate Full-Stack Dart Framework
π 1.8x Faster than Express | π Production-Ready | π― Type-Safe | β‘ Native Compilation
Note: This is Rivet for Dart, a high-performance backend framework for Dart and Flutter.
Not to be confused with rivet.dev, which is a TypeScript framework for stateful workloads.
Why Rivet?
Rivet is the only Dart framework that gives you:
- β Single Language - Dart everywhere (backend + Flutter frontend)
- β Native Compilation - Deploy a single executable (no runtime needed)
- β Blazing Fast - 24,277 req/sec on dynamic routes (1.8x faster than Express)
- β Type-Safe - End-to-end type safety
- β Production-Ready - Built-in auth, rate limiting, WebSockets, database support
Quick Start
import 'package:rivet/rivet.dart';
void main() async {
final app = RivetServer();
app.get('/hello', (req) {
return RivetResponse.json({'message': 'Hello, World!'});
});
await app.listen(port: 3000);
}
Compile to native binary:
dart compile exe server.dart -o server
./server # Instant startup!
Features
π Security & Authentication
- JWT Authentication - Token validation with role-based access
- Rate Limiting - Token bucket algorithm
- CORS - Full cross-origin support
- Request Validation - Schema validation with sanitization
β‘ Performance
- WebSockets - Real-time with rooms & broadcasting
- SSE Streaming - Server-Sent Events
- Worker Isolates - Multi-core request handling
- Connection Pooling - Database connection reuse
ποΈ Database
- PostgreSQL - Full adapter with connection pooling
- Query Builder - Type-safe SQL construction
- Migrations - Schema versioning
π οΈ Developer Experience
- Hot Reload - Auto-restart on file changes
- Request Logging - Colored console + JSON structured logs
- Testing Utilities - Integration test helpers
- Plugin System - Extensible architecture
π Production
- Metrics - Prometheus-compatible endpoint
- Session Management - Cookie-based with auto-cleanup
- Caching - In-memory with TTL
- Docker Support - Official images
Benchmarks
| Framework | Simple JSON | Dynamic Routes |
|---|---|---|
| Rivet | 14,334 req/s | 15,696 req/s β |
| Node.js | 30,691 req/s | 9,967 req/s |
| Express | 20,571 req/s | 4,674 req/s |
Rivet is 3.3x faster than Express on real-world dynamic routes!
Examples
JWT Authentication
app.use(jwt(
secret: 'your-secret',
requiredRoles: ['admin'],
));
app.get('/protected', (req) {
final userId = req.params['__jwt_userId'];
return RivetResponse.ok({'user': userId});
});
WebSockets
app.ws('/chat', (conn) {
conn.join('room1');
conn.messages.listen((msg) {
conn.broadcast('room1', {'message': msg});
});
});
Database
final db = await PostgresAdapter.connect(
host: 'localhost',
port: 5432,
database: 'mydb',
username: 'user',
password: 'pass',
);
final users = await db.query('SELECT * FROM users WHERE id = @id',
substitutionValues: {'id': 1});
Validation
final validator = Validator()
..field('email', [RequiredRule(), EmailRule()])
..field('password', [MinLengthRule(8)]);
app.use(validate(validator));
Installation
dependencies:
rivet: ^1.0.0
Documentation
Deployment
Docker
docker build -t my-rivet-app .
docker run -p 8080:8080 my-rivet-app
Native Binary
./scripts/build.sh
./build/rivet_server
Contributing
We welcome contributions! See CONTRIBUTING.md
License
MIT License - see LICENSE
Built with β€οΈ by Supratim Dhara
Libraries
- adapters
- Shelf adapters for Rivet (v2.0 - Phase 1)
- api_client
- rivet
- Rivet Framework