Registry / devops / react-use-rest

react-use-rest

JSON →
library1.9.0jsnpmunverified

Provides React hooks for fetching and mutating REST API data. v1.9.0 (last release) relies on axios and use-store-hook to share cached state across components without Context or prop-drilling. Offers auto-loading, polling, query support, and collection self-maintenance. Designed for React 16.10+, but no longer actively maintained; alternatives include React Query, SWR, and RTK Query.

npm install react-use-rest
INSTALL
IMPORT
SIG · REACT-USE-REST
R
react-use-rest
devopsjavascriptv1.9.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createRestHook
import { createRestHook } from 'react-use-rest'
import createRestHook from 'react-use-rest'
Named export, not default. Common mistake.
createRestHook
const { createRestHook } = require('react-use-rest')
const createRestHook = require('react-use-rest')
CJS destructuring required.
useKittens (custom)
const useKittens = createRestHook('/api/kittens')
const { useKittens } = createRestHook('/api/kittens')
createRestHook returns a function, not an object.

Create a REST hook for /api/kittens and display loading state and data.

import React from 'react'; import { createRestHook } from 'react-use-rest'; const useKittens = createRestHook('/api/kittens'); export default function App() { const { data: kittens, isLoading } = useKittens(); return <div>{isLoading ? 'loading...' : `Found ${kittens.length} kittens!`}</div>; }
Debug
Known issues
deprecatedPackage is no longer actively maintained; no updates since 2020.
fix
Consider migrating to React Query, SWR, or RTK Query.
affects: >=1.0.0
breakingReact 16.10+ required; does not support React 18's concurrent features.
fix
Upgrade React to 16.10+ or use alternative hooks library.
affects: >=1.0.0
gotchacreateRestHook returns a custom hook, not a component or object; do not destructure it.
fix
Use const useMyHook = createRestHook(endpoint) directly.
affects: >=1.0.0
gotchaUses use-store-hook for global state; mutations update shared state across components automatically.
fix
No action needed, but be aware of unexpected side effects.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: createRestHook is not a function
Importing as default instead of named export.
fix
Use import { createRestHook } from 'react-use-rest'
Uncaught Error: Could not find 'store' in context
Missing peer dependency use-store-hook or outdated version.
fix
Run npm install use-store-hook@latest
Cannot read property 'length' of undefined
Data is undefined on initial render before fetch completes.
fix
Check isLoading and data existence: let { data, isLoading } = useKittens(); if (isLoading) return '...';
Upgrade
Version history
1.9.0latest on npm
Audit
Dependencies
reactrequiredpeer dependency required for hooks
react-domrequiredpeer dependency required
Agent activity
6 hits · last 30 days
node
6
Resources
react-use-rest — npm install react-use-rest · libregistry