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

smart-fetch-pro

v1.0.1

Published

A smart fetch wrapper with retries, caching, error handling, loading states, and React support.

Readme

📦 smart-fetch-pro

Effortless API requests with retry logic, error handling, caching, and React support — built on native fetch.


🔥 Why Use smart-fetch-pro?

Making API requests in modern apps requires more than just calling fetch():

  • ❌ Repeating try-catch blocks
  • ❌ Manually handling retries
  • ❌ Lack of built-in caching
  • ❌ Messy code in React components

smart-fetch-pro solves all of this with:

✅ Retry support
✅ Error handling
✅ In-memory caching
✅ React hook: useSmartFetch
✅ Request/Response interceptors
✅ Lightweight & TypeScript-ready


📌 Installation

```bash`` npm install smart-fetch-pro


🧑‍💻 Usage

Basic Fetch with Retry

import { fetchSmart } from 'smart-fetch-pro';

const data = await fetchSmart('/api/user', { retries: 3, retryDelay: 1000, });

With Caching

const data = await fetchSmart('/api/products', { cacheTTL: 60000, // 1 min in-memory cache });

React Hook

import { useSmartFetch } from 'smart-fetch-pro';

const { data, error, isLoading } = useSmartFetch('/api/posts');

if (isLoading) return Loading...; if (error) return Error: {error.message};

return ;

🧠 Real-World Use Cases

1. 📊 Dashboard Analytics with Retry + Cache

const stats = await fetchSmart('/api/stats', { retries: 2, cacheTTL: 30000, });

✅ Reduces server load ✅ Improves stability on flaky APIs ✅ Prevents duplicate requests

2. 🛍️ E-commerce Product List in React

const { data, isLoading, error } = useSmartFetch('/api/products');

✅ Cleaner UI code ✅ Handles loading/error automatically ✅ Great DX (developer experience)

3. 🔐 Add Global Authorization Header (via Interceptor)

import { setRequestInterceptor } from 'smart-fetch-pro';

setRequestInterceptor((config) => { config.headers['Authorization'] = Bearer ${getToken()}; return config; });

✅ DRY authentication logic ✅ Supports all requests globally

⚙️ Features Overview

| Feature | Native Fetch | Axios | smart-fetch-pro | | --------------------- | ------------ | ----- | --------------- | | Retry Support | ❌ | ✅ | ✅ | | React Hook | ❌ | ❌ | ✅ | | In-Memory Caching | ❌ | ❌ | ✅ | | Request Interceptor | ❌ | ✅ | ✅ | | Response Interceptor | ❌ | ✅ | ✅ | | TypeScript Support | ⚠️ Partial | ✅ | ✅ | | Lightweight (no deps) | ✅ | ❌ | ✅ |

📈 Coming Soon

✅ Response schema validation

✅ Offline queue support

✅ Retry on network failure with exponential backoff

✅ Logging and devtools integration

🧰 API Reference

fetchSmart(url, options) Make smart fetch calls with retry, error handling, and caching.

url – API endpoint (string)

options – Optional fetch options with:

retries (number)

retryDelay (ms)

cacheTTL (ms)

headers, body, etc.

useSmartFetch(url, options) React hook for using fetchSmart with internal state.

setRequestInterceptor(fn) Add logic to modify request before it is sent.

setResponseInterceptor(fn) Add logic to process or transform response data.

💡 Tip for Devs

Think of smart-fetch-pro as the bridge between vanilla fetch, Axios, and SWR — giving you the best of all worlds, in one neat package.