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 🙏

© 2026 – Pkg Stats / Ryan Hefner

redux-shared-store

v0.1.0

Published

A redux store easily shared between components.

Downloads

52

Readme

redux-shared-store

A redux provider that easily allows for injecting reducers dynamically and sharing a redux store across components. See an example application using the redux-shared-store, and a component (that uses the shared store itself) here.

Usage

import Provider, { injectReducers, injectMiddleware } from 'redux-shared-store'

Provider props

  • reducers: Array<Reducer> (optional)

    An array of reducers that will be applied to the root of the redux store. If no reducers are passed, it is assumed that the application does not use redux.

  • middleware: Array<Middleware> (optional)

    An array of middleware to provide the redux store.

injectReducers props

  • keyPath: String (required)

A string representing the path to the reducers. Ex: 'components.something'

  • reducers: Array<Reducer> (required)

An array of reducers that will be appended to the redux store.

  • callback: Function (optional)

A function called after the reducers are injected.

injectMiddleware props

  • middleware: Array<Middleware> (required)

    An array of middleware to provide the redux store.

  • callback: Function (optional)

A function called after the middleware is injected.

Important

Provider must be found at the root of the application. Otherwise, any components that try to use injectReducers will throw an error that there is no store available.

Also important

Components using redux-shared-store need to be careful not to duplicate reducer names. Otherwise, there will be a conflict with the keys. It is useful to tuck components' reducers into a subKey such as 'components'.

Important, as well

Components using redux-shared-store need to be careful not to duplicate action types. Otherwise, reducers could end up with error states. It is useful to name components' action types prefixed with the component name such as 'example/THE_ACTION'.

State preview

{
  ...anyAppRelatedReducers,
  components: {
    example: {
      ...exampleRelatedReducers
    }
  }
}

Example usage for applications

There are not many changes in your application necessary to migrate to redux-shared-store. Remove any store 'creation' or 'configuration' from your app. This will turn to dead code. To hook up your applications' reducers (if you have any), pass them into Provider with the 'reducers' prop. Pass any middleware into Provider with the 'middleware' prop. Then, your application specific state will be available as usual in mapStateToProps;

reducers.js

import config from "./modules/config/reducer";

export default { config };

App.jsx

import React, { Component } from "react";
import Provider from "redux-shared-store";
import loggerMiddleware from "redux-logger";

import reducers from "./reducers";

class App extends Component {
  render() {
    return (
      <Provider
        reducers={reducers}
        middleware={[loggerMiddleware]}
      >
        Hello, World.
      </Provider>
    );
  }
}

const mapStateToProps = ({ config }) {
  return config;
}

export default connect(mapStateToProps)(App);

Example usage for components

If a component needs a reference to the store, it only needs to connect as normal to receive anything that is currently in the store. If it needs it's own set of data and reducers, the components' reducers can be injected with the injectReducers function.

reducers.js

import config from "./modules/config/reducer";

export default { config };

index.js (root of the component)

import React from "react";
import { injectReducers } from "redux-shared-store";

import reducers from "./reducers";
import Something from "./Something";

export default props =>
  injectReducers("components.something", reducers, () => <Something {...props} />);

To access data from the store for your component, they will be found inside components. For this example it would be something like state.components.something.

const mapStateToProps = ({ components: { something } }) {
  const { config } = something;
  return {
    someData: config.data
  };
}

export default connect(mapStateToProps)(Something);