A fully featured web framework for Node.js

AdonisJS includes everything you need to create a fully functional web app or an API server. Stop wasting hours in downloading and assembling hundreds of packages together — Use AdonisJS and be productive from day one

Jam-packed framework core

AdonisJS is not a minimalist framework. To give your projects a head start, we pack many baseline features within the core of the framework.

// Handle GET request
Route.get('posts', async ({ view }) => {
return view.render('posts/index')
})
// Handle POST request
Route.post('posts', async ({ request }) => {
return request.body()
})
Route
.group(() => {
Route.get('users', () => {})
Route.post('users', () => {})
})
.prefix('api/v1')
.middleware('auth')
// Static subdomain
Route
.group(() => {
Route.get('articles', () => {})
})
.domain('blog.adonisjs.com')
// Dynamic subdomain
Route
.group(() => {
Route.get('/', () => {})
})
.domain(':tenant.adonisjs.com')
import Post from 'App/Models/Post'
export default class PostsController {
public async index () {
return Post.all()
}
public async store ({ request }) {
return request.body()
}
}
// Bind controller to the route
Route.get('posts', 'PostsController.index')
Route.post('posts', 'PostsController.store')
Route.post('/posts', ({ request }) => {
// Access file
const coverImage = request.file('cover_image', {
extnames: ['jpg', 'png', 'jpeg'],
size: '2mb'
})
// Check for errors
if (coverImage.hasErrors()) {
return coverImage.errors()
}
// Move to uploads directory
await coverImage.move('uploads')
})
import { schema } from '@ioc:Adonis/Core/Validator'
export default class SignupValidator {
public schema = schema.create({
email: schema.string({}, [
rules.email()
]),
password: schema.string({}, [
rules.confirmed()
]),
fullName: schema.string.optional(),
})
}
// Pass validator to the request
Route.post('users', async ({ request }) => {
await request.validate(SignupValidator)
})
{{-- Write any JavaScript expression --}}
{{ user.username }}
{{ user.username.toUpperCase() }}
{{ (2 + 2) * 3 }}
{{ (await getUser()).username }}
@if(user.fullName)
<p> Hello {{ user.fullName }}! </p>
@elseif(user.firstName)
<p> Hello {{ user.firstName }}! </p>
@else
<p> Hello Guest! </p>
@end
{{-- Loop over an array --}}
@each(user in users)
<li> {{ user.username }} </li>
@end
{{-- Maybe an object too --}}
@each((amount, ingredient) in food)
<li> Use {{ amount }} of {{ ingredient }} </li>
@end
{{-- Component markup --}}
<button type="{{ type }}">
{{{ await $slots.main() }}}
</button>
{{-- Using component --}}
@component('button', { type: 'submit' })
<i class="fa-icon-lock" />
<span> Login </span>
@end

Essentials covered

AdonisJS lays down the foundation for you to kick start your development process.

SQL ORM

Create data driven applications using the Active record based ORM and the fluent database query builder

Authentication

A diverse authentication system with support for sessions, API tokens and OAuth based social login

Authorization

Manage user access using the pre-defined authorization actions and policies

REPL

The simplest way to interact with your application from the command line

Health checks

Use the inbuilt health check module to report your application health to the external monitoring services

CLI

An embeded CLI tool to help you create custom commands and automate your workflows

Sponsored by

AdonisJS is a free-to-use, open-source framework released under the MIT License. However, the effort needed to maintain and develop new features is only sustainable with proper financial backing.

If AdonisJS provides value to you or your business, we encourage you to support the framework development: it ensures the project stays healthy and actively maintained.