DEV Community

Alex Spinov
Alex Spinov

Posted on

Directus Has a Free Self-Hosted Headless CMS — REST + GraphQL API for Any Database

A client needed a CMS. Not WordPress-level bloated. Not Contentful-level expensive. They wanted to manage content in a clean UI, get a REST/GraphQL API, and use their existing PostgreSQL database.

Directus checked every box. Self-hosted, open-source, and it wraps any SQL database with a full-featured API and admin panel. No migration needed — just point it at your existing database.

What You Get Free (Self-Hosted)

Directus is open-source (BSL/GPLv3):

  • REST + GraphQL API — auto-generated from your database schema
  • Admin app — beautiful UI for content management
  • Any SQL database — PostgreSQL, MySQL, SQLite, MS SQL, MariaDB, CockroachDB
  • File storage — local, S3, R2, Backblaze, Azure, GCS
  • Authentication — local, SSO, OAuth2, LDAP, SAML
  • Roles & permissions — granular field-level access control
  • Flows — visual automation (like n8n inside your CMS)
  • Webhooks — trigger external services on data changes
  • Extensions — custom endpoints, hooks, modules, layouts
  • Translations — built-in i18n for content
  • Versioning — content revision history

Quick Start

# Docker
docker run -d \
  -p 8055:8055 \
  -e SECRET="your-secret-key" \
  -e DB_CLIENT="sqlite3" \
  -e DB_FILENAME="/data/database.sqlite" \
  -v directus_data:/data \
  directus/directus

# Open http://localhost:8055
# Create admin account
Enter fullscreen mode Exit fullscreen mode

Or connect to existing PostgreSQL:

docker run -d \
  -p 8055:8055 \
  -e SECRET="your-secret-key" \
  -e DB_CLIENT="pg" \
  -e DB_HOST="your-db-host" \
  -e DB_DATABASE="your-db" \
  -e DB_USER="user" \
  -e DB_PASSWORD="password" \
  directus/directus
Enter fullscreen mode Exit fullscreen mode

Your existing tables appear as collections. Instant API.

Real Example: Fetch Content

// REST
const response = await fetch('http://localhost:8055/items/articles?sort=-date_published&limit=10');
const { data } = await response.json();

// GraphQL
const query = `{
  articles(sort: ["-date_published"], limit: 10) {
    id
    title
    content
    author { name avatar }
  }
}`;
Enter fullscreen mode Exit fullscreen mode

What You Can Build

1. Blog/content site — Next.js/Nuxt frontend + Directus backend. Non-technical editors manage content.

2. Product catalog — manage products, categories, images. REST API for your e-commerce frontend.

3. Internal tools — admin panel for any database. No custom CRUD UI needed.

4. Multi-language site — built-in translation management. Editors handle translations in the UI.

5. Digital asset management — file upload, transformation, tagging. Built-in media library.

Directus vs Alternatives

vs Strapi: Directus connects to existing databases. Strapi creates its own schema. Directus for existing projects, Strapi for greenfield.

vs Contentful/Sanity: Self-hosted = free. No per-record pricing. Your data on your server.

vs WordPress: Modern API-first architecture. No PHP templating. Use any frontend framework.


Need CMS automation or custom API development? Email spinov001@gmail.com

More free tiers: 50+ Free APIs Every Developer Should Bookmark

Top comments (0)