Developers have spent a great deal of time talking about what React is. But they have left out why this topic matters so greatly for anyone who builds React applications.
The answer to this question is essential for any React developer, regardless of their skill level. This is because it indicates what they must know and how they must work in developing any React application.
Whether you are a new or an advanced React developer, I hope this thoughtful analysis will improve your own development process as you build your next React project.
Looking for the complete guide to become an in-demand React developer? Check out the React Bootcamp.
Why is React a library and not a framework?
React was made to build full-fledged web applications. As a result, it’s often compared with other tools that developers use to build apps, like Angular, Vue, and Svelte.
But what makes React a library and not a framework?
The reason becomes clear when we look at other similar tools that are used to create complete web applications.
Let’s look at a project like Angular, which shares the same purpose as React (to create single-page web apps). What sets it apart is the fact that when you set up an Angular project, it is bootstrapped with nearly every single thing that you’ll need to make a complete, large-scale app.
Many developers like to refer to frameworks or similar solutions as having “batteries included.”
In short, everything that you need to make a complete application is included in your Angular project when it’s generated. But that is not the case with React.
React is fundamentally “unopinionated”
While popular tools have emerged like Create React App, which allow you to create a complete React project in a single command, React is often referred to as “unopinionated.”
What does it mean for React to be unopinionated?
The React and React DOM libraries give us the means of building a user interface with the JSX syntax, plus powerful state management tools via hooks, among other things.
However, React itself does not include many of the React-specific libraries you’re going to need for most projects. Angular and Vue, by comparison, include many more tools all bundled within the core package itself.
Many developers consider this discussion of what is and isn’t a library to be trivial. But it has real consequences for our development process. In other words, because React is a library and not a framework, becoming a skilled React developer entails having a good knowledge of third-party React libraries.
That means, in order to build complete React applications, you will need to choose these packages and tools on your own.
Here are a few examples of decisions that I often need to make when I’m building a React application myself:
For a form library, I have to decide whether I want to use the package React Hook Form or Formik. These are both React-specific form libraries to add important features to our forms like validation.
For testing my React application, I might use either React Testing Library, Jest, or some combination of the two.
For making network requests, I might need to choose between the Fetch API and Axios. I might also need to decide if I want to add an additional library to make managing my server state easier, such as React Query or SWR.
This question of whether React is a library or framework is important because any React developer must know what their choices are and which choice to make given the type of React application they’re building.
If you’re building an app without many forms, you might not need a form library at all. If you’re more confident with the Fetch API, you might use that over something like Axios.
It really depends not only on what the demands of the app are, but also on what your preferences are as a developer. This is arguably an advantage that React has as a library and why I believe it’s very popular among newer developers. It doesn’t lock you into one choice or hold you to any specific libraries other than React itself.
You’re able to make your own decisions, and you’re able to have more freedom overall, as a developer.
That being said, even though React is not a framework this does not diminish its presence in the corporate realm. It’s still used to build complex and impressive applications of all kinds. There are many lists of the large-scale React applications that businesses have made and which you likely use on a daily basis.
You need to keep up with emerging libraries
If we were talking about which form library to choose two years ago, I would likely have included Redux Form. As for a data fetching library, I couldn’t have mentioned React Query or SWR, because they weren’t created (or hadn’t gained much traction), until the last year or so.
Because React apps are often reliant upon third-party libraries, newer libraries come about that improve upon the old ones. Individual developers and teams transition to different tools to get the job done and the ecosystem changes as a whole.
Like it or not, React being a library and not a framework entails a large, shifting network of other libraries we must be aware of to build our projects. Some of which may fall out of favor and be replaced by others or may become deprecated and no longer supported as open-source projects.
In short, React being a library may require us to pay more attention to what is going on around React, as compared to if it was a framework.
Wish React was a framework? There are many!
It’s worth noting that there are frameworks out there that are based upon React.
While React itself is just a library, many React-based frameworks have cropped up in recent years to provide developers with a more powerful set of built-in tools. These allow you to build projects faster without needing as many third-party libraries.
Some of the most popular of these frameworks include Next.js, Gatsby, and Redwood.js, all of which are used to create full-scale dynamic and static React applications.
This is, in my opinion, the great advantage of frameworks – you do not have to make as many choices throughout the development process.
Use React’s flexibility to your advantage
Be aware that going forward, there is a robust ecosystem of React-focused libraries that you can add to your React project to achieve whatever you’re looking for, from the most general tasks to the most specific.
This is thanks to React’s popularity and widespread usage. But also note, especially if you’re coming from an opinionated framework like Angular or Vue, that there are many React-based frameworks that you can rely upon and learn about to build equally functional and featureful applications as well.
Want to master React? Join The React Bootcamp
The React Bootcamp takes everything you should know about learning React and bundles it into one comprehensive package, including videos, cheatsheets, plus special bonuses.
Gain the insider information hundreds of developers have already used to master React, find their dream jobs, and take control of their future:
Click here to be notified when it opens