"Building my first npm package: use-fetch-smart for React devs"

✨ A small personal win — but a big moment for me as a developer. For a long time, I wanted to build my own npm package. Nothing huge… just something useful — something I could proudly say: “I built this.” While working on multiple React projects, I kept fighting with the same issues: 1.messy fetch logic 2.repeated loading/error states 3.caching not behaving the way I wanted 4.retry logic 5.token refresh problems 6.too much boilerplate everywhere At some point I asked myself: “Why am I rewriting the same logic in every project? Let me turn this into a proper reusable hook.” So… I finally did it. 🚀 Introducing my first npm package: use-fetch-smart A lightweight React hook for smart data fetching — with caching, TTL, retries, token refresh, and instant cached responses. GitHub Repo: (in comments) npm: (in comments) 🔧 What it comes with ⚡ Smart caching + configurable TTL 🔁 Retry logic 🔐 Auto token refresh 🎯 Simple mutation API 🚀 Instant cached responses 🧽 Cleaner code, less boilerplate This is my first ever published package, and I know it’s not perfect. That’s actually why I’m sharing it. I want feedback. I want criticism. I want to know what breaks, what confuses you, what can be improved. Open-source is all about learning publicly — so here I am, starting small but starting somewhere. If you’re a React dev, I’d genuinely love if you try it out and share your thoughts. Even a single suggestion will help me grow and make this tool better. 🙏 Here’s to building, shipping, learning, and improving — one step at a time. 💛 #reactjs #npm #opensource #javascript #webdevelopment #frontend

  • No alternative text description for this image

We already have a solution for this called tanstack query, this feels like reinventing the wheel again, any special feature this package has which is not there in tanstack? If yes, then people will definitely consume it, else everyone will stick to Tanstack query as it provides more features apart from data fetching. Another big issue is the maintenance of your package which you have to do in order to gain trust of the consumer as if people are using your package and you forgot to maintain it and it has a breaking change, it will break people project.

Great work, Zaid! This is such a clean and practical solution. The smart caching and clean API are exactly what's needed it perfectly bridges the gap between a simple fetch and a complex external library. Have you considered adding a plugin system for custom cache adapters? That could make this even more extensible for enterprise use cases! Congrats on the launch! 🎉👏

Great work zaid shaikh Big kudos for taking your experience and transforming it into something the community can benefit from. I love how you identified repetitive pain points across projects and built a thoughtful, feature-rich solution instead of rewriting the same logic. Great work!

See more comments

To view or add a comment, sign in

Explore content categories