Yesterday's framework and today's library both mean "code you didn't write". The line between them is control.
A framework calls you. It owns the app's structure and runs your code at the points it defines.
A library waits to be called. Your code owns the structure and uses the library for one job.
React is often called a framework, but strictly speaking it's a library: it handles rendering the screen and you decide everything else. Next.js wraps React into a full framework. People blur these terms all the time, so don't stress when you hear them swapped.
A typical project uses one framework and dozens of libraries.
Quick check: You add a piece of code that draws charts, and you call it from three different screens. Library or framework?
## SPOKEN LINES
- Under every message your app says 3 minutes ago, and it is wrong for anyone in a different time zone. You spent a whole weekend on a feature somebody else finished years ago.
- - LIBRARY
- - A library is a collection of code someone else wrote, packaged so you can pull it into your project and call it. You stay in charge. Your code calls the library when it needs it and ignores it the rest of the time.
- - A date library gives you 3 minutes ago, a chart library draws the bar graph on your dashboard, and an email library sends the receipt.
- - So a library is ready-made code your app calls when it needs it. Tomorrow: Dependency, what happens once your app cannot run without that library.
## NEXT
Day 17: Dependency