DEV Community

NPM libraries: which are the good ones?

Getting to know a language's ecosystem is intimidating.

I am switching from backend to frontend for a while, and I think I can master typescript on my own. But when I go to where it seems like one million libraries are available, I'm like : where do I even start? 😱

Dear readers, do you have a list of go-to libraries on npm that solves a specific and common problem well?
I'm not talking about big frameworks like React/Vue/Angular but things like momentjs.

On the other hand, can you think of libraries which are overused?

How do you evaluate whether you want to depend on a library and when reinventing the wheel is actually the better choice?

Top comments (10)

madza profile image

I did a list of personal favs a while ago πŸ˜‰

patarapolw profile image
Pacharapol Withayasakpunt

One actually answers the question πŸ‘

patarapolw profile image
Pacharapol Withayasakpunt • Edited

Looking at my recent repos, my current favs are

  • pnpm
  • better-sqlite3
  • cheerio
  • fastify
  • incremental-dom - I wrote a post about this.
  • fast-glob; haven't tried globby yet
  • markdown-it and related; or sometimes, showdown which is complete without plugins
  • js-yaml
  • zod or jsonschema-definer
  • prettier - much simpler to set up than eslint, and comes with sensible defaults
  • id128, for generating ULID / sortable UUID
  • xregexp
  • codemirror
  • monaco-editor - Yes, you can embed VSCode in your website.
  • highlight.js / prism.js
  • reveal.js
  • chart.js
jmfayard profile image
Jean-Michel Fayard πŸ‡«πŸ‡·πŸ‡©πŸ‡ͺπŸ‡¬πŸ‡§πŸ‡ͺπŸ‡ΈπŸ‡¨πŸ‡΄


bias profile image
Tobias Nickel • Edited

before there was a feature on npm, that you can give pavkages stars like on github. I had around 70 in that list. I would hope they bring the feature back.

In my opinion grunt and gulp are useless, just to npm scripts. these task runner just transform js issues into configuration/tool problem without prividing any real value.

I often start a new frontend project, using create-react-app, even when not using react and just remove it. but the weback config is very good with it.

For working with xml I recommens my own module txml. While also recommending json over xml.

oguimbal profile image
Olivier Guimbal • Edited

If your main choices have already been taken care of (framework, ui lib, ...), i think you're asking the wrong question.

When you're starting to write a new feature, ask yourself:

1) Is this feature domain specific ? (yes ? then do it yourself)
2) Is there any chance that someone might already have done it ? (no ? then do it yourself)
3) Is it really worth it to use someone else code for that, or would I be happier with something I wrote ? (no ? then do it your self)

If you've passed those steps, there is a good chance that there is a lib that suits your needs.

There are literally no way to tell in advance which one will be usefull to you. Nor to know all of them. I can give you some advice to chose them, though:

  • Do not pay attentions to repo⭐ too much or download counts, they dont mean much (especially on recent libs, or on edge features)
  • Avoid libraries that have no activity (not been modified for years, no question asked, ...)
  • Check if there are issues. If there are, and there is nobody answering them, nor any commits showing some sign of authors activity, then the lib is likely dying.
  • Avoid using libs big libs that that are doing too much if you only plan to use a tiny portion of them (it could increase your bundle size signifcantly if they're not tree-shakeable)

That said, I know the best lib out there: mine πŸ˜„ (shouldnt be of much use for the frontend, though)

jmfayard profile image
Jean-Michel Fayard πŸ‡«πŸ‡·πŸ‡©πŸ‡ͺπŸ‡¬πŸ‡§πŸ‡ͺπŸ‡ΈπŸ‡¨πŸ‡΄

That's super helpful, thanks a lot!

adam_cyclones profile image
Adam Crockett

You can't go shopping without knowing what you want to buy in much the same way you can't use packages without knowing the problem. And here's how to choose the library.

I want to write a to-do list.

  1. Do I need a library If yes, what problem am I solving.
  2. Is this library solving my problem
  3. Is the code style matching my stack, eg is typescript well supported, could you live without support?
  4. Is the library maintained and regularly
  5. Is the library full of security issues flagged by npm
  6. Does the library use as few dependencies as possible to prevent headaches when managing other dependencies.
jmfayard profile image
Jean-Michel Fayard πŸ‡«πŸ‡·πŸ‡©πŸ‡ͺπŸ‡¬πŸ‡§πŸ‡ͺπŸ‡ΈπŸ‡¨πŸ‡΄

makes sense, thanks!

thorstenhirsch profile image
Thorsten Hirsch

But when I go to where it seems like one million libraries are available...

There are literally one million packages available (even more). This milestone was reached in 2019.