How to Create, Install, and Uninstall Apps in Frappe?
Create & Install AppMaster the essential Bench CLI commands to create new custom apps, install them on your sites, and remove them safely when no longer needed.
In the Frappe ecosystem, 'Apps' are the building blocks of functionality. Whether you are building a completely new product or extending ERPNext, you will invariably need to create an app to house your code.
Unlike standard Python packages, Frappe apps are managed via the 'bench' command-line tool, which handles scaffolding, installation on specific sites (tenants), and uninstallation. Understanding this lifecycle is critical for any Frappe developer.
1 # 1. Create a new app 2 bench new-app my_custom_app 3
4 # 2. Install the app on a specific site 5 bench --site site_name install-app my_custom_app 6
7 # 3. Uninstall the app from a site 8 bench --site site_name uninstall-app my_custom_app
Understanding This Code
What It Does
These commands allow you to manage the full lifecycle of a Frappe application. 'new-app' generates the folder structure and boilerplate code. 'install-app' runs the database migrations to create DocTypes and tables for the site. 'uninstall-app' removes the app's tables and data from the site.
When To Use
Use these commands when starting a new project, deploying a custom module to a particular site, or cleaning up unused apps to free up resources.
Prerequisites
- •A running Bench instance.
- •Access to the terminal/command line.
- •A valid site created (e.g., via 'bench new-site').
Key Concepts
Important ideas to understand in this code
Bench CLI
Bench is the command-line utility used to manage Frappe deployments. It handles everything from creating sites and apps to updating the system and running maintenance tasks.
Learn moreSites (Multi-tenancy)
Frappe supports multi-tenancy, meaning a single codebase (bench) can serve multiple websites (sites). Apps must be explicitly installed on each site where they are needed.
Learn moreApp boilerplate
When you run 'bench new-app', Frappe automatically creates a standard directory structure including setups for modules, hooks, public assets, and tests, ensuring best practices are followed from the start.
Learn moreStep-by-Step Tutorial
Follow along to understand how this code works
Create the App
Run the 'new-app' command. You will be prompted for details like the App Title and Description. This command creates a new folder in the 'apps' directory.
bench new-app library_managementInstall App on Site
Creating the app downloads the code, but doesn't activate it for any site. To use the app, install it on your target site. This process creates the necessary database tables.
bench --site my.site.name install-app library_managementVerify Installation
You can verify that the app is installed by checking the 'site_config.json' or simply listing the installed apps for the site.
bench --site my.site.name list-appsUninstall App (If needed)
If you need to remove the app and its data from a specific site, use the 'uninstall-app' command. WARNING: This will delete all data related to that app from the site's database.
bench --site my.site.name uninstall-app library_managementCommon Issues & Solutions
Troubleshoot problems you might encounter
