Introducing a new way to review your PRs.

Read the announcement

frappe / frappe-ui

The all-in-one toolkit for modern frontends. High-quality components, app recipes and AI-ready docs.

View on GitHub

28 documents · Updated Nov 23, 2026

docs / build-and-framework-integration

Build and framework integration

Frappe UI connects a Vue application to the Frappe bench through its package contract, Vite integration, and project scaffolder. The integration gives an app a consistent development server, Frappe-aware production output, optional DocType types, boot data in the browser, and small development aids without changing the app's main UI code.

Integration model

The package exposes normal Vue library entry points, a separate frappe-ui/vite entry point, and a frappe-ui/vitepress entry point. An application adds the Vite entry point to its own Vite configuration so development and production can use the same Frappe-aware build rules. See Vite plugins and generators for the detailed plugin and generator contracts. See VitePress integration for the documentation-site build path. See Application scaffolding for the path that creates a Frappe UI application around these integrations.

Plugin bundle

The main Vite entry point groups several related services behind one configuration function. Most services are on by default. Lucide icon auto-imports and DocType type generation are opt-in, while code-language handling is enabled by default. DocType type generation needs an app-to-DocType input map.

The top-level frontendRoute is a shared app identity. It gives the development server a route for site links and gives the production build enough information to infer the HTML file that Frappe serves.

References: vite/index.js• L10-53 vite/index.d.ts• L126-181 package.json• L75-125

Package contract

The package contract separates runtime code from build support. The root runtime entry is a curated public surface for application setup, data access, UI components, composables, directives, and utilities. The package also exposes separate editor, list, chart, icon, Tailwind, Vite, and VitePress entry points. See src/index.ts• L1-21 for the runtime setup and transport boundary.

The published contract also exposes the documentation build through the frappe-ui/vitepress export. Its type, Node, and default targets let documentation tooling load the integration in the runtime it needs. This separation keeps build-time tools out of normal browser imports and lets an app use one Vite service, such as the icon resolver, without adopting the full plugin bundle.

Applications and the scaffolding command use Node 20.19 or later. The create-frappe-ui package publishes a command that starts from the same release version as frappe-ui, so generated projects can use the matching package contract.

References: src/index.ts• L1-21 src/index.ts• L23-187 package.json• L6-8 package.json• L50-134 packages/…/package.json• L1-30 vite/index.d.ts• L184-210

Application scaffolding

The create-frappe-ui command creates a Vue, TypeScript, Vite, and Tailwind project with a starter page. It supports a standalone project and a frontend inside a Frappe app, so the same command can establish either a browser-only project or the connection between a frontend and a bench.

Project templates

The scaffolder combines shared base files with one template-specific layer. The standalone template creates a normal Vite app with no Frappe server. The Frappe template adds the route, boot-data page, and build settings needed to serve the frontend through a Frappe app. It fills project names, titles, package versions, and routes before writing the files.

References: packages/…/README.md• L9-37 packages/…/scaffold.js• L8-19 packages/…/scaffold.js• L32-69 packages/…/cli.js• L101-126

Frappe app connection

For a Frappe template, the command plans the surrounding app changes before it writes them. The changes give Frappe a page that supplies boot values, a route rule that sends paths to the frontend, root scripts that let bench install and build the frontend, and ignore rules for generated output. Existing files are kept when they already contain the needed contract; unsafe edits are shown for manual action.

The command uses the package manager that invoked it and can install dependencies after it writes the project. It also reports the site and development URL that connect the generated frontend to a running bench.

The following diagram shows how scaffolding connects a new frontend to the Frappe build and serve path.

flowchart LR
    A[create-frappe-ui] --> B[Frontend project]
    A --> C[Frappe page and route]
    A --> D[Bench install and build scripts]
    B --> E[Vite development server]
    C --> F[Frappe site]
    D --> G[Production build]
    E --> F
    G --> F

References: packages/…/cli.js• L128-207 packages/…/frappe.js• L145-194 packages/…/frappe.js• L199-230 packages/…/frappe.js• L269-315

Development integration

The development path keeps the browser connected to a live Frappe site while Vite serves the front end. It also reduces the work needed to import library components and gives an engineer useful site URLs when the server starts.

Backend proxy

The Frappe proxy sends selected browser requests from the Vite server to the Frappe web server. It covers application, login, API, asset, file, private, and desk paths, and it keeps WebSocket traffic available for services that need it.

The proxy finds the bench from the working directory. It reads the web server port from FRAPPE_WEB_SERVER_PORT or common_site_config.json, then derives a Vite port when the caller does not set one. The request host selects the Frappe site, so one development server can work with the sites installed for the app.

References: vite/frappeProxy.js• L3-49 vite/utils.js• L11-36 vite/utils.js• L67-101

Development tooling

The Vite bundle improves the development loop without changing the public component API. It can resolve Lucide icons as Vue components, rewrite named imports from the library barrel into focused module imports during development, keep optional CodeMirror language packages from blocking the library build, and print URLs for sites where the current app is installed.

These services have different roles. Icon support helps templates name icons directly. Import rewriting keeps a working copy from pulling the full library graph into the browser. Code-language handling lets an app install only the language packages that it needs. The site banner turns the active Vite port and installed site list into ready-to-use app URLs. The icon and import details are covered in Vite plugins and generators.

References: vite/lucideIcons.js• L7-28 vite/barrelImports.js• L7-30 vite/siteBanner.js• L3-40 vite/codeLanguages.js• L42-145 vite/index.js• L14-48

Code language dependencies

The code-language integration allows frappe-ui/code-editor to work with only the optional @codemirror/lang-* packages that an app installs. If the editor later requests a language that is not installed, the browser receives a clear missing-package error instead of the build or development server failing before the app starts.

The integration applies to both production builds and Vite's development dependency preparation. It only protects the language imports owned by frappe-ui; an application's own direct import still requires that application to install the package itself. The supported package set must stay aligned with the languages exposed by the code editor.

References: vite/codeLanguages.js• L45-61 vite/codeLanguages.js• L87-145 vite/codeLanguages.js• L148-205 vite/codeLanguages.test.ts• L85-122 vite/codeLanguages.test.ts• L218-289

Development route

When frontendRoute is set, the bundle defines the same route for application code and uses it when it prints site links. This gives the app one route value at the build boundary instead of making the development banner and client code choose separate values.

References: vite/index.js• L97-107 vite/index.js• L48-50 vite/siteBanner.js• L22-31

Production build integration

The production path translates Vite's browser build into the directory and URL shape expected by a Frappe app. It places compiled assets in the app's public area, gives those assets a Frappe asset base URL, and copies the entry HTML to the app's web-serving area.

Build output

The build configuration can infer the output directory and asset URL from a standard Frappe app layout. An app can override these values when its layout differs. The build clears the output directory by default and leaves source-map generation off by default because source maps increase build cost.

In a production build, indexHtmlPath is required. The integration can infer it from frontendRoute and the current app name. The copied HTML is the file Frappe serves, while the compiled assets remain under the public asset path.

References: vite/buildConfig.js• L5-34 vite/buildConfig.js• L36-89 vite/buildConfig.js• L94-139 vite/index.d.ts• L88-117

Asset serving

The asset base URL connects browser references in the built HTML to Frappe's asset server. It normally follows the app name and the public subdirectory, which lets an app build in its Frappe app directory without hard-coding a separate asset path in its source.

The output directory and base URL form one contract. If an app changes one manually, it must keep the other aligned with the URL under which Frappe serves the files.

The following diagram shows how an application's source becomes a Frappe-served page and asset set.

flowchart LR
    A[Vue application source] --> B[Vite production build]
    B --> C[Public asset directory]
    B --> D[index.html]
    D --> E[Frappe web-serving directory]
    C --> F[Frappe asset URL]
    E --> G[Application route]
    F --> G

References: vite/buildConfig.js• L23-34 vite/buildConfig.js• L50-58 vite/buildConfig.js• L102-139

Frappe data integration

The integration carries two kinds of Frappe-owned data into the front end. DocType JSON becomes optional TypeScript shape information for application code. Server-side boot context becomes browser globals in the production page.

Generated DocType types

The type generator turns selected DocType definitions from the bench's installed apps into TypeScript interfaces. An application declares the source app names and DocType names, then receives a generated file at a chosen output path.

Generation runs as a separate process during development. It finds the requested DocType JSON, follows table relationships when needed, and updates interfaces only when the source modification value changes. The generated types describe common Frappe document fields and distinguish regular documents from child documents.

Type generation is a development aid rather than a runtime data check. It improves editor and compiler feedback, but the server response remains the source of truth at run time.

References: vite/frappeTypes.js• L9-69 vite/generateTypes.js• L10-49 vite/doctypeInterfaceGenerator.js• L22-45 vite/doctypeInterfaceGenerator.js• L87-194

Boot data

The boot-data integration transfers values prepared by a Frappe page handler into the browser. During a production build it adds a Jinja block to the generated HTML. When Frappe renders that page, each key in the boot context becomes a property on window.

This path suits values that the app needs before its normal requests begin, such as the current user or CSRF information. The page handler must populate context.boot; the build integration only creates the bridge from that context to the page.

References: vite/jinjaBootData.js• L1-22 vite/README.md• L162-190 vite/index.d.ts• L120-124

Integration choices

An application can use the bundled integration or select individual services. The right choice depends on whether the app needs a complete Frappe development and build path or only one focused capability.

NeedEntry or optionResult
Standard Frappe Vue development and production flowfrappe-ui/vite default pluginProxy, build output, boot data, icon support, import handling, code-language handling, and site links
Frappe API and site access during local developmentfrappeProxyVite requests reach the selected Frappe site
Type-safe access to selected DocTypesfrappeTypes with an input mapGenerated TypeScript interfaces
Server values available at page startjinjaBootDataFrappe boot keys appear on window in production
Frappe asset and HTML layoutbuildConfigAsset base path and Frappe-served entry HTML
Only component-based Lucide resolutionlucideIconsPlugin~icons/lucide/<name> imports without the full auto-import setup
Code editor with a selected set of language packagescodeLanguagesMissing optional language packages do not block the Frappe UI build or dev server
A working-copy development import graphbarrelImportsNamed library imports resolve to their declaring modules in dev

Pass false to disable a bundled service or pass an options object to change its behavior. frappeTypes is different: it is off until an options object supplies the required input map. codeLanguages is enabled by default and can be disabled only when the app accepts responsibility for installing every language package that the editor can load.

References: vite/index.js• L10-61 vite/index.d.ts• L126-182 vite/README.md• L39-54

Change checklist

When these files or sections are changed, remember to consider these:

  • When frontendRoute changes, check the development site URLs, the client route definition, and the inferred production HTML path together.
  • When the Frappe app directory or public asset layout changes, check automatic app discovery, outDir, the asset base URL, and indexHtmlPath.
  • When proxy route coverage changes, check API, asset, file, login, desk, private, and WebSocket requests as one backend access contract.
  • When DocType names or fields change, check the input map, generated output path, related child DocTypes, and the source modification marker.
  • When boot data changes, check both the server context.boot keys and the browser globals consumed before application startup.
  • When a Vite sub-plugin is disabled or split out, check its typed package export and the default bundle behavior.
  • When a library export or declaring module moves, check barrel-import mapping and the public package export that consuming apps use.
  • When a code-editor language is added or removed, check the optional package set, the language loader, and both build and dependency-preparation paths.
  • When the curated root runtime exports change, check the package entry contract and the import paths used by consuming applications.
  • When the VitePress entry or documentation commands change, check the package export and the documentation-site configuration together.
  • When the frappe-ui or create-frappe-ui version changes, keep their release versions aligned and check the generated project's dependency range.
  • When scaffolding templates or Frappe app edits change, check the generated route, boot page, bench scripts, package-manager commands, and ignored build output as one setup contract.
  • When the Node engine or scaffolder dependencies change, check both package manifests and the lockfile used to install the CLI.

Important failure modes

TriggerConsequenceGuard
A production build has no usable indexHtmlPath or frontendRouteThe build cannot identify the HTML file that Frappe must serveSet buildConfig.indexHtmlPath or provide frontendRoute in a standard app layout
The asset base URL does not match the public output directoryThe page loads with missing JavaScript or CSS assetsKeep outDir and baseUrl aligned with Frappe's asset path
The Vite server uses the wrong Frappe web-server portAPI, page, asset, or WebSocket requests reach the wrong serviceCheck FRAPPE_WEB_SERVER_PORT and common_site_config.json before overriding port
A requested DocType is not in the configured app or cannot be foundIts interface is not generated and typed application code loses that contractKeep the input map tied to installed app and DocType names
Boot values are not placed in context.bootExpected browser globals are absent from the production pagePopulate the boot context in the Frappe page handler
codeLanguages is disabled while an optional language package is not installedThe code editor's language import can stop the build or Vite dependency preparationKeep the integration enabled or install every language package that the loader can reach
A library export is not mapped by the development import rewriteThe import stays on the public barrel and may retain the larger dev graphKeep public exports as resolvable re-exports and use the bundled production path for builds
A Lucide name is missing from the icon packThe page renders a visible placeholder instead of the requested iconUse a supported icon name or replace it with an SVG asset
A root runtime export is removed or moved without a package contract updateConsumers cannot resolve an import that was part of the main library surfaceKeep the curated root entry and published export map aligned
The VitePress entry is not published with its required runtime conditionsDocumentation tooling cannot load the integration through the package nameKeep the VitePress export's type, node, and default targets aligned
A Frappe scaffold does not update the app route or root build scriptThe generated frontend exists but Frappe does not serve or build itReview the planned app changes and merge any manual snippets before deployment
The scaffolder runs in the wrong folder or uses a reserved routeThe command cannot connect the project to the intended app or conflicts with Frappe-owned pathsRun it inside the app folder and use a valid non-reserved route
frappe-ui and create-frappe-ui use different release versionsA generated project can start with a dependency contract that does not match the CLIRelease both packages at the same version and verify the lockfile

Key files

FileWhy to read it
vite/README.mdShort consumer guide for configuring the Frappe Vite integration
vite/index.jsComposition point for default services and shared options
vite/index.d.tsTyped public contract for application Vite configurations
src/index.tsCurated runtime package surface used by consuming Vue applications
vite/frappeProxy.jsDevelopment connection between Vite and Frappe sites
vite/buildConfig.jsProduction asset output, URL base, and HTML placement rules
vite/jinjaBootData.jsProduction bridge from Frappe boot context to browser globals
vite/frappeTypes.jsDevelopment entry point for DocType type generation
vite/generateTypes.jsBench lookup and generator process boundary
vite/doctypeInterfaceGenerator.jsDocType schema-to-interface contract and change detection
vite/utils.jsBench, site configuration, app identity, and installed-site discovery
vite/siteBanner.jsDevelopment URLs for installed Frappe sites
vite/barrelImports.jsDevelopment-only import graph reduction for working copies
vite/codeLanguages.jsOptional CodeMirror language handling for builds and development dependency preparation
vite/codeLanguages.test.tsEnd-to-end checks for missing and installed language packages across build and development paths
vite/lucideIcons.js and vite/lucideIconsPlugin.jsFull and resolver-only icon integration choices
packages/…/README.mdUser-facing scope, templates, and release contract for application scaffolding
packages/…/cli.jsScaffolding flow, project choices, app checks, and next steps
packages/…/frappe.jsFrappe app discovery and the page, route, script, and ignore-file contract
packages/…/scaffold.jsTemplate composition and project value substitution
packages/…/package.jsonPublished scaffolder command, Node engine, and dependency contract
packages/…/package-lock.jsonLocked install graph for the scaffolder package
package.jsonPackage exports, VitePress commands, public files, and build and development commands