CLI Commands
CLI Reference: A list of all available CLI commands for AdminForth.
Usage
To use a command, write it in format like:
pnpx adminforth <command> [...options]
For example: pnpx adminforth create-app --app-name myadmin --db "sqlite://.db.sqlite"
Commands
create-app
Create a new AdminForth application with initial project structure and configuration.
Description:
The create-app command scaffolds a brand new AdminForth application in a specified directory. The create-app command guides you through setup using command-line arguments or interactive prompts, generates the necessary configuration and project files, installs dependencies, and sets up the development environment.
Usage:
pnpx adminforth create-app [--app-name <name>] [--db <database_url>]
Options:
--app-name: The name of your new application. This becomes the project directory. Defaults toadminforth-app.--db: The connection URL for your database. Currently PostgreSQL, MongoDB, SQLite, MySQL, Clickhouse are supported. If not provided, defaults tosqlite://.db.sqlite.
Example:
pnpx adminforth create-app --app-name my-app --db sqlite://mydb.sqlite
Result:
Creates a folder my-app/ with the entire AdminForth app ready to go.
create-plugin
Scaffold a new plugin for an AdminForth application.
Description:
The create-plugin command sets up a fresh AdminForth plugin project by generating the required files, installing dependencies, and preparing the environment for local development and testing.
Usage:
pnpx adminforth create-plugin [--plugin-name <name>]
Options:
--plugin-name: The name of your new plugin. This becomes the folder name and is used in generated files. If not provided, you'll be prompted.
Example:
pnpx adminforth create-plugin --plugin-name my-awesome-plugin
Result:
Creates a folder with all the necessary files for your plugin and instructions for linking it into an AdminForth project.
generate-models
Generate TypeScript models from your AdminForth resources.
Description:
The generate-models command scans the current working directory for a valid AdminForth instance and automatically generates a TypeScript file containing model type definitions for all defined resources. The generate-models command inspects the resource columns and maps them to appropriate TypeScript types.
Usage:
pnpx adminforth generate-models [--env-file=<path>]
Options:
--env-file=<path>: (optional) Path to a custom.envfile to load environment variables. Defaults to.env.
Example:
pnpx adminforth generate-models --env-file=.env.dev
Result:
A file like this will be generated:
export type User = {
id: number;
name: string;
email: string;
};
export type Product = {
id: number;
title: string;
price: number;
};
bundle
Build the AdminForth Single Page Application (SPA) for production.
Description:
The bundle command bundles the AdminForth front-end (SPA) using your current AdminForth instance. The bundle command calls the bundleNow() method from your AdminForth admin entry point.
Usage:
pnpx adminforth bundle
Output:
The bundle command generates output files (typically JavaScript/CSS assets) in the directory configured by your AdminForth project (usually dist or public).
component
The component command is an interactive CLI tool that scaffolds and injects Vue components into your AdminForth plugin.
The component command helps you generate:
- Custom field components (
fields) - CRUD page injections (
crudPage) - Login page injections (
login) - Global UI injections (
global)
🔤 Custom Fields (fields)
The component fields flow generates components for specific fields in views such as:
listshoweditcreatefilter
The component fields flow prompts you to select a resource, then a column, and finally injects a file like:
custom/UserEmailShow.vue
The component fields flow auto-updates the config.
Usage shortcut:
pnpx adminforth component fields.show.user.email
➖ CRUD Page Injections (crudPage)
The component crudPage flow adds components to entire CRUD pages (not just fields).
The component crudPage flow supports views:
listshoweditcreate
The component crudPage flow then asks:
- Where to inject (top, bottom, dropdown, etc.)
- Optional name (e.g. "ExportButton")
- Whether the component is "thin" (coexists with existing layout)
Generated example:
custom/OrderShowBottomExportButton.vue
🔐 Login Page Injections (login)
The component login flow places a component before or after the login form.
The component login flow prompts for:
- Injection type:
beforeLoginorafterLogin - Purpose (for naming)
- Updates
index.tsautomatically
Example file:
custom/CustomLoginSocials.vue
🌐 Global Injections (global)
The component global flow injects into:
userMenuheadersidebareveryPageBottom
The component global flow asks for:
- Location
- Description (for naming)
Example:
custom/CustomGlobalSupportLink.vue