Directus

Directus Review and Features

Written by Gabriel De Lellis

Last update: 6/11/2024

User interface

One of the things that I really like about the Directus interface is how easy it is to personalize. You have control over how the data is presented and whether it is editable or not.

To give you a better understanding of the dashboard and the feeling of the UI I will show a few actions inside. Let's start with project setup.

The project settings section is where we would set our project’s basic info (name, color, logo, etc.). It is also possible to set the minimum requirement for our users’ passwords.

Data Modeling

Here is where we create our Collections (database tables) and Fields (database columns)

To create collection, do those things:

  • Set the collection name in the Name field option.
  • Next, there is this Singleton field option, when selected the user can only create one item in this collection, this is useful for creating pages that are unique like a reviews page, about us page.
  • Set the Primary Key Field name and the type which could be Auto-incremented Integer, Generated UUID or a Manually entered string.
  • After these fields are created we are presented with Optional System Fields which are actually very useful, your classics, Created On, Created By, Updated On, Updated By, and two which are more Directus specific there is Status which can give you the option for soft delete and Sort which enables drag and drop reordering.

Creating fields

After configuring our collection (remember collections are database tables) we can add fields (database columns) to it.

To create a field we have to give it a Key, type a length, if we want we can then add default value if the field can be NULL and whether it has to be unique.

Here is where Directus gets awesome, after setting the field’s Schema we begin to set the Field in the interface, we can set if it’s Readonly if it’s hidden, add a Note and add a Field Name Translations we can use this instead of the field name in the database.

The Interface section will let us set how the users interact with this specific field, you can select one option that Directus gives you however there is the possibility to use custom interfaces.

And finally, the display section which as the title states this is how the field’s value should be displayed, again Directus gives you a lot of options.

Directus API

Directus API offers both RESTful and GraphQL there are no functional differences between the two endpoints. Which one you choose ultimately depends on your needs.

By default, all data in the system is off-limits for unauthenticated users. You must include an access token for each request or set the permissions for the public role.

Retrieving data

Directus only retrieves the fields that you explicitly request, you can retrieve nested data by using the fields parameter in REST or the regular nested queries in GraphQL.

Here is an example of the fields parameter in the REST API taken from Directus Docs, you can use a wildcard(*) to include all fields at a specific depth.

?fields=title,body,featured_image.*

// or

?fields[]=title
&fields[]=body
&fields[]=featured_image.*

Deleting Relational Data

When deleting data from your database Directus won’t actually delete it. Instead, the foreign key will be nullified. This means that your data will not disappear but you will end up with orphaned items.

Pricing and Support

You can self-host Directus or use one of their cloud plans.

Keep in mind that support from their core team is only available on Professional and Enterprise plans. For everyone else (free and paid clients) there is a Discord community support channel or you could try the contact us page.

Directus Pros and Cons

Directus is a great option when your project will use a relational database. It supports all SQL databases out of the box, an easy-to-use interface, and excellent documentation. Finally, it is open-source and modularized which allows for extending and overriding its functionalities.

[@portabletext/react] Unknown block type "prosCons", specify a component for it in the `components.types` prop