Introduction

Introduction

What is AdonisJS?

AdonisJS is a TypeScript-first web framework for Node.js. You can use it to create a full-stack web application or a JSON API server.

At the fundamental level, AdonisJS provides structure to your applications, configures a seamless TypeScript development environment, configures HMR for your backend code, and offers a vast collection of well-maintained and extensively documented packages.

We envision teams using AdonisJS spending less time on trivial decisions like cherry-picking npm packages for every minor feature, writing glue code, debating for the perfect folder structure, and spending more time delivering real-world features critical for the business needs.

Frontend agnostic

AdonisJS focuses on the backend and lets you choose the frontend stack of your choice.

If you like to keep things simple, pair AdonisJS with a traditional template engine to generate static HTML on the server, create a JSON API for your frontend Vue/React application or use Inertia to make your favorite frontend framework work together in perfect harmony.

AdonisJS aims to provide you with batteries to create a robust backend application from scratch. Be it sending emails, validating user input, performing CRUD operations, or authenticating users. We take care of it all.

Modern and Type-safe

AdonisJS is built on top of modern JavaScript primitives. We use ES modules, Node.js sub-path import aliases, SWC for executing TypeScript source, and Vite for assets bundling.

Also, TypeScript plays a considerable role when designing the framework's APIs. For example, AdonisJS has:

Embracing MVC

AdonisJS embraces the classic MVC design pattern. You start by defining the routes using the functional JavaScript API, bind controllers to them and write logic to handle the HTTP requests within the controllers.

start/routes.ts
import router from '@adonisjs/core/services/router'
const PostsController = () => import('#controllers/posts_controller')
router.get('posts', [PostsController, 'index'])

Controllers can use models to fetch data from the database and render a view (aka template) as a response.

app/controllers/posts_controller.ts
import Post from '#models/post'
import type { HttpContext } from '@adonisjs/core/http'
export default class PostsController {
async index({ view }: HttpContext) {
const posts = await Post.all()
return view.render('pages/posts/list', { posts })
}
}

If you are building an API server, you can replace the view layer with a JSON response. But, the flow of handling and responding to the HTTP requests remains the same.

app/controllers/posts_controller.ts
import Post from '#models/post'
import type { HttpContext } from '@adonisjs/core/http'
export default class PostsController {
async index({ view }: HttpContext) {
const posts = await Post.all()
return view.render('pages/posts/list', { posts })
/**
* Posts array will be serialized to JSON
* automatically.
*/
return posts
}
}

Guides assumptions

The AdonisJS documentation is written as a reference guide, covering the usage and the API of several packages and modules maintained by the core team.

The guide does not teach you how to build an application from scratch. If you are looking for a tutorial, we recommend starting your journey with Adocasts. Tom (the creator of Adocasts) has created some highly quality screencasts, helping you to take the first steps with AdonisJS.

With that said, the documentation extensively covers the usage of available modules and the inner workings of the framework.

Recent releases

Following is the list of recent releases. Click here to view all the releases.

Package Change Released on
@adonisjs/core Add support for dd and dump helpers. Sep 21, 2024
@adonisjs/hash Fix parameters order of Argon2 hash. Sep 20, 2024
@adonisjs/core Keep APP_KEY as an empty value within the .env.example file. Sep 11, 2024
@adonisjs/presets Generate SilentAuth middleware. Sep 11, 2024
@adonisjs/core Use Ace Kernel errorHandler when running commands. Sep 5, 2024

Sponsors