Quick Start
Build and run your first AxilJS backend with HTTP, security, authentication, validation, and database support.
Create your first AxilJS application
This guide takes you from an empty directory to a running AxilJS backend.
By the end, you will have:
- A TypeScript HTTP server
- Security middleware
- Structured API responses
- JWT authentication
- Request validation
- Database connectivity
- Hot reload during development
Install the CLI
Install the AxilJS CLI globally:
Verify the installation:
Tip
You can also create a project without installing the CLI globally:
npx @axiljs/cli create my-api
Create a project
Create a new AxilJS application:
Then start the development server:
Your application is available at:
ORM Studio starts alongside the application by default:
Info
axil run watches your source files, recompiles changes, and restarts the application automatically during development.
Project structure
The generated project provides a standard starting structure:
You can adapt this structure as your application grows. AxilJS supports modular applications, MVC, monoliths, and distributed architectures.
Build your first server
Open src/main.ts and create the application:
Save the file. axil run watches the source tree and restarts the server when the file changes.
Built-in response manager
AxilJS provides structured response methods directly on the response object.
For example:
A successful response follows a consistent structure:
Paginated responses also include pagination metadata.
Tip
The response manager is built into AxilJS. You do not need to import a separate response-formatting package.
Test your API
With the server running, test the health endpoint:
Test the user endpoint:
Create a user:
On Unix-like systems, the equivalent command is:
A successful creation response looks like:
Add authentication
AxilJS provides JWT authentication and role-based access control through @axiljs/auth.
Install the package if it is not already present:
Then create a JWT instance:
Protect a route:
Require a specific role:
Tip
AxilJS authentication includes password hashing and RBAC middleware. See the Authentication docs for login, registration, token, and role-management examples.
Add request validation
Use @axiljs/validation to validate request bodies before your handlers execute.
Invalid input produces a structured validation response:
Add a database
AxilJS ORM supports:
- PostgreSQL
- MySQL
- SQLite
- Class-based models
- Decorators
- Query builders
- Repositories
- Database migrations
Install the ORM:
Create a database connection:
Define a model:
Register the database driver:
You can then work with the model:
Tip
See the ORM documentation for database connections, entities, repositories, query building, and migrations.
Explore ORM Studio
When you run:
AxilJS starts ORM Studio alongside your development server.
Open:
Studio provides:
- API Explorer
- Try It Out
- Database Browser
- SQL Query Editor
- Realtime Monitor
- API collection export
- QR code access
This gives you a visual development interface without requiring a separate API client for basic exploration.
CLI workflow
The axil CLI covers the main application lifecycle:
| Command | Description |
|---|---|
axil create <name> | Create a new AxilJS project |
axil run | Start the development server with hot reload |
axil build | Compile the application for production |
axil test [pattern] | Run matching test files |
axil deploy | Generate Docker and Kubernetes deployment files |
axil install [package] | Install an AxilJS package |
axil install -D [package] | Install a development dependency |
axil doctor | Diagnose project issues |
axil --version | Display the CLI version |
What's included?
The AxilJS ecosystem is organized under the @axiljs scope.
| Package | Purpose |
|---|---|
@axiljs/core | HTTP server, router, middleware, SSE, static files, response manager |
@axiljs/config | Environment loading and typed configuration |
@axiljs/security | Helmet, rate limiting, CSRF, and sanitization |
@axiljs/auth | JWT, password hashing, authentication, and RBAC |
@axiljs/validation | Schema-based request validation |
@axiljs/orm | PostgreSQL, MySQL, SQLite, and migrations |
@axiljs/testing | Test runner, assertions, and HTTP test client |
@axiljs/events | In-process event bus and pub/sub |
@axiljs/websocket | WebSocket server and rooms |
@axiljs/queue | Message queue, scheduler, retries, and delayed jobs |
@axiljs/circuit | Circuit breaker, retry, timeout, and fallback |
@axiljs/observability | Logging, metrics, tracing, and health checks |
@axiljs/ai | AI providers, RAG, agents, vector storage, and MCP |
@axiljs/cloud | Multi-tenancy, audit logs, feature flags, and deployment |
@axiljs/memory | Memory monitoring, leak detection, GC, and optimization |
@axiljs/pm | AxilJS package and process-management capabilities |
@axiljs/studio | Browser-based developer dashboard |
@axiljs/cli | Project scaffolding and development lifecycle commands |
Next steps
You now have the foundation for a complete AxilJS backend.
Continue with the part of the platform you need:
- Project Structure — Organize an AxilJS application
- HTTP Server — Routing, middleware, static files, and SSE
- Response Manager — Consistent API responses
- Authentication — JWT, RBAC, and password hashing
- Validation — Request schemas and validation errors
- Database & ORM — Models, queries, and migrations
- ORM Studio — Visual API and database development
- AI Platform — Providers, RAG, agents, and MCP
- Security — Security middleware and protection
- WebSockets — Realtime communication
- Queue & Scheduler — Background jobs and scheduled tasks
- Observability — Logging, metrics, and tracing
- Cloud & Deployment — Deployment and cloud capabilities