
superagent
A small JavaScript library for making HTTP requests in Node.js and browsers.
- Stars
- 16.6k
- Forks
- 1.3k
- Licence
- MIT
- Language
- JavaScript
- Last update
- 1 months ago
- Type
- Library
What it is
Superagent is a JavaScript library that sends HTTP requests, such as fetching data from or posting data to a web server. It uses the same API in Node.js and in the browser, and it supports common client features like JSON bodies, headers, query strings, and promises or callbacks. The README describes it as small and extensible through plugins.
- Send a JSON POST request to an API with custom headers
- Fetch data from a server in a browser page using a script tag or bundler
- Add query strings and per-request plugins such as caching prevention or URL prefixing
- Use async/await to handle API responses and errors in a Node.js script
Great for
- JavaScript developers who want one HTTP client API that works in both Node.js and browsers
- Projects that need to call web APIs with JSON request bodies and custom headers
- Developers who want to extend request behavior with plugins
- Teams that prefer callback, then/catch, or async/await styles
Not ideal for
- Projects that only need the built-in fetch API and want zero dependencies, since the README does not compare sizes or dependency counts beyond the browser bundle size
- Users on older environments below Node v14.18.0 or the listed browser versions, because the README lists these as supported minimums
How to get it
- 1
Install with a package manager
You'll need: Node.js v14.18.0 or newer
Install with npm
npm install superagentInstall with yarn
yarn add superagent - 2
Run it
- Install the package with npm or yarn
- In a Node.js file, add const superagent = require('superagent');
- Send a request such as superagent.post('/api/pet').send({ name: 'Manny', species: 'cat' })
- Handle the result with .then/.catch or with async/await inside a try block
- 3
Get the most out of it
- Use the plugin list in the README, such as superagent-mock for simulated responses in tests
- Add superagent-prefix to prefix URLs in a test environment
- Use superagent-cache or superagent-cache-plugin if you need caching
- See the GitHub releases page and wiki for upgrade notes and extensions like couchdb and oauth
Downloads
Strengths
- Same API works in Node.js and browsers, as the README states
- Extensible through a list of existing plugins such as superagent-cache and superagent-mock
- Supports callback, promise, and async/await usage styles
Trade-offs
- Browser support needs polyfills for some older browsers, such as WeakRef and BigInt on certain iOS Safari versions
- Breaking changes in earlier major versions were tied to stricter error handling, so upgrades need reading the release notes
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| superagent (this) | 16.6k | Library | beginner | 1 months ago | JavaScript developers who want one HTTP client API that works in both Node.js and browsers |
| axios | 109k | Library | beginner | 4 days ago | JavaScript developers calling REST or other HTTP APIs from a browser front end |
| got | 15k | Library | beginner | 7 days ago | Node.js developers who call web APIs from server-side code |
| ky | 17.1k | Library | beginner | 28 days ago | JavaScript or TypeScript developers who already use fetch and want less boilerplate |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.