Introduction
AdonisJS is a fully featured web framework for Node.js built with TypeScript. Inspired by Laravel and Rails, it ships with an ORM, authentication, validation, mailer, and testing utilities out of the box, letting teams start building features immediately instead of assembling middleware stacks.
What AdonisJS Does
- Provides a complete MVC architecture with controllers, models, views, and routes
- Includes Lucid ORM with Active Record pattern, migrations, seeders, and query builder
- Ships built-in authentication with session, token, and social login drivers
- Offers a powerful validation library with type-safe schema definitions
- Bundles a CLI tool (Ace) for scaffolding, migrations, and custom commands
Architecture Overview
AdonisJS uses an IoC container for dependency injection and service resolution across the application. HTTP requests flow through a middleware pipeline into route-matched controllers. The framework's provider-based architecture lets each subsystem (database, mail, auth) register itself into the container at boot time. Edge.js serves as the default template engine for server-rendered views, while the framework also works as a pure API backend when paired with any frontend.
Self-Hosting & Configuration
- Scaffold a new project with
npm init adonisjs@latestand choose between web, API, or slim presets - Configure environment variables via
.envfiles with built-in validation throughenv.ts - Set up database connections in
config/database.tssupporting PostgreSQL, MySQL, SQLite, and MSSQL - Run migrations with
node ace migration:runand seed data withnode ace db:seed - Deploy to any Node.js host; use
node ace buildto compile TypeScript for production
Key Features
- TypeScript-first design with end-to-end type safety from routes to database queries
- Built-in social authentication via Ally with drivers for Google, GitHub, Discord, and more
- Health checks, graceful shutdown, and structured logging ready for production from day one
- First-party packages for Redis, internationalization, rate limiting, and file uploads
- Japa test runner integrated for unit, functional, and browser testing
Comparison with Similar Tools
- Express — minimal and unopinionated; AdonisJS provides structure and built-in features that Express requires assembling from third-party packages
- NestJS — similar batteries-included philosophy with decorator-heavy DI; AdonisJS uses simpler IoC patterns and feels closer to Laravel
- Fastify — focused on raw HTTP performance; AdonisJS trades marginal speed for a complete application framework
- Laravel — AdonisJS draws direct inspiration from Laravel but runs on Node.js with TypeScript instead of PHP
- Hono — lightweight edge-first framework; AdonisJS targets full server-side applications with ORM and auth included
FAQ
Q: Is AdonisJS suitable for building APIs only? A: Yes. The API starter kit strips out views and session middleware, giving you a lean JSON API setup with auth, validation, and ORM ready to go.
Q: How does Lucid ORM compare to Prisma or TypeORM? A: Lucid follows the Active Record pattern with a chainable query builder. It is deeply integrated with AdonisJS features like auth and validation, reducing boilerplate compared to using a standalone ORM.
Q: Can I use AdonisJS with React or Vue on the frontend? A: Yes. Use the API preset and serve your SPA separately, or use Inertia.js integration to build monolithic apps with React, Vue, or Svelte views.
Q: How large is the AdonisJS community? A: AdonisJS has an active Discord community, regular releases, and a growing ecosystem of first-party and community packages.