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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@webdevarif/redux

v1.0.8

Published

A customizable Redux ecosystem with dynamic slice creation, store builder, and preset slices for modern React applications

Downloads

40

Readme

@webdevarif/redux

A customizable Redux ecosystem with dynamic slice creation, store builder, and preset slices for modern React applications.

Features

  • 🚀 Dynamic Slice Creation - Create Redux slices with minimal boilerplate
  • 🎯 Preset Slices - Pre-built slices for common use cases (auth, notifications)
  • 🔧 Customizable Hooks - Powerful hooks for state management
  • 📦 TypeScript Support - Full type definitions included
  • Performance Optimized - Built on Redux Toolkit for optimal performance
  • 🎨 React Integration - Seamless integration with React components
  • 🔄 Persistence Ready - Built-in support for Redux Persist

Installation

npm install @webdevarif/redux
# or
yarn add @webdevarif/redux
# or
pnpm add @webdevarif/redux

Quick Start

Basic Usage

import { createSimpleSlice, useSlice, useSliceDispatch } from '@webdevarif/redux/core';

// Create a slice
const counterSlice = createSimpleSlice('counter', { count: 0 }, {
  increment: (state, action) => {
    state.count += action.payload || 1;
  },
  decrement: (state, action) => {
    state.count -= action.payload || 1;
  },
});

// Use in component
function Counter() {
  const { state } = useSlice('counter');
  const { dispatch } = useSliceDispatch('counter');

  return (
    <div>
      <h2>Count: {state.count}</h2>
      <button onClick={() => dispatch(counterSlice.actions.increment())}>
        Increment
      </button>
    </div>
  );
}

Preset Slices

import { createAuthSlice, createNotificationSlice } from '@webdevarif/redux/core';

// Create preset slices
const authSlice = createAuthSlice();
const notificationSlice = createNotificationSlice();

// Configure store
import { configureStore } from '@reduxjs/toolkit';

export const store = configureStore({
  reducer: {
    auth: authSlice.reducer,
    notifications: notificationSlice.reducer,
  },
});

Using Hooks

import { useAuth, useNotifications } from '@webdevarif/redux';

function MyComponent() {
  const { user, isAuthenticated, login, logout } = useAuth();
  const { notifications, unreadCount, markAsRead } = useNotifications();

  return (
    <div>
      {isAuthenticated ? (
        <div>
          <p>Welcome, {user?.name}!</p>
          <p>You have {unreadCount} unread notifications</p>
          <button onClick={logout}>Logout</button>
        </div>
      ) : (
        <button onClick={() => login({ email: '[email protected]' })}>
          Login
        </button>
      )}
    </div>
  );
}

API Reference

Slice Creation

createSimpleSlice(name, initialState, reducers)

Creates a simple Redux slice with common reducers.

const mySlice = createSimpleSlice('mySlice', { value: 0 }, {
  setValue: (state, action) => {
    state.value = action.payload;
  },
  increment: (state) => {
    state.value += 1;
  },
});

createAuthSlice()

Creates a pre-configured authentication slice.

const authSlice = createAuthSlice();
// Includes: user, isAuthenticated, session, loading, error
// Actions: setUser, setSession, logout, reset

createNotificationSlice()

Creates a pre-configured notifications slice.

const notificationSlice = createNotificationSlice();
// Includes: notifications, unreadCount, loading, error
// Actions: addNotification, removeNotification, markAsRead, markAllAsRead

Hooks

useSlice(sliceName)

Access slice state and dispatch.

const { state, dispatch } = useSlice('mySlice');

useSliceState(sliceName)

Access only slice state.

const { state } = useSliceState('mySlice');

useSliceDispatch(sliceName)

Access only slice dispatch.

const { dispatch } = useSliceDispatch('mySlice');

useMultipleSlices(sliceNames)

Access multiple slices at once.

const { states, dispatches } = useMultipleSlices(['auth', 'notifications']);

useForm(initialValues)

Form state management hook.

const { values, errors, setValue, submit, isValid } = useForm({
  email: '',
  password: '',
});

useList(sliceName)

List management hook.

const { items, addItem, updateItem, removeItem } = useList('todos');

useApi(sliceName)

API state management hook.

const { data, loading, error, execute } = useApi('users');

useAuth()

Authentication hook.

const { user, isAuthenticated, login, logout } = useAuth();

useNotifications()

Notifications hook.

const { notifications, unreadCount, markAsRead } = useNotifications();

Store Configuration

Basic Store

import { configureStore } from '@reduxjs/toolkit';
import { createAuthSlice, createNotificationSlice } from '@webdevarif/redux/core';

const authSlice = createAuthSlice();
const notificationSlice = createNotificationSlice();

export const store = configureStore({
  reducer: {
    auth: authSlice.reducer,
    notifications: notificationSlice.reducer,
  },
  devTools: process.env.NODE_ENV !== 'production',
});

export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;

With Redux Persist

import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';

const persistConfig = {
  key: 'root',
  storage,
  whitelist: ['auth', 'notifications'],
};

const persistedReducer = persistReducer(persistConfig, rootReducer);

export const store = configureStore({
  reducer: persistedReducer,
});

export const persistor = persistStore(store);

TypeScript Support

The package includes full TypeScript definitions:

import { AuthState, NotificationState } from '@webdevarif/redux';

interface MyState extends BaseSliceState {
  data: string[];
}

const mySlice = createSimpleSlice<MyState>('mySlice', {
  data: [],
  loading: false,
  error: null,
});

Examples

Todo App

import React from 'react';
import { createSimpleSlice, useSlice, useSliceDispatch } from '@webdevarif/redux/core';

interface Todo {
  id: string;
  text: string;
  completed: boolean;
}

const todoSlice = createSimpleSlice('todos', { items: [] as Todo[] }, {
  addTodo: (state, action) => {
    state.items.push({
      id: Date.now().toString(),
      text: action.payload,
      completed: false,
    });
  },
  toggleTodo: (state, action) => {
    const todo = state.items.find(item => item.id === action.payload);
    if (todo) {
      todo.completed = !todo.completed;
    }
  },
});

function TodoApp() {
  const { state } = useSlice('todos');
  const { dispatch } = useSliceDispatch('todos');

  return (
    <div>
      {state.items.map(todo => (
        <div key={todo.id}>
          <span>{todo.text}</span>
          <button onClick={() => dispatch(todoSlice.actions.toggleTodo(todo.id))}>
            Toggle
          </button>
        </div>
      ))}
    </div>
  );
}

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support, email [email protected] or create an issue on GitHub.