Framework vs Library — What's the Difference?
A library is code you call into to perform a specific task, on your own terms; a framework calls into your code according to its own structure and lifecycle — a distinction often summarized as "inversion of control."
Published October 4, 2026
With a library you call its code when you need it; with a framework the framework calls your code. That reversal is called inversion of control.
The concept
A library (lodash, axios) is a toolbox you pick from. You stay in control of the application flow.
A framework (Laravel, Angular, Django) defines the structure and lifecycle; you plug in your controllers, components or handlers where it tells you to.
Who is in charge?
Practical examples
Library: you call it
import _ from 'lodash'
const grouped = _.groupBy(users, 'role')Framework: it calls you
Route::get('/users', function () {
return User::all(); // Laravel decides when this runs
});React is a library, Next.js a framework
React: render UI when you ask
Next.js: routing, data loading and rendering lifecycle decided for youCommon mistakes
- Picking a framework for a tiny script.
- Fighting the framework's conventions.
- Calling any big library a framework without considering control flow.
Key takeaways
- Library = you call; framework = it calls you.
- Frameworks bring structure, libraries bring flexibility.
- Match the tool to project size.
FAQ
Is React a library or framework?
React calls itself a library; Next.js built on it is a framework.
Can I mix them?
Yes, frameworks commonly use many libraries.