React is a Framework
By this definition, React is a framework.
The Definition
I recently read a definition I like for "framework" vs "library". He acknowledges first that "framework" and "library" are squishy terms. From the htmx blog:
Library - 3P code whose API does not significantly influence the rest of the application
Framework - 3P code whose API dictates the overall structure of the application
(3P = "3rd-party", eg, not yours.) I think this is a helpful, illuminating definition.
React is Not a Framework
The UI library I used prior to picking up React was Ember. Being written by Rails enthusiasts, it was big on convention over configuration, and it included a lot. It specified how to write views, create models, route urls, even fetch data.
Going to React felt much lighter. It was a library that defined UIs as functions that took data and returned a virtual DOM. Other companion libraries were configured to address other needs in the app. React felt like a library, doing its niche UI rendering job.
There were even other UI libraries that said they had a mostly-interchangeable interface with React (ie, your components will work in our library and vice versa). Can this be said to be true today?
React is a Framework
React doesn't feel as light these days. The API surface area of React has grown immensely. The latest versions of React are even full-stack web framework dependent (ie, RSC currently run only on Next.js).
Leaving aside the last, most egregious, point, even if I did a client-only React application, React.something
s are going to be littered about the code. Think: useCallback
, useContext
, useEffect
, useRef
, useState
,
, createContext
, forwardRef
, lazy
, memo
, createPortal
, etc.
There is no tight (data) => ui
abstraction any more. There are a host of Reactisms that must be employed to make that function run within React. Its abstraction is exposed, leaking everywhere. This is no longer a replaceable library.
React dictates not just that we are using a component-modelled UI. It dictates the very particulars of the internals of those components. To look at the overall structure of the UI codebase, we know it's modelled by components. To look at the internals of each component, we know it's React and nothing else.
To switch your app to another UI library? Rewrite. To share components with another library? Rewrite.
React is defining of the structure in the large and in the small. For that reason, by this definition, React is a framework.
What other "framework" definitions do you have? Is React a framework from those perspectives?