Repository navigation
Releases: tylerdgenius/netwrap
Releases · tylerdgenius/netwrap
Release list
v4.0.0
netwrap v4.0.0
Date: 2026-01-19
Highlights
- New client entry point:
netwrap/clientfor React hooks and client-only usage. useFetcherhook for client components with loading/error/data state.- Clear split between server-safe utilities (
netwrap) and client hooks (netwrap/client).
Deprecations
- Using
fetcherinside client components is deprecated. UseuseFetcherinstead.
Migration Notes
- Update client components to import hooks from
netwrap/client. - If you rely on
fetcherin client components, plan to migrate touseFetcher.
API Summary
fetcher(options)
Returns:
trigger(triggerData?)dataerrorisLoadinggetData()getError()getIsLoading()onLoadingChange(listener)onDataChange(listener)onErrorChange(listener)invalidateCache()
useFetcher(options)
Returns:
trigger(triggerData?)dataerrorisLoadinginvalidateCache()
Notes
useFetchermust be imported fromnetwrap/clientand used only in client components.fetcheris not reactive; avoid destructuringdataorerrorif you expect live updates.fetchercache is instance-local; recreate the instance to reset the cache.
v2.0.4
Built base for making and simulating data calls
In this release you have access to the function generators which enable you to simulate data calls as well as have live calls in your app when you import them into your app from the package.
This means you can do something like this
// Define the hook configuration
const hookConfig = {
name: "myFetchDataHook", // Specify a name for your hook
dataCallerType: "axios", // Set the DataCallerType to "axios"
method: "get", // Specify the HTTP method (default: "get")
url: "https://api.example.com/data", // Specify the URL
/** Other optional props below can be included depending on your use case */
requestData: { key: "value" }, // Include data to be sent in the request body (optional)
signal: undefined, // Specify the AbortSignal object for canceling requests (optional)
headers: { "Content-Type": "application/json" }, // Include HTTP headers (optional)
onUploadProgess: (e: ProgressEvent) => {
console.log("Upload Progress:", e.loaded);
}, // Include a function to handle upload progress (optional)
};
// Call the hook generator with the hook configuration
const { functions, loaders } = useFunctionGenerator(hookConfig);
const handleGetData = async () => {
try {
const result = await functions.takeAction();
console.log("Data:", result.payload);
} catch (error) {
console.error("Error:", error);
}
};
```javascript
Study the readme below to understand how to use this version properly. If you have any issues, kindly add them to this repo or fork the repo branch and raise a PR
[README.md](https://github.com/metrobuzz-com-ng/netwrap/files/14138237/README.md)
### Note
This will be removed once we move to version 3