App Extensions

Custom Modules

Modules are top-level areas of the Data Studio, navigated to from the left-hand module bar.

Modules are top-level areas of the Data Studio, navigated to from the left-hand module bar. They will load at the specified routes.

A module in Directus

The Data Studio splits up functionality into modules - the content module, the files module, the user module, the insights module, and the settings module. Extensions can add new modules to the Data Studio.

Enable the Module
For the module to appear in the module bar, the extension has to be enabled in your main project settings.

This extension type is loaded into the Directus Data Studio. They are are built with Vue 3, and can use the provided composables exported by the @directus/extensions-sdk package. Extensions can be written in JavaScript or TypeScript.

Module Entrypoint

The index.js or index.ts file exports an object that is read by Directus. It contains properties that control how a module is displayed in the module bar, the routes that exist within the module, and the actual Vue component that will be loaded.

Entrypoint Example

import { defineInterface } from '@directus/extensions-sdk'
import ModuleComponent from './module.vue';

export default defineInterface({
    id: 'custom',
    name: 'Custom',
    icon: 'box',
    routes: [
        {
            path: '',
            component: ModuleComponent,
        },
    ],
});

Properties

PropertyTypeDescription
idstringA unique identifier for this extension.
namestringThe displayed name for this panel in the Data Studio.
iconstringAn icon name from the Google Material Icons set. Supports filled and outlined variants.
colorstringA color associated with the module.
routesarrayList of routes in the module. The routes are registered as nested routes with the module's id serving as the base path.
hiddenbooleanA boolean that indicates if the module should be hidden from the module bar.
preRegisterCheckfunctionA function that receives the current user as the first parameter and the permissions of this user as the second parameter. It should return a boolean indicating success.
Unique Identifiers
The extension id must not conflict with other extensions, so consider prefixing with author name.

Route Object

The route object uses the same syntax as Vue Router, defining each route as an object.

PropertyDescription
pathThe route path without the leading slash.
componentA Vue component to be rendered for this route.

The routes array should contain a root route with an empty path, which will load at the module's base route (the value of the module's id). Dynamic portions of the path can be defined using the :param syntax.

Route Component

The module route component will be rendered in the Data Studio when the route is accessed.

<template>
    <private-view title="My Custom Module">Content goes here...</private-view>
</template>

<script>
export default {};
</script>

You can use the globally-registered private-view component to get access to Directus' page structure consisting of the module bar, navigation, sidebar, header, and the main content area. Named slots can be used to add additional content to these areas.

SlotDescription
navigationAdds content to the navigation area of the Directus interface.
title-outer:prependInserts content before the outer title container in the Directus header.
headlineDisplays a headline above the main title in the Directus header.
titleSets the main title in the Directus header. If not used, title:prepend and title:append can be used instead.
title-outer:appendInserts content after the outer title container in the Directus header.
actions:prependAdds content before the action buttons in the Directus header.
actionsDefines the main action buttons in the Directus header.
actions:appendAdds content after the action buttons in the Directus header.
splitViewRenders content in the split view area (only if the private layout has the split-view prop set to true).
sidebarPopulates the sidebar area in the Directus interface.

Using Directus Internals

To access internal systems like the API or the stores in app extensions, you can use the useApi() and useStores() composables exported by the @directus/extensions-sdk package.

Learn more about using Directus composables.

Directus UI components are globally registered, making them accessible throughout your extension without the need to import them.

Learn more about using the Directus UI library.

Using External APIs

To avoid Cross Site Request Forgery (CSRF), app extensions cannot make requests to external servers by default. A common approach to achieve this is to create a bundle containing an endpoint that makes the external request, and an app extension that uses the now-internal endpoint to retrieve data.

Learn more about building extensions through our tutorials.