Choosing Libraries

We just added drag-and-drop to our Kanban board with @dnd-kit. We did not build the drag-and-drop system ourselves — we installed a library and wired it in.

You will do that a lot as a developer. You find a library, you check whether it is any good, and you wire it into your project.

The JavaScript Ecosystem

One of the reasons we chose React for this course is its ecosystem. There are libraries for authentication, charts, drag-and-drop, and many other things.

This is not unique to React. The JavaScript ecosystem as a whole is very large. npm has over two million packages. Whatever you are trying to build, someone has probably published a library that handles part of it.

That saves you a lot of work, but it also means you have to think about what you install.

How to Evaluate a Library

Not every package on npm is worth adding to your package.json. Before you install something, check a few things:

  • Weekly downloads — Is this package actively used? A library with tens of thousands of weekly downloads has likely been tested by many projects. One with 12 downloads last week might not be.
  • GitHub stars — Not a precise measure, but a rough signal of how much interest and trust the project has.
  • Recent activity — Look at the commit history and issue tracker. A library that has not been updated in two years may not work with current versions of React or Node.
  • Open issues and PRs — A healthy project has maintainers responding to issues. A project with hundreds of unanswered issues suggests the maintainers cannot keep up with it.
  • Documentation — If you cannot figure out how to use it from the docs, that will slow down every feature that touches it.
  • Bundle size — Tools like bundlephobia.com show you how much a package adds to your bundle. For a client-side app, that matters.

A quick visit to npmjs.com gives you download stats, and the GitHub repo covers the rest.

Building From Scratch

When you are starting out, it is tempting to build everything from scratch. That is good for learning, and we have done plenty of it in this course. But in a real project, a well-maintained library is usually the better choice. It takes less time, it gives you fewer bugs, and it leaves you free to work on the parts of the app that are specific to your project.