nim-redux-cli
Version:
nim-redux-cli is a simple tool to set up a Redux project with RTK Query and React Router. It provides a quick and easy way to get started with a Redux setup for your project. It also includes a simple setup for a basic React Native project.
161 lines (112 loc) โข 3.21 kB
Markdown
# nim-redux-cli
โก A powerful CLI tool to quickly set up Redux with either RTK Query or traditional reducers for React, Next.js, React Native, and Expo projects.
## ๐ง What does it do?
This CLI automatically:
- Detects your project type (React, Next.js, React Native, or Expo)
- Asks you to choose between RTK Query or a Normal Reducer setup
- Creates all necessary Redux folder structure and files
- Injects the Redux `<Provider>` into the correct app entry point
- Installs all required dependencies
- Includes optional auth mutation setup for RTK Query
## ๐ฆ Installation
Install globally via npm:
```bash
npm install -g nim-redux-cli
```
Or use it directly without installing globally:
```bash
npm install nim-redux-cli
npx nim-redux-cli
```
## ๐ Getting Started
First, create your project using your preferred framework:
```bash
npx create-react-app my-app
# or
npx create-next-app my-app
# or
npx create-expo-app my-app
# or
npx @react-native-community init my-app
```
Then, navigate to your project folder:
```bash
cd my-app
```
Run the tool:
```bash
npx nim-redux-cli
```
Youโll be prompted to choose a Redux setup type:
- RTK Query
- Normal Reducer
Based on your selection, it will generate the required structure and logic.
## ๐งฑ File Structure Generated
Depending on your choice, this tool will create files like:
For RTK Query:
```
src/
redux/
store.js
service/
backendApi.js
authSlice.js
utils/
constant.js
lib/
axios.js
```
For Normal Reducer:
```
src/
redux/
store.js
slices/
authSlice.js
```
Additionally, the tool will wrap your app with the Redux `<Provider>` in the correct entry file:
- React: `src/main.jsx` or `src/main.js` or `src/main.tsx`
- Next.js: `app/layout.jsx` or `pages/_app.js` or `pages/_app.tsx`
- React Native: `App.js` or `App.tsx` or `App.jsx`
- Expo: `app/_layout.js` or `app/_layout.jsx` or `app/_layout.tsx`
## ๐ฆ Dependencies Installed Automatically
- `@reduxjs/toolkit`
- `react-redux`
- `axios` (for RTK Query setup)
## ๐งช Example Output
```bash
npx nim-redux-cli
```
```
? Choose Redux setup: (Use arrow keys)
โฏ RTK Query
Normal Reducer
๐ Created directory: /your-project/src/redux
๐ Created file: /your-project/src/redux/store.js
๐ Created file: /your-project/src/redux/service/backendApi.js
๐ Created file: /your-project/src/redux/service/authSlice.js
๐ Created file: /your-project/src/utils/constant.js
๐ Created file: /your-project/src/lib/axios.js
๐งต <Provider> wrapped in /your-project/App.js
โ
RTK Query setup complete for react-native project.
๐จโ๐ป Thanks for using this tool and to the creators of the tool. Have a great day!
๐ Visit my website: https://www.zaynmiraj.com
```
## ๐ก Tips
- You can rerun this command if you want to switch between RTK and Reducer setup (but be cautious of overwriting existing files).
- Works best in a clean/new project scaffolded with Create React App, Next.js, React Native, or Expo.
## ๐ Credits
Built by **ZaYn Miraj**
CLI Creator: [@zaynmiraj](https://www.zaynmiraj.com)
## ๐ชช License
MIT License
Copyright (c) 2025 ZaYn Miraj