What is a package in coding?
A package is ready-made code that someone else wrote and shared, which you add to your project with one command instead of building that part yourself.
Last updated
In real life
Like buying a ready-made cake base instead of growing the wheat: you still make the cake, just much faster.
Try it yourself
The demo's made-up bakery site needs a date picker. Instead of weeks of building, one command installs a package. It's added to package.json, the project's list of packages, and a working date picker appears on the order page.
Your project needs a date picker for orders
- Option 1: build it yourself. Calendars, months, time zones, phones: weeks of work.
- Option 2: install a package someone already built and tested.
rosas-bakery $
package.json, the project's list of packages
{
"name": "rosas-bakery",
"dependencies": {
"next": "15.5.0"
}
}The order page
Pick a collection day
No date picker yet.
A package is ready-made code you add to your project with one command. It's listed in package.json, so anyone setting up the project gets the same packages.
Package vs API
A package is code you download and run inside your own project. An API is a service running somewhere else that your code sends requests to.
Common questions
Where do packages come from?
From shared package libraries. For JavaScript, the biggest is npm, with millions of packages. Python's is called PyPI.
Are packages safe?
Usually, but you're running someone else's code. Prefer packages that are widely used and recently updated, and be wary of ones a stranger tells you to install.
Where you will use this
Quick check: Package
Question 1 of 3