DEV Community

Cover image for Is React a Library or a Framework? Why It Matters
Reed Barger
Reed Barger

Posted on • Originally published at


Is React a Library or a Framework? Why It Matters

Developers have spent a great deal of time what React is, but 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, 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 already, 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.

React is written in JavaScript and is used to make better JavaScript applications. We refer to React specifically as a library.

But what makes React a library and not a framework?

The reason becomes clear by looking at what other similar tools that are used to create complete web applications:

If we look at a project like Angular, which was made with the identical 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."

Frameworks is a common choice for companies and anyone looking to make enterprise JavaScript applications because they include resources that a large-scale application would likely need. This includes built-in tools for common tasks like creating forms, running automated tests, making network requests, and much more.

In short, everything that you would need to make a complete application is included in your Angular project when it's generated. 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, it does not include many of 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, however, 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.

Since React is a library, you must choose the tools on your own

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 as well as if I want to add an additional library to make managing my server state easier, such as React Query or SWR.

The tools you choose depend on your app and knowledge of them

Why this question of whether React is a library or framework is important is 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 on what you're not only what the demands of the app are, but 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 the decisions, you're able to make your own decisions, and you're able to have more freedom overall, as a developer. That being said, React not being a framework does not diminish its presence in the corporate realm, and is still used to build complex and impressive applications of all kinds. There are many such lists of the large-scale React applications that businesses have made and which you likely use on a daily basis.

It's arguably a requirement 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 haven'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 no longer 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 that have been made that are based upon React.

While React itself is just a library, many frameworks have cropped up in recent years to provide developers with a more powerful set of built-in tools to allow you to build projects faster without needing as many third-party libraries.

There are many React frameworks React-based frameworks. Some of the most popular ones 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:

The React Bootcamp

Click here to be notified when it opens

Top comments (1)

isaachagoel profile image
Isaac Hagoel

As far as i know the difference between a library and a framework is that a library is something that your code calls and a framework calls your code, as in it creates slots in which your code lives but it controls the application life cycle for you.
By this definition React is a framework (just not a fully featured one).