# Library vs Framework

URL: https://softwaredictionary.org/compare/library-vs-framework
Last updated: 2026-10-03

In short: A library is code you call when you need it, while a framework provides your app's structure and calls your code. You call a library; a framework calls you.

## What is the difference between a library and a framework?

Both are reusable code written by someone else, so the difference isn't size or quality but control. With a library, your program is in charge: it decides when to call `formatDate()` or `axios.get()`, gets a result and carries on. With a framework, the framework is in charge: it starts the application, handles the request or the screen, and calls the functions and classes you wrote at the points it defines.

This reversal is called inversion of control. A web framework such as Django or Spring receives every HTTP request, routes it, and calls your view or controller. A testing framework such as Jest finds your test functions and runs them. You fill in the blanks the framework leaves, following its conventions for where files go and how things are named.

That trade-off shapes projects. Frameworks give structure, sensible defaults and a lot of built-in functionality, so teams move fast and code looks similar across projects, but they are harder to swap out later. Libraries are easy to add, replace or combine, but you design the overall structure yourself.

A common misconception is that anything large must be a framework. React describes itself as a library for building user interfaces, because your code decides where to render it; Next.js, built on top of React, is a framework because it controls routing, rendering and the build. Many tools sit somewhere in between.

| Aspect | Library | Framework |
| --- | --- | --- |
| Who is in control | Your code calls the library | The framework calls your code |
| Structure | You design the application's structure | The framework defines it |
| Scope | Usually one focused job | A whole application skeleton |
| Replacing it | Usually easy | Usually hard, the code is built around it |
| Learning curve | Learn just the functions you use | Learn its conventions and lifecycle |
| Examples | Lodash, Axios, NumPy, React | Django, Spring, Angular, Next.js, Rails |

## Choose Library when

- You need one specific capability, such as dates, HTTP or charts.
- You want to keep control over your application's structure.
- You may need to swap the tool for another later.

## Choose Framework when

- You are building a whole application and want proven structure.
- Your team benefits from shared conventions and built-in features.
- Speed of getting started matters more than full flexibility.

## Frequently asked questions

**Is React a library or a framework?**

React calls itself a library for user interfaces. It handles components and rendering, while routing and data loading come from other libraries or from frameworks built on it, such as Next.js.

**What is inversion of control?**

A design where a framework controls the flow of the program and calls code you provide, instead of your code calling the framework. It is the main thing that distinguishes frameworks from libraries.

**Can a project use both libraries and frameworks?**

Yes, almost every project does. A typical app runs on one framework and uses many libraries inside it for specific tasks.

---

Software Dictionary: https://softwaredictionary.org/ · https://softwaredictionary.org/llms.txt
