npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

redux-cli-setup

v1.1.1

Published

Generate Redux folder structure with Redux Toolkit, React-Redux, and Redux Persist.

Downloads

269

Readme

Redux Setup CLI 🚀

A powerful CLI tool to instantly scaffold a production-ready Redux setup with Redux Toolkit, React-Redux, and Redux Persist integration.

Features ✨

  • 🛠️ Complete Redux folder structure generation
  • 🔐 Built-in authentication slice and API setup
  • 📦 Redux Persist integration
  • 🎯 TypeScript support
  • 🔄 RTK Query setup with base API configuration
  • 🎨 Organized feature-based architecture

Prerequisites 📋

  • Node.js
  • npm or yarn
  • TypeScript project (preferably Next.js and ReactJs)

Installation 📥

npm install -g redux-cli-setup

Or use directly with npx:

npx redux-cli-setup

Generated Structure 📁

src/
└── redux/
    ├── base/
    │   ├── baseApi.ts
    │   └── baseReducer.ts
    ├── features/
    │   └── auth/
    │       ├── authSlice.ts
    │       └── authApi.ts
    ├── lib/
    │   └── ReduxProvider.tsx
    ├── store.ts
    └── hooks.ts

File Breakdown 📝

1. Base Configuration

baseApi.ts

  • Centralized API configuration
  • Token refresh mechanism
  • Authentication header setup
  • Base URL configuration

baseReducer.ts

  • Combines reducers
  • Configures Redux Persist
  • Handles authentication state persistence

2. Authentication Feature

authSlice.ts

  • Manages authentication state
  • Provides setUser and logout actions
  • Defines user type with role-based access

authApi.ts

  • Authentication-related RTK Query endpoints
  • Supports:
    • User login
    • Email verification
    • Password management
    • Token handling

3. Store Configuration

store.ts

  • Configures Redux store
  • Sets up middleware
  • Integrates Redux Persist
  • Defines TypeScript types for store

hooks.ts

  • Provides typed Redux hooks
  • useAppDispatch and useAppSelector

4. Redux Provider

ReduxProvider.tsx

  • Wraps application with Redux Provider
  • Implements Redux Persist Gate

Usage Example 💻

  1. Generate Redux structure:
npx redux-cli-setup
  1. Wrap your app with ReduxProvider:
import ReduxProvider from "@/redux/lib/ReduxProvider";

function App() {
  return (
    <ReduxProvider>
      <YourApp />
    </ReduxProvider>
  );
}
  1. Use in components:
import { useAppDispatch, useAppSelector } from "@/redux/hooks";
import { useLoginUserMutation } from "@/redux/features/auth/authApi";

function LoginComponent() {
  const dispatch = useAppDispatch();
  const [loginUser] = useLoginUserMutation();
  // Authentication logic
}

Authentication Endpoints 🔐

  • loginUser: User authentication
  • verifyEmail: Email verification
  • forgetPassword: Initiate password recovery
  • resetPassword: Complete password reset
  • changePassword: Update password

Best Practices 🌟

  1. State Management

    • Use RTK Query for API calls
    • Implement comprehensive error handling
    • Leverage TypeScript for type safety
  2. Authentication

    • Secure token storage
    • Implement clean logout
    • Handle token expiration gracefully
  3. Performance Optimization

    • Minimize state updates
    • Implement efficient caching
    • Optimize component re-renders

Contributing 🤝

  1. Fork the repository
  2. Create feature branch
  3. Commit changes
  4. Push to branch
  5. Create Pull Request

License 📄

MIT © [Apu Sutra Dhar]

Support 💬


Made with ❤️ by Apu Sutra Dhar