Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Client and server side - general question

I have a more general question about the client-server division. In the Express.js and Node.js courses we were building server apps which basically did everything - manage data, render templates and so on. My question is why is it necessary to design it this way? What I mean is that we could have a client side completely independent from the server as such, and only requesting/getting certain data from the server using websocket or something when it is necessary. And the server would only answer those requests and leave the whole rendering process to the front end. I suppose this way of doing things would be much clearer. So why it is not the case?

1 Answer

Casey Ydenberg
Casey Ydenberg
15,622 Points

Hi Konrad,

This is often what Express is used for - as a layer between Angular (or another client-side rendering framework) and a database. You still need this layer for security (you can't connect your front-end directly to a database) and managing user accounts and such. In a lot of cases, Express does not deliver HTML at all, just JSON.

There's some debate however, about how much client side rendering is too much - if you build a web-app with a blog, homepage, and other "front matter" on the same site, do you really want to leave ALL the rendering to the client (and thus invisible to web crawlers). So the rendering capability of Express is still important. Another twist in this is so-called "isomorphic Javascript" - using the same templates on both client and server to get the best of both worlds.