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-progressive-enhancement

v0.0.10

Published

React Context that progressively enhances components

Downloads

23

Readme

react-progressive-enhancement

A handy collection of HOCs for universally rendered apps 🤩

Build Status

TL;DR In universally rendered React apps, it is common to branch data-fetching and component-rendering depending on the environment (server or client), and defer rendering (a.k.a. "progressively enhance") some components. However, we must ensure the first client render matches the server render.

This module achieves all the above by tracking whether or not the render mode is "enhanced" with an isEnhanced boolean (true only after first client render, otherwise false), which is accessed through a withIsEnhanced HOC. Additionally a progressivelyEnhanced HOC is provided which only renders the composed component for enhanced renders.

For more info, check out this blog post.

Features

  • No dependencies (other than React ^16.3)
  • Written in TypeScript (type-annotated)
  • Easily extensible through the exported React Context's Consumer & Provider

Install

yarn add react-progressive-enhancement
# OR
npm install react-progressive-enhancement

Usage

  • Root.jsx:
import { enableProgressiveEnhancementsOnMount } from 'react-progressive-enhancement';

const Root = () => (
  <div>
    <PhotoRoute />
  </div>
);

export default enableProgressiveEnhancementsOnMount(Root);
  • PhotoRoute.jsx:
import { withIsEnhanced, progressivelyEnhance } from 'react-progressive-enhancement';

const ProgressivelyEnhancedRelatedContent = progressivelyEnhance(RelatedContent);

class PhotoRoute extends React.Component {
  componentDidMount() {
    const hasDataFromServer = !this.props.isEnhanced;

    if (!hasDataFromServer) {
      this.getPhotoRouteData();
    } else {
      // do nothing, because the server already fetched the data and passed it to the client.
    }
  }

  render() {
    return (
      <div>
        <Photo />
        {/* This component will only render after the first client render */}
        <ProgressivelyEnhancedRelatedContent />
      </div>
    );
  }
}

export default withIsEnhanced(PhotoRoute);

API Reference

enableProgressiveEnhancementsOnMount

(ComposedComponent: React.Component) => React.Component

An HOC that wraps ComposedComponent with the Context Provider. ComposedComponent should be the root-most Component in your React app.

withIsEnhanced

(ComposedComponent: React.Component) => React.Component

An HOC that provides the isEnhanced prop to ComposedComponent.

progressivelyEnhance

(ComposedComponent: React.Component) => React.Component

An HOC that defers rendering ComposedComponent until after the first client render.

Consumer, Provider

React.Context

The Context's Consumer and Provider are exported as well, so that you can easily extend this library as you see fit.