Skip to content

4.9 Stop Reinventing the Wheel

Goal of this section: Master the most commonly used libraries in the Node.js ecosystem, learn how to quickly find the right tool for the job, and spend your time on business logic instead.

Xiaoming wanted to add infinite scroll to his app, so he opened Claude Code and said: "Help me write an infinite scroll implementation."

Claude Code immediately started writing code. The senior dev nearby saw this and quickly stopped him: "Wait! Are you sure you want it to write that?"

Xiaoming was confused: "AI can write it, why not let it?"

The senior dev said: "It can write it, but that's the least efficient approach. If you're using React, SWR or TanStack Query already handle infinite scroll, caching, revalidation, error retry, optimistic updates... If you let AI write it, you'd need hundreds of lines just to handle edge cases, and it wouldn't be production-tested. Mature libraries are more reliable."

"The value of AI isn't helping you reinvent the wheel," the senior dev continued, "it's helping you find the right wheel and teaching you how to use it."

Real Project Problems and Solutions

Before we dive in, let's look at what problems a real Next.js full-stack project encountered during development, and which libraries solved them:

Problem 1: User data changes frequently, refetching every time is too slow

The problem: On the user list page, every time you switch back it has to reload, which is a terrible experience. Plus multiple components requesting the same endpoint wastes bandwidth.

Solution: swr - Automatically caches request results, multiple components share the same data, and automatic revalidation keeps data fresh.

Problem 2: Form validation logic scattered everywhere, changing one place requires changes in multiple files

The problem: Validate once on frontend, once on backend, the two logics are inconsistent, bugs keep popping up.

Solution: zod - Define schema once, share between frontend and backend, type-safe, change one place and it applies everywhere.

Problem 3: User authentication requires handling sessions, cookies, password encryption... too complex

The problem: Writing your own auth system takes weeks just to handle security properly, and it still might not be reliable.

Solution: better-auth - Out-of-the-box authentication solution, supports multiple login methods, security concerns are all handled for you.

Problem 4: Writing SQL for database queries is tedious and error-prone

The problem: Hand-written SQL is easy to mess up, no type hints, changing table structure requires global search and replace.

Solution: drizzle-orm - Type-safe ORM, intelligent autocomplete when writing queries, compiler errors when you change table structure.

Problem 5: User-uploaded content may contain malicious scripts

The problem: User-input Markdown or HTML may contain XSS attack code.

Solution: sanitize-html + rehype-sanitize - Automatically clean dangerous content while preserving safe formatting.

Problem 6: Form state management is too complex, every field requires tons of code

The problem: Controlled components are tedious to write, validation, error messages, submit states... code explodes.

Solution: react-hook-form - Manage forms with Hooks, 70% less code, better performance too.

Problem 7: No one knows when production processes crash

The problem: When the Node.js process dies, the site goes down, and you have to restart manually.

Solution: pm2 - Auto-restart, load balancing, log management, all with one command.

Problem 8: Log output is too slow, affects performance

The problem: console.log blocks the event loop under high concurrency.

Solution: pino - Asynchronous logging, 10x+ faster than console.log.

Problem 9: Drag-and-drop sorting requires handling all kinds of edge cases

The problem: Drag-and-drop involves mouse events, touch events, animations, collision detection... writing it yourself takes at least hundreds of lines.

Solution: @dnd-kit/core - Professional drag-and-drop library, accessibility, touch support, animations all included.

Problem 10: Images need compression before upload, otherwise they're too large

The problem: User-uploaded photos are often several MB, server bandwidth can't handle it.

Solution: browser-image-compression - Compress images in the browser, reduce traffic by 80%.


See? Each one solves a specific problem. None are "using it for the sake of using it"—they're all "encounter problem → find library → solve problem."

This is the norm in modern web development—it's not about whether you can write it, it's about whether you know there's already a solution.

Why Not Reinvent the Wheel?

In the AI-assisted development era, many people have a misconception: "Since AI can help me write it, why not write it myself?"

The truth is:

  1. AI-written "wheels" are lower quality than mature libraries:

    • Mature libraries are production-tested millions of times; AI-written code is only tested by you
    • Mature libraries have complete edge case handling; AI-written code may miss 90% of edge cases
    • Mature libraries have ongoing maintenance and security updates; AI-written code issues are yours alone to fix
  2. Maintenance costs far exceed your imagination:

    • You think you're done after writing it? Dependency updates, security vulnerabilities, new requirements... all on you
    • Mature libraries have communities to help solve these; your code only has you
  3. AI's real value is helping you choose and integrate libraries:

    • Finding the most suitable library
    • Reading library documentation
    • Writing correct integration code
    • Handling special cases

Developer Value in the AI Era

Your value isn't "being able to make AI write code"—it's "being able to choose solutions, assemble them, and solve problems." Having AI reinvent wheels for you is the least efficient behavior.

How to Find the Right Wheel?

1. Awesome Series (Curated Lists)

The Awesome series are community-maintained curated resource lists, each strictly vetted:

Quick Access

Visit node.cool to jump directly to awesome-nodejs

2. Other Resources

3. Let AI Help You Choose Libraries

This is the most efficient approach. Tell Claude Code your requirements and let it filter for you:

I need a Node.js date handling library with these requirements:
- Actively maintained (updated in last 6 months)
- TypeScript support
- Good documentation
- Small size (< 50KB)
- Timezone support

Please recommend 3 options with pros and cons for each.

Claude Code will recommend based on the latest ecosystem status, much faster than searching yourself.

Common Node.js Libraries Quick Reference

Below are the most commonly used libraries in the Node.js ecosystem, organized by category. For the complete list, see awesome-nodejs.

Web Frameworks

When you need them: When you need to handle HTTP requests, routing, middleware. If you're just writing a simple script, Node.js's built-in http module is enough. But for building web apps or API services, frameworks save you 90% of boilerplate (route matching, request parsing, error handling, middleware management...).

  • Fastify - High-performance web framework Use case: API services needing high concurrency, 2-3x faster than Express

  • Express - Most popular web framework Use case: General web applications, most complete ecosystem, easiest to find resources, team collaboration preferred choice

  • Hono - Lightweight modern framework Use case: When you need to deploy across multiple runtimes like Cloudflare Workers, Deno, Bun

  • Next.js - React full-stack framework (recommended in this tutorial) Use case: React applications needing SSR, routing, API all-in-one solution

  • Nest - Enterprise-grade framework Use case: Large projects needing dependency injection, modular architecture, complete engineering solutions

  • Koa - Express team's new creation Use case: Prefer async/await style, need more flexible middleware control

Database ORM/ODM

When you need it: When you need to interact with databases in your code. Hand-written SQL is error-prone, lacks type hints, and requires global search-and-replace when schema changes. ORMs let you write queries in TypeScript with IntelliSense, and the compiler catches schema changes.

  • Drizzle - Type-safe ORM (recommended in tutorials) Problem faced: Hand-written SQL is error-prone, lacks type hints, and requires global search-and-replace when schema changes. Solution: Define schema in TypeScript, get IntelliSense for queries, and let the compiler catch schema changes. Why not build it yourself: Type inference, query builder, migration management, connection pooling... would take thousands of lines of code to implement yourself.

  • Prisma - Most feature-complete ORM Use case: When you need visual database management, auto-generated types, and complete migration tooling

  • TypeORM - Established ORM Use case: When you need a traditional ORM supporting multiple databases (MySQL, PostgreSQL, SQLite, etc.)

  • Mongoose - MongoDB ODM Use case: The go-to choice when using MongoDB, provides schema validation and query building

  • Sequelize - Multi-database ORM Use case: When you need to switch between multiple SQL databases

  • Knex - SQL query builder Use case: When you don't want a full ORM, just need type-safe query building

Database Drivers

When you need it: When you don't want to use an ORM and need to execute SQL directly. Or when the ORM uses these drivers under the hood. If you need maximum performance or complex native SQL, drivers are more appropriate.

  • node-postgres - PostgreSQL client Use case: Direct PostgreSQL operations without ORM abstraction

  • ioredis - Redis client Use case: Caching, session storage, message queues—better performance and features than the official client

  • mongodb - MongoDB driver Use case: When you don't want Mongoose and need lower-level MongoDB operations

  • mysql2 - MySQL client Use case: Operating MySQL/MariaDB with Promise and Prepared Statement support

Data Validation

When you need it: When you need to validate user input, API request parameters, or configuration files. Without validation, bad data causes app crashes or security vulnerabilities. Hand-written validation logic scattered everywhere leads to frontend-backend inconsistency—changing one field requires updates in multiple files.

  • Zod - TypeScript-first schema validation (recommended in tutorials) Problem faced: Validate once on frontend, once on backend, with inconsistent logic between sides—bugs happen constantly. Changing one field requires updates in multiple files. Solution: Define schema once, share between frontend and backend, type-safe, change in one place applies everywhere. Why not build it yourself: Validation rules, error messages, type inference... would take hundreds of lines of code without type safety.

  • Joi - Powerful validation library Use case: When you need complex validation rules (conditional validation, dependent fields)

  • Yup - Simple and easy-to-use validation library Use case: Use with React Hook Form, clean syntax

  • ajv - Fastest JSON Schema validator Use case: When you need to validate large amounts of data and performance is the top priority

Authentication & Authorization

When you need it: When you need user login and permission management. Building your own auth system requires handling password encryption, session management, cookie security, CSRF protection, OAuth integration... Just handling security issues takes weeks, and it still might not be reliable.

  • Better Auth - Modern authentication library (recommended in tutorials) Problem faced: Building your own auth system takes weeks just to handle security issues, and it still might not be reliable. Password encryption, sessions, cookies, CSRF... each is a pitfall. Solution: Out-of-the-box authentication with multiple login methods (email, OAuth, magic links), security issues handled for you. Why not build it yourself: Password hashing, salts, session management, token refresh, CSRF protection... would take thousands of lines of code and likely introduce security vulnerabilities.

  • Passport - Established authentication middleware Use case: When you need to support 500+ login strategies (OAuth, SAML, etc.)

  • Auth.js - Next.js authentication solution Use case: Next.js projects needing quick OAuth integration

  • CASL - Permission management library Use case: When you need fine-grained permission control (RBAC, ABAC)

  • node-casbin - Access control library Use case: When you need complex access control models (ACL, RBAC, ABAC)

HTTP Clients

When you need it: When you need to call external APIs from the server side. Node.js's built-in http module is too low-level—you have to manually handle request bodies, response parsing, error retrying... These libraries handle that for you.

  • undici - Node.js official high-performance HTTP client Use case: When you need maximum performance; Node.js 18+'s built-in fetch is based on it

  • axios - Most popular HTTP client Use case: General HTTP requests, interceptors, automatic transforms, good browser compatibility

  • got - Better HTTP interface Use case: When you need advanced features like retry, caching, hooks

  • node-fetch - Fetch API implementation Use case: When you want to use the browser's fetch API in Node.js (built into Node.js 18+)

React Data Fetching (Important)

Why do you need a dedicated data fetching library?

You might think "isn't it just fetch, why use a library?" But data fetching involves: caching, revalidation, error retry, optimistic updates, race condition handling, offline support... Building it yourself takes hundreds of lines of code and still might not be reliable.

  • SWR - Vercel's React Hooks data fetching library (used in tutorial projects)

    • Automatic caching, revalidation
    • Real-time updates, optimistic updates
    • Lightweight (~5KB)
    • Good for simple scenarios
  • TanStack Query - Most powerful data fetching library

    • Powerful cache management
    • Infinite scroll, pagination
    • Offline support
    • DevTools debugging
    • Good for complex scenarios

Comparison:

  • SWR: Simple, lightweight, sufficient (recommended for beginners)
  • TanStack Query: Feature-rich, good for complex applications

React UI & Interactions

When you need it: When dealing with complex UI interactions (forms, drag-and-drop, animations, content security). Rolling your own requires handling numerous edge cases—mature libraries are more reliable.

  • React Hook Form - Form state management The problem: Controlled components are tedious—every field needs value, onChange, validation, error messages, submit state... the code explodes. The solution: Use hooks to manage forms, reducing code by 70% with better performance (fewer re-renders). Why not build it yourself: Form validation, error handling, submit states, field dependencies, dynamic forms... at least hundreds of lines of code, and easy to introduce performance issues.

  • @dnd-kit/core - Drag-and-drop library The problem: Drag-and-drop involves mouse events, touch events, animations, collision detection... at least hundreds of lines to implement yourself, plus handling various edge cases. The solution: Professional drag-and-drop library with accessibility, touch support, and animations—all with a flexible, easy-to-use API. Why not build it yourself: Too many edge cases in drag-and-drop—multi-touch, keyboard navigation, screen readers, performance optimization... easy to miss 90% of scenarios when building yourself.

  • sanitize-html - HTML content sanitization The problem: User-submitted Markdown or HTML may contain XSS attack code (<script> tags, onerror events, etc.). The solution: Automatically sanitize dangerous content while preserving safe formatting (like <b>, <a>, etc.). Why not build it yourself: XSS attack vectors are numerous—not just <script>, but also event handlers, javascript: protocol, CSS injection... easy to miss an attack vector when building yourself.

  • browser-image-compression - Browser-side image compression The problem: User-uploaded photos are often several MB, overwhelming server bandwidth and slowing uploads. The solution: Compress images in the browser, reducing traffic by 80%, faster uploads, less server load. Why not build it yourself: Image compression involves Canvas API, EXIF preservation, multiple format support, Worker threads... at least hundreds of lines of code, and quality isn't guaranteed.

Date Handling

When you need it: When you need to format dates, calculate time differences, or handle time zones. JavaScript's native Date object API is cumbersome, and timezone handling is error-prone. These libraries provide friendlier APIs.

  • date-fns - Modern date utility library (recommended) Use case: Formatting dates, calculating time differences, functional API, supports tree-shaking

  • Day.js - Lightweight alternative Use case: Need Moment.js API but smaller footprint (2KB vs 67KB)

  • Luxon - The Moment.js team's new project Use case: Need robust timezone and internationalization support

Testing Frameworks

When you need it: When you need to ensure code quality and prevent regression bugs. Manual testing is too slow—change one thing, test ten places. Automated testing gives you confidence when modifying code.

  • Vitest - Fast unit testing framework (recommended) Use case: First choice for Vite projects, simple configuration, fast, Jest-compatible API

  • Playwright - E2E testing framework (tutorial recommended) Use case: Testing real user flows (login, checkout, payment), multi-browser support

  • Jest - Veteran testing framework Use case: Traditional choice for React projects, mature ecosystem

  • AVA - Concurrent testing framework Use case: Need to run tests concurrently for faster test execution

  • Mocha - Flexible testing framework Use case: Need highly customizable testing workflows

  • Sinon.JS - Test spies/stubs/mocks Use case: Need to mock function calls, monitor function behavior

  • Nock - HTTP mocking Use case: Need to mock external API responses during testing

CLI Tools

When you need it: When writing CLI tools, scripts, or automation tasks. Native console.log is too primitive, argument parsing must be built from scratch, and interactive prompts require handling various edge cases.

  • chalk - Terminal string styling Use case: CLI tools need colored output, highlighting important information

  • ora - Elegant terminal spinner Use case: Long-running tasks need progress animation display

  • Inquirer.js - Interactive command-line prompts Use case: Need user input, selection, confirmation (e.g., project initialization wizard)

  • zx - Write shell scripts in JavaScript Use case: Need to write complex automation scripts, more maintainable than Bash

  • commander - Command-line argument parsing Use case: Building complex CLI tools, need subcommands, options, help documentation

  • yargs - Command-line argument parsing Use case: Need more flexible argument parsing and validation

  • meow - CLI app helper Use case: Quickly build simple CLI tools

  • boxen - Create boxes in the terminal Use case: Need to display prominent message boxes in the terminal

  • Ink - Build CLI apps with React Use case: Need complex terminal UI (e.g., dashboards, real-time updates)

Logging

When you need it: When you need to track issues in production. console.log blocks the event loop under high concurrency, has no log levels, no structured output, no log rotation. Professional logging libraries improve performance and maintainability.

  • pino - Extremely fast logging library (recommended) The problem: console.log blocks the event loop under high concurrency, affecting performance. The solution: Asynchronous logging, 10x+ faster than console.log, supports structured output. Why not build it yourself: Async writing, log rotation, formatting, performance optimization... at least hundreds of lines of code, and not necessarily fast.

  • winston - Multi-transport async logging library Use case: Need to output to files, databases, remote services simultaneously

  • consola - Elegant console logging Use case: Development environment needs beautiful log output

  • debug - Lightweight debugging utility Use case: Need to toggle debug logs by module

File System

When you need it: When you need to manipulate files, directories, or watch for file changes. Node.js's built-in fs module API isn't user-friendly, lacks Promise support (older versions), and many common operations must be implemented yourself.

  • fs-extra - Enhanced fs module Use case: Need common operations like copying directories, ensuring directories exist, reading/writing JSON

  • globby - Match files with glob patterns Use case: Need to find files matching specific patterns (e.g., src/**/*.ts)

  • chokidar - File watcher Use case: Need to watch file changes and trigger actions (e.g., hot reload)

  • del - Delete files/folders Use case: Need to safely delete files, supports glob patterns

  • find-up - Find files upward Use case: Need to find the nearest config file (e.g., package.json)

Utility Libraries

When you need it: When you need to handle common programming tasks. While modern JavaScript is already powerful, some operations still benefit from utility libraries for simplification.

  • lodash - Utility library Use case: Need deep clone, debounce, throttle, and other utility functions (but prefer native JS when possible)

  • nanoid - Unique ID generator Use case: Need to generate short, secure, URL-friendly unique identifiers

  • ms - Time unit conversion Use case: Need to convert "2 days" to milliseconds

  • execa - Better child_process Use case: Need to execute external commands, more user-friendly than native API

  • dotenv - Load .env files Use case: Need to load environment variables from .env files

  • cheerio - Server-side jQuery Use case: Need to parse and manipulate HTML on the server side

  • jsdom - JavaScript implementation of the DOM Use case: Need to simulate browser environment in Node.js (e.g., for testing)

Build Tools

When you need it: When you need to bundle frontend code, transpile TypeScript, or optimize assets. Modern frontend projects rely on build tools to handle module bundling, code transpilation, asset optimization, dev servers, and more.

  • Vite - Modern frontend build tool (recommended) Use case: First choice for new projects, dev server starts instantly, extremely fast HMR

  • esbuild - Extremely fast JavaScript bundler Use case: Need extreme build speed, written in Go, 10-100x faster than JS-based tools

  • Rollup - ES module bundler Use case: Building libraries (not applications), produces smaller and cleaner output

  • webpack - Veteran bundler Use case: Maintaining legacy projects, or when specific webpack plugins are needed

  • Parcel - Zero-config bundler Use case: Rapid prototyping, don't want to write configuration files

Image Processing

When you need it: When you need to process images on the server side (resize, crop, format conversion, thumbnail generation). The browser has Canvas API, but the server side requires specialized libraries.

  • sharp - High-performance image processing (recommended) Use case: Need to process large volumes of images quickly, 4-5x faster than other libraries

  • jimp - Pure JavaScript image processing Use case: Need cross-platform compatibility, don't want to install native dependencies

  • qrcode - QR code generator Use case: Need to generate QR codes (payments, share links, etc.)

Email Sending

When you need it: When you need to send emails (registration confirmation, password reset, notifications). The SMTP protocol is complex, and email formats have many pitfalls (HTML, attachments, encoding)—these libraries handle them for you.

  • Nodemailer - Send emails Use case: Need to send emails, supports various SMTP services and transport methods

  • email-templates - Email templates Use case: Need to generate email content using template engines

  • MJML - Responsive email markup language Use case: Need to write HTML emails that display correctly across various email clients

Task Queues

When you need it: When you have time-consuming tasks that shouldn't block the main thread (sending emails, processing images, generating reports). Put tasks in a queue for async processing, with retry on failure and concurrency limiting.

  • BullMQ - Redis-based task queue (recommended) Use case: Need reliable task queue with support for priorities, delays, retries, and concurrency control

  • Agenda - MongoDB-based job scheduling Use case: Already using MongoDB, need scheduled task scheduling

  • Bree - Job scheduler Use case: Need cron-style scheduled tasks with worker thread support

  • node-resque - Redis job queue Use case: Need compatibility with Ruby's Resque

Process Management

When you need it: When you need to run Node.js applications in production. If the Node.js process crashes, the site goes down. Use nodemon for auto-restart in development, but production needs more robust process managers.

  • PM2 - Process manager (recommended) Problem faced: Node.js process crashes, site goes down, have to restart manually. No log management, can't tell what went wrong. Solution: Auto-restart, load balancing, log management, monitoring dashboard—all with one command. Why not build your own: Process monitoring, crash restart, log rotation, cluster management... would take at least thousands of lines of code to build yourself, and it might not even be stable.

  • nodemon - Auto-restart dev server Use case: Development environment, auto-restart server when code changes

Node.js Version Management

When you need it: When you need to switch between Node.js versions for different projects. Different projects may require different Node.js versions, and manually installing/uninstalling is too cumbersome.

  • fnm - Fast Node.js version manager (recommended) Use case: Need to switch Node.js versions quickly, written in Rust, much faster than nvm

  • nvm - Node.js version manager Use case: Most popular version manager, largest community resources

  • n - Simple version manager Use case: Need the simplest version switching tool

Parsers

When you need it: When you need to parse and process data in various formats (Markdown, YAML, XML, CSV). Hand-written parsers are error-prone; these libraries are thoroughly tested and handle various edge cases.

  • markdown-it - Markdown parser Use case: Need to convert Markdown to HTML, supports plugin extensions

  • remark - Markdown processor Use case: Need complex transformations and processing of Markdown

  • js-yaml - YAML parser Use case: Need to read and write YAML configuration files

  • xml2js - XML parser Use case: Need to parse XML data (e.g., RSS, SOAP)

  • csv-parser - CSV parser Use case: Need to process CSV files (import/export data)

  • PEG.js - Parser generator Use case: Need to parse custom syntaxes (e.g., DSLs, configuration languages)

Compression

When you need it: When you need to create or extract archives (backups, file downloads, asset bundling). Node.js's built-in zlib module only supports gzip; these libraries support more formats.

  • Archiver - Create ZIP/TAR archives Use case: Need to bundle multiple files for user download

  • pako - Pure JS implementation of zlib Use case: Need to compress/decompress data in the browser

Security

When you need it: When you need to protect web applications from common attacks (XSS, CSRF, clickjacking, SQL injection). Security issues are easily overlooked; these libraries help you set correct HTTP headers and protection measures.

  • helmet - Express security middleware Use case: Need to set secure HTTP response headers (CSP, HSTS, etc.)

  • rate-limiter-flexible - Rate limiting Use case: Need to prevent brute force attacks, DDoS attacks, and limit API call frequency

  • crypto-hash - Asynchronous hashing Use case: Need to compute hash values for files or data

Static Site Generators

When you need it: When you need to build documentation sites, blogs, or marketing pages. Static sites load fast, are secure, and easy to deploy. These generators let you write content in Markdown and automatically generate beautiful websites.

  • VitePress - Vue-powered static site generator (used in this tutorial) Use case: Building documentation sites, based on Vite, fast, beautiful themes

  • Astro - Modern static site generator Use case: Need extreme performance, supports multiple frameworks (React, Vue, Svelte)

  • Docusaurus - React documentation site generator Use case: Building product documentation, feature-complete, from Facebook

  • Hexo - Blog framework Use case: Quickly set up personal blogs, rich themes

CMS (Content Management Systems)

When you need it: When you need to let non-technical people manage website content. Building your own admin backend takes weeks or even months; these CMS solutions provide out-of-the-box content management interfaces.

  • Strapi - Headless CMS Use case: Need flexible content management backend, serving content via API

  • Ghost - Blogging platform Use case: Professional blogging and publishing platform, great editing experience

  • KeystoneJS - CMS and web application platform Use case: Need to quickly build data-driven applications and admin backends

Package Managers

When you need it: When you need to install and manage npm packages. npm is the default package manager, but there are faster, more disk-space-efficient alternatives.

  • pnpm - Disk-space-efficient package manager (recommended in this tutorial) Use case: Need to save disk space (hard links for shared dependencies), fast installation

  • npm - Default package manager Use case: Comes with Node.js, best compatibility

  • yarn - Alternative package manager Use case: Need offline installation, deterministic dependency resolution

  • bun - All-in-one toolkit Use case: Need extreme speed, integrates runtime, bundler, and test framework

Complete List

The above are just the most commonly used libraries. For the complete Node.js ecosystem resources, check out:

How to Evaluate a Library?

After finding candidate libraries, use this checklist for quick assessment:

Quick Assessment Checklist

  • GitHub stars > 1000 (indicates a user base)
  • Updated in the last 6 months (indicates maintenance)
  • Issues responded to promptly (indicates responsible authors)
  • Complete documentation and examples
  • TypeScript support (if you use TS)
  • ⚠️ Reasonable number of dependencies (too many dependencies = potential risk)
  • ⚠️ Reasonable package size (check with bundlephobia)
  • ⚠️ Friendly license (MIT/Apache 2.0, etc.)

Let Claude Code Help You Evaluate

Send the library's README and package.json to Claude Code and ask:

Is this library suitable for my project? Are there better alternatives?
Please evaluate from the following angles:
1. Maintenance status
2. Community activity
3. Documentation quality
4. Performance
5. Are there better alternatives?

Claude Code will give you detailed analysis and recommendations.

When Can You "Reinvent the Wheel"?

Only consider writing your own in these situations:

  1. Existing solutions don't meet your needs (but first confirm you've really searched everywhere)
  2. Learning purposes (but don't use in production)
  3. Extreme performance optimization (but profile first, don't optimize prematurely)
  4. Dependencies too heavy (a simple feature introducing 100MB of dependencies isn't worth it)

Xiao Ming listened, reopened Claude Code, and this time asked differently: "I need a React data fetching library that supports caching and automatic revalidation."

A few seconds later, Claude Code replied:

Two recommendations:

1. SWR (recommended for beginners)
   - Lightweight (~5KB)
   - Automatic caching and revalidation
   - Simple and easy to use
   - Officially maintained by Vercel

2. TanStack Query (more powerful features)
   - Powerful cache management
   - Supports infinite scroll, pagination
   - Has DevTools
   - Suitable for complex scenarios

Your project is a simple CRUD application, so I recommend SWR.
Do you need me to help you write the integration code?

Xiao Ming chose SWR, and Claude Code immediately generated complete usage examples. From finding the library to integration, less than 5 minutes.

"See?" said the master. "Same AI, different question, completely different results. Ask it to build wheels for you, you get hundreds of lines of unverified code. Ask it to help you choose wheels, you get mature solutions that have been validated millions of times in production."


Next Step

After learning to find wheels, next learn how to efficiently integrate these libraries with AI—4.7 API Integration in Practice.

Alpha Preview:This is an early internal build. Some chapters are still incomplete and issues may exist. Feedback is very welcome on GitHub.