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

react-simple-universal

v0.4.2

Published

Creating universal apps with Redux and React is too hard. I want to make it easier. In this document I'll propose an API to create modern universal apps.

Readme

React Simple Universal

Creating universal apps with Redux and React is too hard. I want to make it easier. Especially for people that are just starting out with creating Universal React Application.

This library is not production ready yet, only for development. Will be production ready soon!

The Problem

Universal rendering and routing in React combined with Redux is great. For big projects it can really save you ton of time. I've created a universal React app myself and if you ever tried it yourself, you know it's a PITA. When I contributed to universal-react-boilerplate which is a boilerplate for creating universal React apps, there was so much code needed to bootstrap the universal React app, it felt like this should be easier.

Below an example from universal-react-boilerplate to give you an idea of how complicated configuring this stuff yourself might look like.

import React from 'react';
import { match } from 'react-router';

import renderLayout from 'server/render-layout';
import render from 'server/render';
import settings from 'server/settings';

import configureStore from 'shared/configure-store';
import createRoutes from 'shared/routes';

const store = configureStore();
const routes = createRoutes(React);
const initialState = store.getState();

export default (req, res) => {
  match({ routes, location: req.url }, (error, redirectLocation, renderProps) => {
    if (error) {
      res.status(500).send(error.message);
    } else if (redirectLocation) {
      res.redirect(302, redirectLocation.pathname + redirectLocation.search);
    } else if (renderProps) {
      const rootMarkup = render(React)(renderProps, store);
      res.status(200).send(renderLayout({ settings, rootMarkup, initialState }));
    } else {
      res.status(404).send('Not found');
    }
  });
};

This is only the routing part. There are some other files that need to be configured correctly to have a working app.

So what's included?

Simple example

npm install --save react-simple-universal react react-dom react-router redux webpack
npm install --save-dev babel-core babel-loader webpack-hot-middleware babel-preset-es2015 babel-preset-react
npm install -g babel-cli // So we can run babel-node globally for now
echo '{ "presets": ["es2015", "react"] }' > .babelrc // Will make sure babel-node uses the presets to transpile

routes/index.js:

// More at https://github.com/reactjs/react-router/blob/master/docs/guides/RouteConfiguration.md

import React from 'react';
import { Router, Route } from 'react-router';
import App from './path/to/my/component';

export default (browserHistory) => {
  return (
    <Router history={ browserHistory }>
      <Route path="/" component={ App } />
    </Router>
  );
};

reducers/index.js:

// More at http://redux.js.org/docs/basics/Reducers.html

const exampleInitialState = [
  { id: 1, text: 'Book 1', count: 2 },
  { id: 2, text: 'Book 2', count: 3 },
  { id: 3, text: 'Book 3', count: 4 },
];

const books = (state = {
  items: exampleInitialState,
}, action) => {
    return state;
  }
};

const reducers = {
  books
};

export default reducers;

client.js:

import { browserHistory } from 'react-router';
import universal from 'react-simple-universal/client';
import reducers from './path/to/my/reducers';

import createRoutes from 'routes';
const routes = createRoutes(browserHistory);

const store = universal({ routes, reducers });

// You can dispatch actions directly from the server
store.dispatch({ type: 'YOUR_ACTION' });

server.js:

import { expressDevServer } from 'react-simple-universal';
import universal from 'react-simple-universal/server';
import config from './path/to/my/webpack.config.dev';
import createRoutes from './path/to/my/routes';
import reducers from './path/to/my/reducers';

const routes = createRoutes();

// This will contain an express server with webpack hot reloading
// You can just add your own configuration here like: app.use('/', myMiddleware)
const app = universal({ routes, reducers, app: expressDevServer(config) });

Run babel-node --presets es2015 --presets react server.js to start your application.
That's it! You got a working server-side rendered React application now.

Feedback or want to contribute?

Do you have feedback or do you want to contribute? Please send me a message on twitter @guidsen or make an issue.