Introduction to Admin
A comprehensive guide to building, configuring, and scaling modern administrative interfaces with the Admin platform.
What is Admin?
Admin is a powerful, modular framework designed to help developers build secure, scalable, and maintainable administrative panels and dashboards. It provides a unified API, flexible configuration system, and a rich plugin ecosystem that accelerates development cycles.
Admin v3.x introduces breaking changes from v2.x. If you're migrating, please review the Migration Guide before proceeding.
Installation & Setup
Get started in minutes using your preferred package manager. Admin supports Node.js 18+ and runs on major cloud providers.
# Using npm
npm install @admin/core @admin/ui
# Using yarn
yarn add @admin/core @admin/ui
# Using pnpm
pnpm add @admin/core @admin/ui
After installation, initialize the configuration file:
npx admin init
Quick Start
Create your first admin module in under 5 minutes. Below is a minimal example demonstrating routing, authentication, and data fetching.
import { AdminApp, createRouter, authMiddleware } from '@admin/core';
const app = new AdminApp({
name: 'My Dashboard',
theme: 'modern',
});
const router = createRouter([
{
path: '/users',
component: 'UserList',
middleware: [authMiddleware('admin')],
permissions: ['users:read', 'users:write'],
},
{
path: '/settings',
component: 'SettingsPanel',
middleware: [authMiddleware('superadmin')],
},
]);
app.use(router);
app.start(3000);
Visit http://localhost:3000 to see your admin panel running. The default credentials are admin:admin.
Authentication
Admin supports multiple authentication strategies out of the box: API keys, OAuth 2.0, SAML, and JWT-based sessions. All strategies are configurable via the auth object in your configuration file.
API Key Authentication
Include your API key in the request header for programmatic access:
GET /api/v1/dashboard HTTP/1.1
Host: api.admin.io
Authorization: Bearer sk_live_51M7x9a2K...
Content-Type: application/json
Session Management
Sessions expire after 24 hours of inactivity by default. Configure sliding expiration and secure cookie policies in admin.config.js.
API Endpoints
All API routes are prefixed with /api/v1. Below are the core resource endpoints:
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/users |
List all users with pagination |
| POST | /api/v1/users |
Create a new user account |
| PUT | /api/v1/users/:id |
Update user profile details |
| DELETE | /api/v1/users/:id |
Permanently delete a user |
All endpoints support JSON responses and return standard HTTP status codes. Check the Error Handling section for code reference.
Configuration
Admin uses a flat configuration structure. Override defaults by creating admin.config.js in your project root:
export default {
server: {
port: process.env.PORT || 3000,
host: '0.0.0.0',
cors: {
origin: ['https://myapp.com'],
credentials: true,
},
},
database: {
driver: 'postgresql',
url: process.env.DATABASE_URL,
pool: { min: 2, max: 10 },
},
security: {
rateLimit: { max: 100, window: '15m' },
csrf: true,
helmet: true,
},
logging: {
level: 'info',
format: 'json',
file: './logs/admin.log',
},
};
Never commit sensitive credentials like DATABASE_URL or API keys to version control. Use environment variables or a secrets manager.