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

universal-react

v1.0.0

Published

A universal react starter, with routing, meta, title, and data features

Downloads

24

Readme

Universal React

This boilerplate aims at solving the MVP (Minimal Viable Product) of a universal app while trying to keep the base unopinionated elsewhere and simple to read and extend.

Universal React on NPM Dependency Status

## Features

  • Universal routing react-router
  • Redux
  • Hot reloading
  • Title, meta, css, and scripts overridable by each component react-helmet
  • Universal data fetching/rehydration on the client isomorphic-fetch
  • No other templating engines - React from root down
  • 404 and redirect handling
  • Shared app config
  • Webpack and Babel

Since there are so many opinions on how to use css (vanilla, sass, less, react css modules etc) I've left it up to you.

## Install & run

npm i && npm start

Go to http://localhost:3000/.

Build

npm run build

This will create a dist/ folder with a app.min.js which will be used on any environment which isn't undefined (i.e. not local).

npm run start-prod

This will build and then run your app with environment set to production, so that app.min.js and config/production.js are used.

Adding routes

Add your routes in Routes.js.

<Route path='users' component={Users} />

Title and Meta

The parent App.js defines the base title and meta in a Helmet component. Any sub-component can override/add properties (even adding scripts and css). See the react-helmet docs for more info.

Config

You can store app settings under app/config/. A file matching process.env.NODE_ENV will be loaded, for example app/config/production.js. If process.env.NODE_ENV is undefined it will fallback to app/config/default.js. You can access the correct config with:

import config from './config';

Data fetching and client hydration

Read the Redux guide if you are new to redux. Write Redux actions and stores as normal, and if the action creator is asynchronous then it should return a Promise (or a Promise.all) in the inner function.

You should write dispatches for actions that must be called for the container to be ready:

static readyOnActions(dispatch, params) {
	return Promise.all([
		dispatch(UserActions.fetchUserIfNeeded(params.id))
	]);
}

You should also invoke the actions in componentDidMount. This ensures that if the component is reached on the client, then the same actions will be invoked. It's up to the action to figure out if fetches for data need to be made or not:

componentDidMount() {
	User.readyOnActions(this.props.dispatch, this.props.params);
}