Coupling of front end and backend

github logo ・1 min read

What’s the recommended practice for the coupling of the frontend and backend of a web application? Should the frontend and backend be coupled through server views (pug templates), or decoupled by a building a separate api which the frontend will ping?

Aside from the accepted practice, what are some advantages and disadvantages of each option?

twitter logo DISCUSS (2)
markdown guide

Personally, I like more and recommend to decouple the Frontend from the API. This let you update them individually so you can change your frontend without redeploying your API or improve the API without re-building your Frontend.

On the other side, coupling them and using template based view can give you a faster start when coding a project and if you're a FullStack dev with more Backend background you can just go this way and eventually split them if the Frontend grows in complexity (or you get a Frontend dev to work with you).

Also for simple projects like a CRUD admin for a little company or similar project without too many frontend stuffs aside of CSS (and maybe using Bootstrap or similars) the coupled approach is more than enough because in that case you most probably have everything already done for you and doesn't make sense to use something like React, Angular, Vue, etc. and decouple the Frontend.


If I had to boil it down to one fact, it is where your business state needs to live.

If your frontend is stateless and you're essentially directly accessing and modifying a database with every single action, that might be an good case for a template based solution.

If you want to have a significant amount of user specific, short lived state belonging to to the frontend, one might be better off with a fat client application.
An example could be an application that needs to work offline.

Obviously, there is a lot of nuance to this decision. It can depend a lot on what you / your users want and need, when and how data needs to flow.

In doubt, starting with a monolith (a template based solution) is probably the better approach.

Classic DEV Post from Jun 13 '19

Async, Parallel, Concurrent Explained - Starring Gordon Ramsay

Complex computing concepts simplified

Tomas Alejandro V. Falgui III profile image