Directus is an open-source headless CMS for managing custom SQL databases. It wraps any SQL database with GraphQL+REST APIs and an intuitive app for non-technical users.
Gabriel De Lellis
- CMS type: API
- Website: directus.io
- Founded: 2004
- Company size: 1-10 people
Last update: June 18, 2021
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.
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.
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 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.
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.*
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.
You can self-host Directus for free or use one of their cloud plans. Keep in mind that support from their core team is only available for cloud-managed projects. For everyone else (free and paid clients) there is a Discord community support channel or you could try the contact us page.
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.
- Multiple ways to try Directus for free
- Allows multiple ways of hosting: self-hosting or multiplatform hosting
- Easy to use for non-technical users
- Database history and backup
- Official video tutorials
- Good documentation
- Dynamic API reference
- All features for free tier (self-hosted)
- Access to your raw SQL database
- Can only use relational databases
- API has its particularities that you need to adapt to
- If you need very advanced filters there could be an issue where the URL can’t hold enough data to include the full query structure and there is a need to use SEARCH http method