All posts

Why build a headless CMS in Rust?

Why build a headless CMS in Rust? For Headla, the short answer is that Rust lets us ship the whole CMS, server and editor alike, as one program that is hard to break, without making it any less pleasant to use. Headla is a fast, lightweight, feature-rich headless CMS built with Rust, and this post explains what that choice gives the people who run it, and what it costs us.

What is a headless CMS?

A headless CMS keeps your content and leaves the showing of it to you. Your team writes in an editor in the browser, and your websites and apps fetch the content and show it in their own way. Every part of Headla is written in Rust, including that editor.

What does a CMS need from its language?

A CMS is on the internet all day, reads whatever people and programs send it, and holds content a business depends on. So before we picked a language, we wrote down what we wanted from the program itself:

  • It should be easy to run, without a pile of separate services to install and keep in step.
  • It should be hard to break by sending it strange input.
  • The people who build it should be able to check every part of it the same way.
  • It should still be pleasant for the people who use it every day.

Rust is the language that let us say yes to the first three without giving up the fourth.

Why ship the whole CMS as one program?

When we build Headla, the result is one program. The part that answers your websites and apps, the background work such as sending email, and the editor all come out of the same build.

For the person who runs it, that means one thing to install, start and update. Headla keeps your content in PostgreSQL, a widely used database, and can use Redis as a cache. There is no separate front-end project and no second runtime to keep up to date.

Every extra moving part can be out of date, set up wrong, or fail at three in the morning. Fewer parts, fewer of those nights.

How does Rust make a CMS harder to break?

Rust's compiler refuses whole families of mistakes in how a program uses memory, the kind behind many serious security problems over the years. In ordinary Rust code, those mistakes simply do not compile.

That does not make Headla correct by magic; a program can still have the wrong rules in it. But with one large category of problems off the table, our time on safety goes into the questions about your content: who may see what, who may change what, and what gets recorded when they do.

For those questions we lean on the database as well. The rules about who may read which rows are handed to PostgreSQL itself, as row-level security, so the database refuses rows a person may not see, whichever part of the program asked. We explain more in where Headla keeps your content.

Why write the server and the editor in one language?

Because then the same formatting rules, strict warnings, tests, and licence and security checks of every library we depend on apply to every line. Nothing hides in a corner that a different set of tools would have looked at.

The editor is also held to accessibility rules. It is meant to work with a keyboard, with a screen reader and in light and dark modes, and we check that automatically as part of our own tests.

What does choosing Rust cost?

The downsides are real, so here they are:

  • Rust takes longer to build than many languages, so each small change takes us a little longer to try out. That cost lands on us, not on you.
  • A browser editor in Rust has fewer ready-made pieces, so we build more of its controls ourselves.
  • Fewer people write Rust than some other languages, so fewer can help with Headla today. We keep the code plain so it stays approachable.

We think these costs are worth paying once, by us, so that you get something small, sturdy and easy to look after.

Frequently asked questions

Is Headla written entirely in Rust?

Yes. The server, the background work and the browser editor are all written in Rust and built into one program.

What do I need to run Headla?

Headla itself and a PostgreSQL database. Redis is optional: Headla uses it as a cache when you have it.

Does Rust make Headla free of bugs?

No. Rust stops a whole family of memory mistakes before the program runs, but a program can still have the wrong rules in it. Those we check with our own tests.

When can I try Headla?

Headla is not released yet; it is in early development, and we will write about the work here. When it is ready, it will be free for everyone, with every feature: read what fair source means for you.

To hear when the first release is out, join the waiting list. Questions are welcome at contact@headla.com.

Headless CMS. Unleashed.