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

add-redux

v0.6.0

Published

Quickly add Redux boilerplate files and directories to your vanilla JavaScript, React, or React Native App.

Downloads

273

Readme

add-redux license npm version Build Status PRs Welcome

Quickly add Redux boilerplate files and directories to your vanilla JavaScript, React, or React Native app.

Want to contribute to this project, request a feature, or report a problem? Please open an issue here.

Getting Started

You can install add-redux with the command:

npm i -g add-redux

Alternatively, you can use yarn like so:

yarn global add add-redux

You can then use add-redux on an existing project like so:

add-redux <example_project_directory>

Please note that this command assumes npm init or yarn init has already been run in the project directory, and that a package.json file exists within it. add-redux will throw an error if package.json is not present.

If a yarn.lock file is present in the project directory, add-redux will use yarn to install packages instead of npm.

Why is this Needed?

When creating a Redux-based project, there are currently many popular cli tools: redux-wooo, create-react-app-with-redux, create-react-redux-native-app, generator-create-redux-app, create-redux-app, etc.

These tools are useful, but there are three main problems with them:

  1. Many of them are bloated and include features that are often unnecessary for basic applications.

  2. Multiple commands are needed for different types of projects (i.e one is needed for regular React apps, while one is needed for React Native apps, and another is needed for vanilla JavaScript apps).

  3. The commands themselves are often a bit long to type out.

add-redux aims to address these issues by providing a single, consice cli command for any type of Redux project, which sets up only the most barebones boilerplate code in order to avoid bloat.

What's Included?

Running add-redux on a project directory will add the following files and directories into the project directory:

├── reducers/ (only without the '--ducks' flag)
│   ├── index.js 
│   ├── sampleReducers.js
├── actions/ (only without the '--ducks' flag)
│   ├── index.js
├── store.js
├── redux_examples/ (optional with the '--examples' flag)
│   ├── <project examples> ...
├── ducks/ (optional with the '--ducks' flag)
│   ├── sampleDuck.js

From there, you can simply use import store from 'store'; in your project to begin using Redux.

Any reducers should be created in the reducers/ directory and imported into index.js to be merged with the other reducers.

Any actions should be created in the actions/ directory.

add-redux will also save and configure the following middleware in your project by default:

If your project does not require any of these, see the option flags below.

Options

When using add-redux, you can specify the following flags to control which packages are installed by the command and configured in the boilerplate code:

  • -r, --react - Adds react-redux to the project dependencies. This feature currently leaves the rest of the React setup to the user, but it does prompt the user on how to do so.
  • -l, --no-logger - Skips adding redux-logger to the project dependencies and boilerplate code.
  • -t, --no-thunk - Skips adding redux-thunk to the project dependencies and boilerplate code.
  • -p, --no-promise - Skips adding redux-promise-middleware to the project dependencies and boilerplate code.
  • -e, --examples - Adds a redux_examples/ directory to the project root. This directory includes examples for integrating redux with different types of projects.
  • -d, --ducks - Adds a ducks/ directory to the project root. This directory contains an example modular redux file (also known as a duck). Using this option will prevent the actions/ and reducers/ directories from being generated, since they are not needed by the duck specification.
  • -s, --src <directory> - Specifies the source directory for the project. This is where the boilerplate code will reside. Defaults to the root project directory. The directory argument should be a relative path name from the root project directory.

Examples

The following example directories are generated within the redux_examples/ directory when using the --examples flag.

  • react_example/ - An example project for integrating Redux with React. Includes a sample App.js file and a sample component which is used in App.js.