Umbraco Extension Template
Use the `umbraco-extension` .NET template to create a new Umbraco extension.
Last updated
Was this helpful?
Use the `umbraco-extension` .NET template to create a new Umbraco extension.
Last updated
Was this helpful?
Umbraco provides a .NET template to help you get started with building extensions for the Umbraco backoffice. This template sets up a new project with all the necessary files and configurations to build an extension. The template is called umbraco-extension
and can be used to create a new Umbraco extension project with a single command.
version 9.0 or later
version 22 or later
To install the Umbraco extension template, run the following command in your terminal:
This command installs both the umbraco
and umbraco-extension
templates, which you can use to create new Umbraco and Umbraco extension projects. If a new Umbraco project has previously been created using dotnet new umbraco
, the templates may already be installed.
To create a new Umbraco extension project, run the following command in your terminal. It should be executed in a folder where you want to create the new project, for example in the root of your solution:
This command creates a new folder called MyExtension
with the following files and folders:
MyExtension.csproj
: The project file for the extension.
Constants.cs
: A file containing constants for the extension.
Client
: A folder containing the source code for the extension, a package.json
file, a tsconfig.json
file, and the vite.config.ts
configuration file.
README.md
: A readme file with instructions on how to build and run the extension.
The -ex
flag indicates that you want to include examples of how to use the extension. This flag is optional, but it is recommended to include it if you are new to building extensions for Umbraco. It will additionally give you:
Composers
: A folder containing an example composer that registers a custom Swagger API.
Controllers
: A folder containing an example API controller for a dashboard.
Client/src/api
: A folder containing an example API client that calls the API controller.
Client/src/dashboards
: A folder containing an example dashboard Web Component that uses the API client.
After setup, the dashboard appears in the main Content section of the Backoffice.
To include the extension in your Umbraco project, you need to add a reference to the extension project in your Umbraco project.
Right-click the Dependencies node in the Umbraco project.
Select Add Reference.
Choose the MyExtension
project.
Click OK.
Run the following command in the root folder of your Umbraco project:
This command adds a reference to the MyExtension
project in your Umbraco project. You can then build your Umbraco project and see the extension in action.
To build and run the extension, install the dependencies and start the Vite development server. To do this, run the following commands in the Client
folder of your extension project:
This command compiles the TypeScript files and copies them over to the wwwroot
output folder. Once complete, run the Umbraco project to view the extension in action.
The output files are automatically copied to the wwwroot
folder of your Umbraco project. They are also included in the publishing process when you publish your Umbraco project. You can publish your Umbraco project using the following command:
To publish your extension as a package, create a NuGet package. Run the following command in the root folder of your extension project:
This command creates a NuGet package in the bin/Release
folder of your extension project. You can then publish this package to a NuGet feed or share it with others.
The umbraco-extension
template is opinionated until a certain point. It is a starting point for building extensions for the Umbraco backoffice. The template includes a basic structure and configuration for building extensions, but you can customize it to fit your needs. You can add additional files, folders, and configurations as needed.
To install this template, run the following command in your terminal:
To create a new package project, run the following command:
To publish your extension as an Umbraco Package, you need some additional files. For details, see the article.
Another option is to use the . This is a template that includes all the files and configurations needed to build an Umbraco package. It builds on top of the umbraco-extension
template and includes additional files and configurations for building Umbraco packages. This template is a great starting point for building Umbraco packages and includes everything you need to get started.