npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

unfee

v1.0.6

Published

Fetch API with sensible defaults

Readme

unfee

zero-dependencies TypeScript first tiny fetch wrapper that comes with good defaults.

Quick start

Install:

pnpm install unfee

Import:

import { unfee } from 'unfee'

Usage:

import { unfee } from 'unfee'

const [error, data] = await unfee<{ id: string }>('https://jsonplaceholder.typicode.com/todos/1')
if (error) {
  console.error(error)
  return
}
console.log(data.id)

Benefits over plain fetch

  • Simple API
  • Treat non-2xx status codes as errors
  • Retry failed requests
  • Timeout support
  • Instances with custom defaults
  • Hooks
  • TypeScript niceties

JSON

JSON is used by default. FormData, URLSearchParams, or string bodies override the Content-Type automatically.

Example:

const [_, todos] = await unfee('/todos', {
  method: 'GET',
  data: { key: 'value' },
})

Error handling

Error handling is a first-class citizen in unfee.

The function returns an error as its first value. When response.ok is false, the error will be populated accordingly.

const [error] = await ofetch('https://httpbin.org/status/404')
//      ^
//      fetch-error: Request failed: [GET https://httpbin.org/status/404]

unfee comes with HTTPError, ParseError types.

Timeout

You can specify a timeout (in milliseconds) to automatically abort a request.

const [error, data] = await ofetch('/api', { timeout: 10000 })

Retry

Requests are automatically retried when certain errors occur. By default, retries are triggered for the following status codes:

  • 408 — Request Timeout
  • 409 — Conflict
  • 425 — Too Early
  • 429 — Too Many Requests
  • 500 — Internal Server Error
  • 502 — Bad Gateway
  • 503 — Service Unavailable
  • 504 — Gateway Timeout

Requests using the POST, PUT, PATCH, and DELETE methods are not retried by default to avoid unintended side effects.

You can customize the retry behavior:

const [error, data] = await unfee('/api', {
  retry: {
    times: 5,
    delay: 500,
    statusCode: new Set([500]),
  },
})

Global instances

You can create a new instance with a custom configuration to share common options across requests.

import { unfee } from 'unfee'

const api = unfee.extend({
  baseUrl: 'http://api.test/',
  headers: {
    Authorization: 'Bearer xxx',
  },
})

const [error, data] = await api('/endpoint', {
  retry: {
    times: 2,
  },
})

Hooks

You can hook into request lifecycle events using the hooks option. Each hook lets you run custom logic at a specific stage of the request.

Available hooks:

  • beforeRequest(options) — called before the request is sent. Useful for modifying headers or request options.
  • afterResponse(request, response, options) — called after a successful response is received.
  • onRequestError(error, request, options) — triggered when a request fails before receiving a response.
  • onResponseError(error, response, request, options) — triggered when the server responds with an error status.
  • onResponseParseError(error, response, request, options) — called when response parsing fails.
  • onRequestRetry(retryCount, response, request, options) — called before a request is retried.

Example:

const [error, data] = await unfee('/api', {
  hooks: {
    beforeRequest(options) {
      console.log('Sending request...')
    },
    afterResponse(request, response) {
      console.log('Received response:', response.status)
    },
  },
})