Migrating from react-grabkit
The react-grabkit npm package is deprecated and no longer maintained. Grabkit is a focused HTTP client; React hooks and providers are intentionally out of scope.
What changes
Section titled “What changes”Before (react-grabkit) | After (grabkit) |
|---|---|
Hooks such as useGrab | Your data layer (TanStack Query, SWR, Relay, etc.) |
| Provider / context | Factory per API origin: const grab = grabkit(baseURL) |
| Framework-coupled errors | Tuple [data, error, meta] + if (error) |
Minimal migration
Section titled “Minimal migration”- Remove
react-grabkitfrom dependencies. - Install
grabkit. - Create a grab callable where you previously configured the provider:
import grabkit from 'grabkit';
export const grab = grabkit(process.env.API_URL!, { casing: 'camelCase',});- Call
grabinside your existing query/mutation functions. UseorThrowwhen the data layer expects thrown errors:
import grabkit, { orThrow } from 'grabkit';
const grab = grabkit(process.env.API_URL!);
async function fetchUser(id: string) { const [data] = await orThrow(grab(`GET /users/${id}`)); return data;}Grabkit still returns errors in the tuple by default; orThrow is optional sugar for throw-based caches. See Errors & results.
Data layer examples
Section titled “Data layer examples”Full walkthroughs:
- TanStack Query
- SWR
- Node.js (server-side)
Version 1.0 defaults
Section titled “Version 1.0 defaults”grabkit 1.0.0 defaults to JSON:API. If your API is plain JSON, set format: 'json' on the factory. See Plain JSON.