Frontend First Development

Frontend
   First
     Development

TL;DR

Solve friction between backend and frontend with an API mocking server, GraphQL, automatic server side rendering and a schema first headless CMS of your choice.

About

Back in the day, web development was a lot less complex. Those days the backend basically was the frontend, today the backend and frontend are two distinct and often rather complex entities. Syncing frontend templates and assets with backend rendered markup is often anything else than straight forward. Depending on the CMS driving your site, you get more or less container markup wrapping the data outputted by different modules and either you overwrite a lot of server templates (if that is even possible!) or you adapt your CSS (not always possible either with flex based layouts) to integrate your markup.

But thankfully there’s finally a promising path out of this mess! By doing as much as possible on the frontend, ideally component based so you can abstract complexity into smaller more focused pieces, and than render the routes and markup with a server side rendering framework, you never again have to sync markup from different sources. And by additionally mocking the API server, we can flexibly and much faster tinker with the project till everything is perfect, without first implementing the feature on the backend, making us more responsive and our clients happy.

Let’s be honest, letting the backend render markup was never a great idea anyway. Not only does it create the described friction between frontend and backend, it also isn’t really the expertise of backend developers, especially when it comes to things like accessibility and above the fold performance optimisations. A frontend first development workflow can solve us all these problems and this place here will try to do it’s best to point you in the right directions.

A content management system is for managing content, not for content rendering!

Why

Let’s first have an overview why we actually need to move to a frontend first development workflow by comparing its advantages and possible disadvantages.

Advantages:

Possible disadvantages:

Less friction between FE and BE

Let’s have a closer look at one of the pros, one that creates a lot of issues with current workflows, to get a better idea why frontend first is such a tempting idea.

Usual developer workflow:

This workflow creates friction when both paths meet!

Frontend First Workflow:

Only one development path, no friction!

Information architecture and technical specification is mostly a first draft. Than changes happen after the client can interact with the frontend or living style guide, while iterating till every stakeholder is happy. Without a frontend first approach, this leads to friction everywhere. Even content creation is more and more frontend first focused these days, just think of headlines that have to be limited to certain lengths to match the design and use fitting word lengths to break nicely in the limited space designed for that element.

Key technologies

Thanks to some key technologies of recent years like GraphQL and all the tooling around it, we are now pretty close to make a truly frontend first workflow possible!

API server mocking

The first key technology is API server mocking. On a frontend first workflow, you want to start working before any backend is set up. Traditionally we used hardcoded data and mocked JSON endpoints to mock our API endpoints, but these days it’s now possible to mock a whole REST or GraphQL server with just some sample data. These kind of servers support all the CRUD operations (create, read, update and delete) and especially with GraphQL, can feel like the real thing, but with almost no effort. This is very important, as you can create prototypes that are so close to the real thing, that your client can get a very realistic impression of the final product, without ever having to first setup a backend CMS. The other important feature of this approach, is that you can design your sample data so realistically, that you can test frontend edge cases, for example different content lengths, right from the beginning. As you’re working with sample data, changes to your API are done in seconds, even changing normally complicated stuff like relationships, becomes really easy.

If you want to have super fast iterations on your API, there’s no way around an API mocking server.

Let’s have a look at an example. The following sample data defines a blogging API where users have posts and posts can have comments and comments can be replies to other comments.