Application scaffolding
Application scaffolding is the create-frappe-ui command-line workflow for starting a Vue application with Frappe UI, Vite, TypeScript, Tailwind CSS, and a ready-to-edit page. It creates either a frontend inside a Frappe app or a standalone Vite app, then connects the generated project to the right development and build path.
Scaffold purpose
The command gives an engineer a safe starting point instead of a blank Vue project. It selects a project shape, fills in the app name and route, prepares the files needed by that shape, and reports the next commands to run.
The package is published as create-frappe-ui, and the normal entry command is:
npm create frappe-ui@latest
It requires Node 20.19 or later. The generated project starts with the same frappe-ui release as the scaffolding package, so the starter files and the UI package begin with a matched version.
Command workflow
The command moves from context detection to project choice, safety checks, file creation, optional dependency installation, and next-step guidance. The following flow shows the main decisions.
flowchart TD
A[Run create-frappe-ui] --> B[Detect package manager]
B --> C[Detect Frappe app context]
C --> D{Choose template}
D -->|Frappe| E[Validate app folder and route]
D -->|Standalone| F[Use standalone project folder]
E --> G[Plan Frappe app changes]
F --> H[Check target folder]
G --> H
H --> I[Confirm planned changes when needed]
I --> J[Copy shared and selected template files]
J --> K[Install dependencies or show install command]
K --> L[Show development and build next steps]
Input and defaults
The command accepts one project folder and a small set of options. In a terminal it asks for missing values; in non-interactive use it applies defaults. --yes selects those defaults but does not approve writing into a non-empty folder.
| Input | Frappe app default | Standalone default |
|---|---|---|
| Project folder | frontend directly inside the detected app | my-app |
| Template | frappe when run in an app | standalone when no app is detected |
| Route | /<app-name> | Not used |
| Dependency install | Confirmed in an interactive terminal | Confirmed in an interactive terminal |
The command checks the target before it writes. It can add a project to a non-empty folder only after confirmation, and it never silently replaces an existing target in non-interactive mode. A Frappe route must use simple path segments and cannot use routes already owned by Frappe, such as /api, /app, or /login.
References: packages/…/cli.js• L28-45 packages/…/cli.js• L75-159 packages/…/cli.js• L339-370 packages/…/frappe.js• L28-107
Package-manager handling
The command follows the package manager that launched it. It recognizes npm, Yarn, pnpm, and Bun, and uses the matching install and script syntax for the generated project.
This choice also matters to a Frappe app because the app-level scripts call into the frontend. npm and Yarn are normally available to bench, while pnpm or Bun must also be available on any system that installs or builds the app. If installation is skipped or fails, the command prints the matching install command instead of leaving the next step ambiguous.
References: packages/…/packageManager.js• L4-25 packages/…/packageManager.js• L38-57 packages/…/cli.js• L175-249 packages/…/frappe.js• L199-249
Template selection
The two templates share a Vue application foundation, but they connect that foundation to different runtimes. The Frappe template serves a frontend from a Frappe app; the standalone template keeps the app independent from a Frappe server.
For the template-specific file set and the choices each template makes, see Scaffold templates. The generated files become the integration points described in Generated application integration points.
Frappe application template
The Frappe template is for a project created from an app folder such as apps/todo. The command finds the app from its Python package and hooks.py, then creates the frontend as a direct child of that app.
The scaffold connects the frontend to the app in four ways:
- A Python page provides the frontend entry page and exposes boot data such as the CSRF token and logged-in user.
- A
website_route_rulesentry sends every path below the chosen route to that page. - The app-level package.json gains scripts for frontend install, development, and production build.
- The app
.gitignoreskips the frontend build output written into the app.
The route is shared by the Frappe Vite setup and the Vue router. During development, the Frappe-aware Vite integration proxies the bench; during a build, it places the output in the app locations used by Frappe. Existing route rules and compatible build setup remain unchanged. When an existing file cannot be edited safely, the command shows the lines that an engineer must merge by hand.
References: packages/…/README.md• L13-34 packages/…/cli.js• L128-157 packages/…/frappe.js• L145-194 packages/…/frappe.js• L199-290 packages/…/vite.config.ts• L1-9 packages/…/router.ts• L1-10
Standalone application template
The standalone template is for a plain Vite application. It suits a prototype, a static site, or a frontend that talks to a backend other than Frappe.
It keeps the shared UI and build setup, but turns off the Frappe-server parts of the Vite integration. Its router uses the site root as its history base, and its starter page demonstrates local UI behavior rather than a server call. The command does not inspect or modify a Frappe app when this template is selected.
References: packages/…/README.md• L36-37 packages/…/cli.js• L101-126 packages/…/vite.config.ts• L1-12 packages/…/router.ts• L1-9 packages/…/Home.vue• L1-69
Generated application structure
Every generated project starts with a shared base and then applies one template layer. A file from the selected layer can replace the shared version, while the remaining base files stay common to both application types.
Shared application foundation
The shared foundation provides the basic Vue runtime, route outlet, styling entry, Tailwind setup, and fallback page. The application mounts App.vue, loads the router and stylesheet, and places the routed page inside FrappeUIProvider and DesktopShell.
The main integration points are:
| Area | Purpose |
|---|---|
| src/main.ts | Starts Vue and mounts the application. |
| src/App.vue | Provides Frappe UI context and the application shell. |
| src/router.ts | Defines the home route and not-found route. |
| src/…/Home.vue | Starter page that the engineer replaces with product work. |
| src/…/NotFound.vue | Fallback for unknown routes. |
| src/style.css | Loads the Frappe UI stylesheet. |
| tailwind.config.js | Loads the Frappe UI preset and scans app source. |
| vite.config.ts | Joins Vue support with the selected Frappe UI Vite mode. |
The starter package also includes TypeScript, PostCSS, Tailwind CSS, Vue Router, Vite, and Vue type checking. Its scripts expose the common development, build, and type-check actions without imposing product-specific business code.
References: packages/…/scaffold.js• L8-19 packages/…/scaffold.js• L27-50 packages/…/scaffold.js• L54-82 packages/…/main.ts• L1-6 packages/…/App.vue• L1-13 packages/…/style.css• L1 packages/…/tailwind.config.js• L1-7 packages/…/tsconfig.json• L1-18 packages/…/package.json• L1-28
Frappe integration points
The Frappe project structure adds the boundary between the Vue frontend and the Frappe app. The frontend lives in its own folder, while the app-level page, route rule, build scripts, and ignored output let Frappe serve and deploy it as part of the app.
The generated home page is a connectivity check as well as a starter screen. It reads boot data, calls a Frappe method, and gives the engineer a working example of the request path that the new application can extend.
References: packages/…/Home.vue• L1-22 packages/…/Home.vue• L24-107 packages/…/frappe.js• L303-315 packages/…/frappe.js• L318-389
Standalone integration points
The standalone project structure keeps the same UI shell and route model without the Frappe app boundary. Its home page demonstrates an application-owned interaction and links to the Frappe UI documentation, so an engineer can replace it with site or service-specific behavior.
References: packages/…/package.json• L1-29 packages/…/Home.vue• L1-69 packages/…/vite.config.ts• L5-12
Related build paths
Scaffolding creates the first Vite configuration that an application will extend. Read Vite plugins and generators for the broader Frappe-aware Vite services, and VitePress integration for the separate documentation-site path.
The scaffold is therefore a starting contract, not a complete application architecture. Product code owns its pages and data rules, while the generated route, build, style, and server boundary keep the application connected to its chosen runtime.
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the
create-frappe-uiversion aligned with thefrappe-uiversion used in generated package.json files. - Keep the Frappe route value aligned across the Vite frontend route, Vue history base, generated Python page, and
website_route_rulesentry. - Keep package-manager command syntax aligned between the CLI's install guidance and the Frappe app-level
postinstall,dev, andbuildscripts. - Keep the template overlay rules aligned with the file list shown when a target folder already contains scaffold files.
- Keep the generated Tailwind content paths paired with the Frappe UI preset content contract.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The Frappe template runs outside a detected app | The command stops before it creates a frontend because it cannot connect the project to an app. | Run it from the app folder, such as apps/todo, or select the standalone template. |
| The Frappe frontend folder is not directly inside the app | The generated root scripts and app build path would point to an unsupported location. | Use a direct child folder such as frontend. |
| The chosen route uses a Frappe-owned path | Frappe handles the request before the frontend route can load. | Choose a non-reserved route such as /todo or /my-app. |
| An existing app package.json has no compatible frontend build entry | Bench can install the app but does not build the frontend during deployment. | Merge the printed postinstall, dev, and build entries into the app package scripts. |
| pnpm or Bun is used but is missing on the build server | App install or build scripts fail even though local development works. | Install the same package manager on every system that builds the Frappe app. |
| A Frappe route is changed in only one generated location | Client history, development proxying, and server routing disagree. | Update the route as one cross-file contract. |
Key files
| File | Why to read it |
|---|---|
| packages/…/README.md | Gives the user-facing command, template choices, safety rules, and package-manager expectations. |
| packages/…/cli.js | Shows the end-to-end command flow and its user-facing decisions. |
| packages/…/scaffold.js | Explains how the shared base and selected template become the generated project. |
| packages/…/packageManager.js | Defines package-manager detection and command forms. |
| packages/…/frappe.js | Defines Frappe app discovery, route checks, app changes, and bench-facing setup. |
| packages/…/App.vue | Shows the common application shell and Frappe UI provider boundary. |
| packages/…/vite.config.ts | Shows the Frappe-connected Vite starting point. |
| packages/…/vite.config.ts | Shows the server-independent Vite starting point. |
| packages/…/Home.vue | Shows the generated Frappe boot-data and server-call example. |
| packages/…/Home.vue | Shows the generated standalone interaction example. |