Registry / devops / rtk-query-axios

rtk-query-axios

JSON →
library1.0.1jsnpmunverified

A CLI tool that scaffolds RTK Query + Axios integration into React or Next.js apps with a single command. Version 1.0.1 installs @reduxjs/toolkit, react-redux, axios, and js-cookie, and copies a ready-to-use redux/ folder with base query setup, root API slice, example service, store, hooks, and Redux provider. It automatically detects whether a src/ directory exists and places files accordingly. Key differentiator: opinionated but minimal setup for RTK Query with Axios as the HTTP client, including cookie-based auth token injection.

npm install rtk-query-axios
INSTALL
IMPORT
SIG · RTK-QUERY-AXIOS
R
rtk-query-axios
devopsjavascriptv1.0.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.

useGetExampleByIdQuery
import { useGetExampleByIdQuery } from '@/redux/services/example/example'
import useGetExampleByIdQuery from '@/redux/services/example/example'
The hook is a named export from the service file, not default.
ReduxProvider
import ReduxProvider from '@/redux/Provider'
import { ReduxProvider } from '@/redux/Provider'
ReduxProvider is the default export of the generated Provider.tsx.
store
import { store } from '@/redux/store/store'
import store from '@/redux/store/store'
store is a named export from the generated store file.

Scaffolds a redux/ folder with RTK Query + Axios integration, overwriting existing files.

npx rtk-query-axios --force
Debug
Known issues
gotchaFolder placement depends on existence of src/ directory: if src/ exists, files go under src/redux/; otherwise at project root redux/.
fix
Ensure your project's source structure is consistent before running. Use --force to overwrite.
affects: <=1.0.1
gotchaThe CLI installs packages (react-redux, @reduxjs/toolkit, axios, js-cookie) even if already present, potentially causing version conflicts.
fix
Review installed versions after scaffolding and adjust package.json if needed.
affects: <=1.0.1
deprecatedThe generated base query uses js-cookie to read token; if you use a different auth mechanism (e.g., localStorage), you must modify the base query manually.
fix
Edit redux/baseQuery/axiosBaseQuery.ts to read token from your preferred source.
affects: <=1.0.1
gotchaThe generated Provider.tsx expects the store to be at '@/redux/store/store', which may not match your project's alias setup.
fix
Update the import path in Provider.tsx to match your project's alias configuration.
affects: <=1.0.1
Errors
Common errors & fixes
Error: Cannot find module '@/redux/Provider'
The alias '@' is not configured in your project; generated imports use '@/' path prefix.
fix
Configure the '@' path alias in tsconfig.json (paths: {'@/*': ['./src/*']}) or update import paths in the generated files.
TypeError: Cannot read properties of undefined (reading 'useGetExampleByIdQuery')
The generated service hooks are not correctly exported or imported.
fix
Ensure the service file exports the hook and the import path matches (e.g., '@/redux/services/example/example').
npx: command not found: rtk-query-axios
npx is not installed or the package name is misspelled.
fix
Use 'npx rtk-query-axios' (exact spelling) and ensure npm >= 5.2.0.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
@reduxjs/toolkitrequiredCore RTK dependency for redux store and RTK Query
react-reduxrequiredRequired for Redux Provider and hooks
axiosrequiredHTTP client used by the generated base query
js-cookierequiredUsed for reading auth token cookie in the generated base query
Agent activity
6 hits · last 30 days
node
6
Resources
rtk-query-axios — npm install rtk-query-axios · libregistry