CLI Reference
Better Admin CLI
The Better Admin CLI is your command-line tool for managing Better Admin components. It handles installation, updates, and configuration so you can focus on building your admin interface.
What's a CLI? A CLI (Command-Line Interface) is a tool you run in your terminal. Instead of manually copying files and installing dependencies, the CLI does it all for you automatically.
Why Use the CLI?
The CLI saves you time by automating:
- ✅ Component installation
- ✅ Dependency resolution (finds what each component needs)
- ✅ shadcn/ui integration
- ✅ Configuration setup
- ✅ Version management
Without CLI: Manually copy files, install dependencies, configure imports (30+ minutes)
With CLI: Run one command (30 seconds)
Installation
The CLI comes with the better-admin package:
npm install better-adminOnce installed, you can run it with:
npx better-admin <command>Using npx: The npx command runs the Better Admin CLI without installing it globally. It's the recommended way to use the CLI.
Commands
init
Initialize Better Admin in your project.
npx better-admin initThis command:
- Creates a
better-admin.jsonconfiguration file - Sets up the components directory structure
- Configures shadcn/ui integration
Options:
npx better-admin init [options]
Options:
--components-dir <path> Components directory (default: "src/components")
--utils-dir <path> Utils directory (default: "src/lib")
--force Overwrite existing configurationExample:
npx better-admin init --components-dir app/componentsadd
Install one or more components.
npx better-admin add [component-names...]This command:
- Downloads the component from the registry
- Installs required shadcn/ui dependencies
- Installs npm dependencies
- Copies files to your project
Examples:
# Install a single component
npx better-admin add data-table
# Install multiple components
npx better-admin add data-table crud-form login-page
# Install with options
npx better-admin add data-table --forceOptions:
Options:
-f, --force Overwrite existing files
-y, --yes Skip confirmation prompts
--dry-run Show what would be installed without installinglist
List all available components.
npx better-admin listOptions:
Options:
--category <name> Filter by category
--json Output as JSONExamples:
# List all components
npx better-admin list
# List components by category
npx better-admin list --category forms
npx better-admin list --category data-display
# Get JSON output
npx better-admin list --jsondiff
Show differences between installed and registry versions.
npx better-admin diff [component-name]Examples:
# Check all installed components
npx better-admin diff
# Check specific component
npx better-admin diff data-tableupdate
Update installed components to latest versions.
npx better-admin update [component-names...]Examples:
# Update all components
npx better-admin update
# Update specific components
npx better-admin update data-table crud-formremove
Remove installed components.
npx better-admin remove [component-names...]Examples:
# Remove a component
npx better-admin remove data-table
# Remove multiple components
npx better-admin remove data-table crud-formComponent Categories
List components by category:
Authentication
npx better-admin list --category authComponents: authentication, login-page
Data Display
npx better-admin list --category data-displayComponents: data-table, list, text-field, number-field, date-field, email-field, url-field, badge-field, file-field, record-field, resource-list
Forms
npx better-admin list --category formsComponents: form, crud-form, simple-form, text-input, number-input, boolean-input, select-input, radio-button-group-input, file-input, array-input, autocomplete-input, autocomplete-array-input, reference-input, reference-array-input, filter-form, search-input, simple-form-iterator, field-toggle
Layout
npx better-admin list --category layoutComponents: admin, layout, app-sidebar, breadcrumb, list-pagination, show, simple-show-layout, create, edit, example-card
Fields
npx better-admin list --category fieldsComponents: array-field, count, input-helper-text, reference-field, reference-array-field, reference-many-field, reference-many-count, select-field, single-field-list
Buttons
npx better-admin list --category buttonsComponents: create-button, edit-button, show-button, delete-button, bulk-delete-button, bulk-export-button, export-button, cancel-button, columns-button, icon-button-with-tooltip, sort-button, toggle-filter-button, refresh-button, locales-menu-button
Feedback
npx better-admin list --category feedbackComponents: loading, spinner, error, notification, confirm
Views
npx better-admin list --category viewsComponents: list-guesser, edit-guesser, show-guesser
Toolbars
npx better-admin list --category toolbarsComponents: bulk-actions-toolbar, ready
UI
npx better-admin list --category uiComponents: theme-provider, theme-mode-toggle, user-menu, saved-queries
Configuration
The better-admin.json file stores your configuration:
{
"componentsDir": "src/components",
"utilsDir": "src/lib",
"tailwind": {
"config": "tailwind.config.js",
"css": "src/app/globals.css"
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}Workflow Examples
Setting Up a New Project
# 1. Initialize better-admin
npx better-admin init
# 2. Install authentication
npx better-admin add authentication login-page
# 3. Install core layout
npx better-admin add layout app-sidebar
# 4. Install data components
npx better-admin add data-table crud-form
# 5. Install utility components
npx better-admin add loading error notificationBuilding a CRUD Interface
# Install CRUD components
npx better-admin add data-table crud-form create-button edit-button delete-button
# Install view components
npx better-admin add show simple-show-layout
# Install feedback components
npx better-admin add confirm notificationAdding Forms
# Basic form components
npx better-admin add form simple-form
# Input components
npx better-admin add text-input number-input boolean-input select-input
# Advanced inputs
npx better-admin add autocomplete-input reference-input file-input array-inputSetting Up Lists
# List components
npx better-admin add list data-table list-pagination
# Filter and search
npx better-admin add filter-form search-input toggle-filter-button
# Bulk actions
npx better-admin add bulk-actions-toolbar bulk-delete-button bulk-export-buttonTroubleshooting
Component Not Found
Error: Component 'xyz' not found in registrySolution: Check available components:
npx better-admin listDependency Conflicts
Warning: Dependency conflict with existing versionSolution: Use --force to overwrite:
npx better-admin add data-table --forceMissing Configuration
Error: better-admin.json not foundSolution: Initialize first:
npx better-admin initBest Practices
1. Install Components as Needed
Don't install all components at once. Install only what you need:
# Good: Install specific components
npx better-admin add data-table crud-form
# Avoid: Installing everything2. Use Categories
Filter by category to find related components:
npx better-admin list --category forms3. Check Updates Regularly
Keep components up to date:
npx better-admin diff
npx better-admin update4. Customize After Installation
Components are copied to your project, so customize them:
// Customize installed component
import { DataTable } from "@/components/admin/data-table";
export function CustomDataTable(props) {
return <DataTable {...props} className="custom-styles" />;
}Integration with Package Managers
npm
npx better-admin add data-tablepnpm
pnpm dlx better-admin add data-tableyarn
yarn dlx better-admin add data-tablebun
bunx better-admin add data-tableCI/CD Integration
GitHub Actions
name: Update Components
on:
schedule:
- cron: '0 0 * * 0' # Weekly
jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: npm install
- run: npx better-admin update
- uses: peter-evans/create-pull-request@v5
with:
title: "Update better-admin components"Next Steps
- Components - Browse all components
- Quick Start - Get started quickly
- Examples - View example applications