Registry / devops / ra-data-django-rest-framework

ra-data-django-rest-framework

JSON →
library0.2.1jsnpmunverified

React-admin data and authentication provider for Django REST Framework (DRF). Current stable version is 0.2.1, targeting react-admin 3.x via peer dependency ra-core ^3.5.3. Provides sorting, pagination with PageNumberPagination, filtering (generic and DjangoFilterBackend), and two authentication providers: token-based (TokenAuthentication) and JWT (JSON Web Token Authentication). Compared to generic providers, it directly maps react-admin query parameters to DRF's URL parameters, simplifying integration. Requires Node >=10. Ships TypeScript types.

npm install ra-data-django-rest-framework
INSTALL
IMPORT
SIG · RA-DATA-DJANGO-RES
R
ra-data-django-rest-framework
devopsjavascriptv0.2.1
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.

drfProvider
import drfProvider from 'ra-data-django-rest-framework'
const drfProvider = require('ra-data-django-rest-framework')
Package uses default ESM export. CommonJS require may not work depending on bundler configuration.
tokenAuthProvider
import { tokenAuthProvider } from 'ra-data-django-rest-framework'
const tokenAuthProvider = require('ra-data-django-rest-framework').tokenAuthProvider;
Named export for token-based authentication provider. ESM-only syntax recommended.
jwtTokenAuthProvider
import { jwtTokenAuthProvider } from 'ra-data-django-rest-framework'
Named export for JWT authentication provider.
fetchJsonWithAuthToken
import { fetchJsonWithAuthToken } from 'ra-data-django-rest-framework'
Named export for custom httpClient with token auth header.
fetchJsonWithAuthJWTToken
import { fetchJsonWithAuthJWTToken } from 'ra-data-django-rest-framework'
Named export for custom httpClient with JWT auth header.

Minimal setup: import default drfProvider, create data provider with API base URL, and use in react-admin Admin component.

import drfProvider from 'ra-data-django-rest-framework'; import { Admin, Resource } from 'react-admin'; import { PostList } from './posts'; const dataProvider = drfProvider(process.env.REACT_APP_API_URL || '/api'); const App = () => ( <Admin dataProvider={dataProvider}> <Resource name="posts" list={PostList} /> </Admin> ); export default App;
Debug
Known issues
gotchaAuthentication providers (tokenAuthProvider, jwtTokenAuthProvider) require corresponding fetchJsonWithAuth* httpClient to be passed to drfProvider.
fix
When using authentication, always pass the httpClient as second argument: drfProvider('/api', fetchJsonWithAuthToken).
affects: <=0.2.1
deprecatedPackage targets react-admin 3.x via peer dependency ra-core ^3.5.3. Not tested with react-admin 4.x or 5.x.
fix
For react-admin 4+, consider using the official ra-data-simple-rest or a raw fetchJson provider.
affects: <=0.2.1
gotchaPagination only supports PageNumberPagination. Other pagination styles (e.g., LimitOffsetPagination) may not work.
fix
Ensure your DRF API uses PageNumberPagination or customize pagination class.
affects: <=0.2.1
gotchaDefault obtainAuthTokenUrl is '/api-token-auth/' and '/api/token/' for JWT; if your DRF URLs differ, provide options.
fix
Pass URL in options: tokenAuthProvider({obtainAuthTokenUrl: '/custom-auth/'})
affects: <=0.2.1
Errors
Common errors & fixes
Module not found: Can't resolve 'ra-data-django-rest-framework'
Package not installed or missing from node_modules.
fix
Run 'npm install ra-data-django-rest-framework' and ensure it's in dependencies.
Uncaught TypeError: drfProvider is not a function
Incorrect import or default export not recognized (e.g., using named import instead of default).
fix
Use import drfProvider from 'ra-data-django-rest-framework' (default import).
Error: Cannot find module 'ra-core'
Missing peer dependency ra-core.
fix
Install ra-core: 'npm install ra-core@^3.5.3'
Error: No auth token found in localStorage
Using authentication but user not logged in.
fix
Login using authProvider before making requests.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
ra-corerequiredPeer dependency; provides core react-admin interfaces for data providers and auth providers.
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
ra-data-django-rest-framework — npm install ra-data-django-rest-framework · libregistry