The Backoffice Entry Point extension type is used to run some JavaScript code at startup.
This manifest declares a single JavaScript file that will be loaded and run when the Backoffice starts. In other words this can be used as an entry point for a package.
The backofficeEntryPoint extension is also the way to go if you want to load in external libraries such as jQuery, Angular, React, etc. You can use the backofficeEntryPoint to load in the external libraries to be shared by all your extensions. Additionally, global CSS files can also be used in the backofficeEntryPoint extension.
See also the App Entry Point article for a similar extension type that runs before the user is logged in.
Register a Backoffice Entry Point in the umbraco-package.json manifest
umbraco-package.json
{
"name": "Name of your package",
"alias": "My.Package",
"extensions": [
{
"type": "backofficeEntryPoint",
"alias": "My.EntryPoint",
"js": "/App_Plugins/YourFolder/index.js"
}
]
}
Base structure of the entry point file
All examples are in TypeScript, but you can use JavaScript as well. Make sure to use a bundler such as Vite to compile your TypeScript to JavaScript.
index.ts
import type { UmbEntryPointOnInit } from '@umbraco-cms/backoffice/extension-api';
/**
* Perform any initialization logic when the Backoffice starts
*/
export const onInit: UmbEntryPointOnInit = (host, extensionsRegistry) => {
// Your initialization logic here
}
/**
* Perform any cleanup logic when the Backoffice and/or the package is unloaded
*/
export const onUnload: UmbEntryPointOnUnload = (host, extensionsRegistry) => {
// Your cleanup logic here
}
The onUnload function is optional and can be used to perform cleanup logic when the Backoffice and/or the package is unloaded.
Examples
Register additional UI extensions in the entry point file
index.ts
import type { UmbEntryPointOnInit } from '@umbraco-cms/backoffice/extension-api';
const manifest: UmbExtensionManifest = {
type: '', // type of extension
alias: '', // unique alias for the extension
elementName: '', // unique name of the custom element
js: '', // path to the javascript resource
meta: {
// additional props for the extension type
}
};
export const onInit: UmbEntryPointOnInit = (host, extensionsRegistry) => {
// Register the extension
extensionRegistry.register(manifest);
}
export const onUnload: UmbEntryPointOnUnload = (host, extensionsRegistry) => {
// Unregister the extension (optional)
extension.unregister(manifest);
}
If you only need to register extensions, then consider using a bundle type instead.
Register global CSS
An entry point is a good place to load global CSS files for the whole application. You can do this by creating a link element and appending it to the head of the document:
Alternatively, you can import the CSS file directly in your JavaScript file:
index.ts
import '/App_Plugins/YourFolder/global.css';
Type IntelliSense
It is recommended to make use of the Type intellisense that we provide.
When writing your Manifest in TypeScript you should use the Type UmbExtensionManifest, see the TypeScript setup article to make sure you have Types correctly configured.