So, you want to know what Express is in Nodejs? Well, you’re in luck, because today I am going to explain it to you in plain English!
Just like you, I was also once confused about what the purpose of Express was in the node environment. Why is it used? What does Express actually do? Why is it not already included in Nodejs?
If you are having similar thoughts to these, this guide is for you. Let’s start with the obvious question:
What is Express.js?
So, what is Express exactly? Well, Express is a minimalistic web framework built for Node JS. Express handles things like creating a server and routing. It also contains middleware to help you complete common tasks, such as handling authentication and parsing body/query strings.
If you don’t know what these things are yet, it’s not really important. The important thing to remember is that when you want to create a web app, there are certain things you will need to do to build that app. Express handles those things for you, and the only thing you are responsible for is learning how to use the framework.
However, since Express is a framework, you could actually do everything Express does manually. In other words, you can write your own code and never use ExpressJS. Even create a better framework. Express simply makes the code you write a lot simpler and removes the aspects that are overly complicated and saves you a lot of time and headaches.
Now, what is Express in Nodejs? You can think of Nodejs as the base layer, or environment, where Express lives. In order to use Express, it must exist in the Node environment. In fact, Express utilizes API endpoints available in Nodejs. Without those, Express would not exist.
Do I Need To Know How To Build Web Apps Without Express?
The short answer? You certainly do not need to learn how to build your own web framework to build web apps or work as a professional web developer.
In addition, unless you were working for a giant tech company, you would actually probably use a web framework like Express on your backend. If you worked for a fortune 500 company, they may have their own in-house framework.
Either way, you would never be building your own framework. Why? Simply because it would take way too much time, introduce way too many bugs, and be way too expensive. So don’t sweat it if you don’t fully understand how Express works under the hood. Just learn ExpressJS.
However, building your own web server for the sake of learning can be a fun and interesting project that will give you a much better idea of the tools you are using and how web development works on a deeper level. Just like how learning C can give you a better understanding of modern programming languages.
As programmers, we often get the idea that we should be building everything from scratch and that it will somehow be better. But it’s always important to remember that software built by a team of professional developers is (almost) always going to outperform something you build by yourself and it will take a fraction of the time to reach your goals.
It is also interesting to note that some people think that Express is actually too lightweight and does not offer enough help with these common tasks in a professional setting. That is where a heavier framework like Sails JS comes in. Not that I’m recommending it, I actually haven’t heard great things…