fetchlane
v0.0.1
Published
Lightweight React data-fetching utility with caching, retry, and deduplication.
Maintainers
Readme
🚀 FetchLane
Lightweight React data-fetching utility with caching, retry, and request deduplication.
Simplify API handling in your React apps — no more repetitive loading, error, and state management.
📦 Installation
npm install fetchlane⚡ Quick Usage
import { SmartLoader } from "fetchlane";
const getUser = async () => {
const res = await fetch("/api/user");
return res.json();
};
<SmartLoader api={getUser}>{(data) => <UserCard user={data} />}</SmartLoader>;✨ Features
- 🔄 Automatic API execution
- ⏳ Built-in loading state
- ❌ Flexible error handling
- ⚡ Smart caching with TTL
- 🔁 Retry failed requests
- 🚫 Request deduplication (no duplicate API calls)
- ⏱️ Optional loading delay (better UX)
- 🐛 Debug mode for development
- 🎯 Clean and minimal API
📌 Component Example
<SmartLoader
api={getUser}
skeleton={<p>Loading...</p>}
error={(err) => <p>{err.message}</p>}
>
{(data) => <UserCard user={data} />}
</SmartLoader>🛠️ Hook Usage
import { useSmartLoader } from "fetchlane";
const { data, loading, error, refetch } = useSmartLoader(getUser, {
cache: true,
ttl: 5000,
retry: 2,
delay: 300,
debug: false,
});⚙️ Options
| Option | Type | Default | Description | | ------ | ------- | ------- | --------------------------- | | cache | boolean | true | Enable caching | | ttl | number | - | Cache expiry time (ms) | | retry | number | 0 | Retry failed requests | | delay | number | 0 | Delay before showing loader | | debug | boolean | false | Enable debug logs | | key | string | auto | Custom cache key |
🔄 How It Works
API Call
↓
Check Cache
↓
Check Pending Request (Deduplication)
↓
Execute API
↓
Store in Cache
↓
Return Data🎯 When to Use
Use FetchLane when you want:
- Simple API handling without heavy libraries
- Lightweight alternative to React Query
- Clean and readable code
📄 License
MIT © 2026 FetchLane Contributors
🤝 Contributing
Contributions are welcome! Feel free to open issues or submit pull requests.
💬 Support
If you have any questions or issues, please open an issue on the GitHub repository.
