React is a library, not a framework: its official website describes it as the library for web and native user interfaces, and it focuses only on building the view layer of an application. People call React a framework because real projects add routing, data fetching and build tools around it, and frameworks such as Next.js are built on top of React. This guide explains whether React is a framework or library, what the difference actually is, and why the answer matters in interviews.
Key takeaways
- React handles one job, rendering user interfaces from components, so by definition it is a library.
- The key difference is control: you call a library from your code, while a framework calls your code and decides the structure.
- Routing, data fetching and state management come from separate packages or from frameworks such as Next.js, not from React itself.
- Angular is a full framework, while React and Vue are usually described as libraries or progressive tools for the view layer.
- In interviews, say React is a library and explain why, then mention that React-based frameworks exist for full applications.
Library vs framework: the real difference
Both libraries and frameworks are reusable code written by someone else. The difference is who is in charge.
- A library is a set of tools you call when you need them. Your code controls the flow of the program.
- A framework provides the skeleton of the application and calls your code at the right moments. This is called inversion of control.
A simple analogy: a library is like buying furniture for a house you designed, while a framework is like moving into a flat where the walls, rooms and plumbing are already fixed and you decorate inside them.
Why React is a library
React does one thing: it lets you describe the user interface as components and keeps the browser in sync when data changes. It does not include:
- A router for moving between pages
- A built-in way to fetch data from APIs
- A form validation system
- A fixed project structure or file conventions
- A testing setup or build system
You choose those pieces yourself, for example React Router for routing and a tool such as Vite to build the project. That freedom of choice is typical of a library.
import { useState } from 'react';
function Counter() {
const [count, setCount] = useState(0);
return (
<button onClick={() => setCount(count + 1)}>
Clicked {count} times
</button>
);
}
export default Counter;This component is all React asks you to write. Where it lives, how it is routed to and where its data comes from are your decisions.
Why people call React a framework
The confusion is understandable for three reasons.
- Components and hooks feel framework-like. React does call your component functions when it renders, which is a small amount of inversion of control.
- The ecosystem is huge. Once you add a router, a state library and a build tool, the result behaves like a framework, even though React is only one part.
- Frameworks are built on React. Next.js and React Router (in its framework mode) add routing, server rendering and data loading on top of React, and the official React documentation recommends using a framework like these for new full applications.
So the accurate statement is: React is a library, and there are frameworks built with React.
React vs Angular vs Vue
| Tool | Type | What is included |
|---|---|---|
| React | Library | Components, state and rendering; other pieces chosen separately |
| Angular | Full framework | Routing, forms, HTTP client, dependency injection, CLI and testing tools |
| Vue | Progressive framework | Core view library with official router and state packages you can add |
| Next.js | Framework built on React | File-based routing, server rendering, data fetching and build setup |
Is React a programming language?
No. React is written in JavaScript and you use it from JavaScript or TypeScript. The HTML-like syntax inside React components is called JSX, which is converted to normal JavaScript function calls by a build tool. If you are new, learn JavaScript properly first. Our article Is JavaScript a programming language? explains where it fits.
Does the difference matter?
For building apps, the label matters less than the consequences.
- Flexibility: with React you choose your router, styling and state tools, which suits teams that want control.
- Decisions: beginners must make more choices, which can feel overwhelming without guidance.
- Consistency: two React projects can look very different, while two Angular projects usually follow the same structure.
In interviews, the question is a quick check of whether you understand these trade-offs. A strong answer is: React is a UI library because it only handles the view layer and leaves routing, data and structure to other tools, which is why frameworks like Next.js exist.
How to learn React the right way
- Learn modern JavaScript: functions, arrays and objects, destructuring, modules, promises and async/await.
- Learn React basics: components, props, state, events and lists.
- Learn hooks such as
useStateanduseEffect, and how to fetch data from an API. - Add React Router and build a small multi-page project.
- Try a framework such as Next.js once you are comfortable.
React is the R in the MERN stack, so it fits naturally into a full stack path. See our guide to the MERN stack and the full stack developer roadmap for what to learn next, and revise with our JavaScript interview questions.
Frequently asked questions
Is React a framework or a library?
React is a library. It focuses only on building user interfaces from components and does not include routing, data fetching or a fixed project structure, which you add with other tools or with a React-based framework such as Next.js.
Is Next.js a framework or library?
Next.js is a framework. It is built on top of React and adds file-based routing, server-side rendering, data fetching and build configuration, so it provides the structure that React alone does not.
Is React frontend or backend?
React is mainly a frontend library for building user interfaces in the browser. Frameworks built on React can also render pages on the server, but the backend logic such as databases and APIs is usually handled by Node.js or another server technology.
Should I learn React or Angular first?
Many beginners find React easier to start with because it has a smaller core to learn. Angular is a good choice if the companies you are targeting use it. Check job listings in your city and focus on the one that appears more often for fresher roles.
Read more in our full stack development articles.
