You may have already searched "Directus vs Strapi" on Google, and what a surprise: you got nothing relevant. You know why ? These "articles" are either written by a 2$/hour paid third-world country citizen, or a dumbass A.I like Jasper.
But don't worry, this article is written by a real developer (me) who really used these two tools.
Also, I'm not in a partnership or whatsoever with Directus. I'm just giving my raw personal opinion.
Strapi and Directus are both headless CMS. If you don't know what it means, check this article. They both provide an API (REST & GraphQL), an admin web-app to manage your content and a bunch of stuff.
Directus supports 6 DB clients:
Strapi supports only 4:
- MongoDB not anymore since v4, who uses Mongo anyway lol
Strapi's architecture is based on local files: collections models, life-cycle hooks... everything is declared in configuration files. So, when you bootstrap a Strapi project, you have this structure.
Directus stores everything in the database except for custom plugins (hooks, app mods, endpoints...). This is what your Directus project looks like at initialization:
Which one is better ? Depends on your preference. Personally, I prefer Directus' way mainly because any change is applied instantly, you don't need to wait for the app to restart, unlike Strapi.
Strapi's admin app is based on React, Directus' on Vue. Honestly, there isn't much to say: Directus clearly outperforms Strapi on this part: customization, snappiness, coherence... We will come back later on this but I strongly suggest you play around with Directus by yourself.
Directus' advantages over Strapi
Directus can be used over an existing database
Directus can initialize itself over your existing database, allowing you to manage your tables even if they were not created with the tool (except for relational fields I think). Strapi forces you to bootstrap your project with it if you want to have control over your database.
It's not a huge drawback, but still it's a nice feature from Directus.
Directus has a powerful role & permission system
Directus offers a simple and powerful permissions management interface through the admin app. To begin with, Directus lets you create an unlimited number of roles, where Strapi has a limit of 3 roles in its free version. Why ? I don't know, it's stupid and unnecessary.
Although Strapi provides an interface to manage permissions per roles, Directus goes much (MUCH) further by allowing you to customize access based on conditions, and per field access.
Imagine you have a blog, and you want public users to only have read access on your articles that are published, this is how you would to it:
If you want to go further and limit what fields public users can see, check the Field Permissions tab:
Directus supports geographic objects (PostGIS)
PostGIS is a spatial database extender for PostgreSQL which adds support of geographic objects queries to be run in SQL. It's such an important feature of PostgreSQL that is not supported in Strapi. Again, why ? Again, I don't know. But Directus does support it, and it's gracefully implemented. Take a look:
We have the choice between:
- Point - a geo object represented by a latitude and a longitude
- LineString - a geo object represented by two geographic points
- Polygon - a geo object represented by a finite number of straight line segments connected to form a closed polygonal chain
- MultiPoint - a geo object represented by an array of points
- MultiLineString - a geo object represented by an array of lines
- MultiPolygon - a geo object represented by an array of polygons
- Geometry - a geo object represented by one or more geometrical shapes
Let's choose the Geometry (All) type for this example and create a new item:
Amazing huh ? What's more amazing is that Directus natively supports queries on geo fields!
Directus' UI is more customizable
Directus allows you customize your admin dashboard much more than Strapi, allowing non-technical users to actually use the dashboard easily. Here are my favorites parts:
- Per field aliases - you can give an alias to any field of any collection ; let's say you have a relationship field named "blog_blogs", you can visually rename it on the fly with "Related blogs"
- Conditional display - you can style field presentation based on conditions; for example show a red dot if a blog article is in draft, and a green dot if it's published
- Collections grouping - group collections by categories you define; for example group all marketing related collections in a "Marketing" collapsable group
- Adjust collection page layout - arrange the collection page layout as you wish; choose between different views (table, cards, map, calendar), show or hide any field as you wish, even deep relational field, this is as BIG +
This is in my opinion the best feature of Directus right now. Flows allow you to run operations based on different triggers directly from your dashboard in a no-code way, with a beautiful UI composed of blocks connected to each other.
Let's take a simple example: you want to send an email to your customers every time a blog article is published. You can define this operation with Flows like this:
First, you define your Flow's trigger. Here we choose the "Event Hook" with a "items.update" scope on the Blogs collection so that our Flow triggers when at least one blog article is updated.
Then we create an operation that extracts all emails from our users collection
In order to bulk-send emails, we need them to be formatted as array of strings so we have to run a little script before the email operation. Just look at that, you can run JS code directly from the dashboard. Beautiful isn't it ?
The final touch, create a Send Email operation, pass the array of emails through the $last variable, fill in the missing inputs and you're good to go. Simple as that, makes perfect sense.
At the end, you get this Flow:
Why Directus is so unpopular ?
If you type "cms for developers" or "react CMS" or "best headless cms", you will surely come across on Strapi in the first page before Directus. Just look at the difference in popularity:
Strapi clearly outperforms Directus in popularity.
But why ?
Honestly, I don't know. Even though Directus has been around longer than Strapi with its PHP version (< v9), the latter just destroyed the game. This is thanks to their marketing department I guess, even I fell for it when I had to choose between the two tools.
I mean, they sold us Strapi like the future, better Wordpress. Their website looked dope compared to Directus' one, and I remember seeing an example project where you could create the whole front from Strapi with NextsJS and I was fucking hyped. And then, after using it, I realized how the code behind was just broken and buggy.
The way I see it, Directus = good code but low marketing, Strapi = good marketing but low code.
Clearly if you're hesitating between the two tools, go for Directus. It has all the features of Strapi, but better implemented and more. I didn't even mention Directus' JS SDK, media library management, extensions DX or Insights, but I suggest you to try by yourself.
Don't fall for Strapi's powerful marketing. Créer des vos fausses fiches de paies gratuitement
izoukhai 07/03/2023 13:49