Exploring AdonisJS

2:02:203 min readMaximilian Schwarzmüller05/22/2026Computing/Software · Small Business/Startups · Internet Technology

Key Takeaway

Adonis.js provides a comprehensive, batteries-included alternative to modular JavaScript stacks by integrating core features like ORM, authentication, and view rendering into a single, cohesive framework.

Highlights

  • Adonis.js functions as a full-stack, batteries-included framework for JavaScript, offering built-in authentication, ORM, caching, and rate-limiting.

  • The framework provides three distinct frontend approaches: server-side HTML rendering with Edge templates, React-based development via Inertia.js, and REST API creation.

  • Using a monolithic framework like Adonis.js reduces dependency bloat compared to stitching together numerous individual libraries for backends.

  • The Lucid ORM allows interaction with database tables through JavaScript model classes rather than raw SQL queries.

  • Development environments include built-in commands, migrations for schema changes, and factory/seeder utilities for generating and populating dummy data.

  • Adonis.js maintains a strict separation between backend and frontend, preventing the accidental exposure of server-side code to the client.

Timeline

  1. Adonis.js Framework Philosophy

    Adonis.js is frequently compared to Laravel due to its batteries-included approach. Unlike frameworks focused primarily on routing and server-side rendering, Adonis provides its own ORM and native support for complex backend requirements. This integrated structure is intended to improve security by minimizing the need for numerous external library dependencies.

    • Adonis.js is characterized as a backend-first, type-safe framework for Node.js and TypeScript.
    • It eliminates reliance on third-party services by including essential features like authentication, file uploads, and rate limiting by default.
    • The framework architecture prioritizes a limited set of dependencies to mitigate supply chain security risks.
  2. Frontend Integration Strategies

    Adonis.js offers flexibility in the view layer. The Hypermedia approach is suited for traditional multi-page applications, while Inertia.js enables a single-page application experience with React while maintaining the benefits of server-side rendering. The choice of frontend strategy does not change the core backend controller logic.

    • Developers can choose between Hypermedia, Inertia.js with React, or a pure REST API approach for the frontend.
    • Hypermedia applications use the Edge template engine to generate HTML on the server and lightweight libraries like Alpine.js for interactivity.
    • Inertia.js serves as a bridge, allowing React components to be server-side rendered without requiring manual data fetching or API endpoint management in the component.
  3. Project Structure and Initial Setup

    Setting up an Adonis.js project requires Node.js and the Ace CLI tool to manage life-cycle scripts. The folder structure follows a clear pattern: app for domain logic, config for environment settings, and database for migrations. This structure ensures that server-side concerns remain decoupled from frontend assets stored in the resources folder.

    • Initialization involves using npm create for the starter kit, with sqlite3 utilized as the default lightweight database.
    • The project structure organizes logic within the app, configuration in config, and database schemas in the database directory.
    • Ace serves as the command-line interface for managing tasks, including running migrations and generating application files.
  4. Database Modeling and Relationships

    Adonis.js uses a migration-based system to track database evolution. Relationships between entities are established by defining foreign keys in migration files and mapping these associations within the model classes using specific decorators. This workflow allows developers to query complex data sets programmatically without writing manual SQL.

    • Models act as JavaScript classes for data interaction, while migrations define the physical database table structures.
    • Lucid ORM decorators, such as @hasMany and @belongsTo, define relationships between models like posts, comments, and users.
    • Factories and seeders automate the generation and insertion of fake data to facilitate rapid development and testing.
  5. Authorization and Controller Logic

    Controllers leverage the HTTP context to access requests, responses, and authentication states. For authorization, the Bouncer package allows for the creation of policy classes that encapsulate permission logic, such as ensuring only post owners can edit or delete their content. This modular approach keeps authentication and authorization concerns isolated from business logic.

    • Controller methods handle incoming HTTP requests by interacting with models and returning views or serialized data.
    • The Bouncer package manages authorization through policies that verify user permissions before executing sensitive operations.
    • Validation is performed using the Vine library, which enforces data integrity rules and automatically generates error messages.

Description

Made with Restream. Livestream on 30+ platforms at once via https://restream.io

Community Posts

View all posts
Write about this video