How to choose an open-source library: what to check before adding a dependency
Every dependency is code you did not write but are now responsible for. A few minutes of evaluation can prevent painful migrations later.
Checklist before adding a library
- Maintenance: when was the last release and commit? Are issues and pull requests getting responses?
- Maintainers: is it one person or a team? Is there organizational backing?
- Adoption: widely used libraries tend to have bugs found and fixed faster
- License: is it compatible with your project and how you distribute it?
- Security history: how were past vulnerabilities handled?
- Dependency tree: does it pull in dozens of transitive dependencies?
- Size and scope: does it do far more than you need?
- Documentation and tests: are they present and up to date?
- API stability: does it follow semantic versioning, and do major versions break things often?
Questions to ask yourself
- Could this be a few lines of your own code instead?
- How hard would it be to replace if it was abandoned?
- Does your language's standard library already handle it?
Reduce risk
- Pin versions and use lockfiles
- Wrap external libraries behind your own interfaces when they are central to your app
- Use automated dependency update and vulnerability alerts
What red flag makes you avoid a library immediately? Have you ever regretted adding a tiny dependency?
Comments · 3
Maintenance activity is the thing I'd check first. A library with one maintainer and stale issues is a risk to your roadmap.
Documentation quality says a lot. If it's hard to get started, that's a preview of how support will feel.
Consider the switching cost. The more of your code it touches, the more careful the choice should be.