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-async-elements

v0.4.0

Published

Suspense-friendly async React elements for common situations.

Readme

React Async Elements

Suspense-friendly async React elements for common situations.

npm i react-async-elements

Table of Contents

API

<Img>

props

  • src: string
  • anything else you can pass to an <img> tag
import React from 'react';
import { Img } from 'react-async-elements';

function App() {
  return (
    <div>
      <h1>Hello</h1>
      <React.Placeholder delayMs={300} fallback={'loading...'}>
        <Img src="https://source.unsplash.com/random/4000x2000" />
      </React.Placeholder>
    </div>
  );
}

export default App;

<Script>

props

  • src: string
  • children?: () => React.ReactNode - This render prop will only execute after the script has loaded.
  • cache?: Optionally pass your own instance of simple-cache-provider
  • anything else you can pass to a <script> tag
import React from 'react';
import { Script } from 'react-async-elements';

function App() {
  return (
    <div>
      <h1>Load Stripe.js Async</h1>
      <React.Placeholder delayMs={300} fallback={'loading...'}>
        <Script src="https://js.stripe.com/v3/" async>
          {() => console.log(window.Stripe) || null}
        </Script>
      </React.Placeholder>
    </div>
  );
}

export default App;

<Video>

props

  • src: string
  • cache?: Optionally pass your own instance of simple-cache-provider
  • anything else you can pass to a <video> tag
import React from 'react';
import { Video } from 'react-async-elements';

function App() {
  return (
    <div>
      <h1>Ken Wheeler on a Scooter</h1>
      <React.Placeholder delayMs={300} fallback={'loading...'}>
        <Video
          src="https://video.twimg.com/ext_tw_video/1029780437437014016/pu/vid/360x640/QLNTqYaYtkx9AbeH.mp4?tag=5"
          preload="auto"
          autoPlay
        />
      </React.Placeholder>
    </div>
  );
}

export default App;

<Audio>

props

  • src: string
  • cache?: Optionally pass your own instance of simple-cache-provider
  • anything else you can pass to a <audio> tag
import React from 'react';
import { Audio } from 'react-async-elements';

function App() {
  return (
    <div>
      <h1>Meavy Boy - Compassion</h1>
      {/* source: http://freemusicarchive.org/music/Meavy_Boy/EP_71_to_20/Compassion */}
      <React.Placeholder delayMs={300} fallback={'loading...'}>
        <Audio src="https://file-dnzavydoqu.now.sh/" preload="auto" autoPlay />
      </React.Placeholder>
    </div>
  );
}

export default App;

<Preload>

Preload a resource with <link rel="preload">.

More Info:

props

  • href: string
  • as: string - resource type
import React from 'react';
import { Preload, Script } from 'react-async-elements';

function App() {
  return (
    <div>
      <h1>Preload</h1>
      <React.Placeholder delayMs={300} fallback={'loading...'}>
        <Preload href="https://js.stripe.com/v3/" rel="preload" as="script" />
        <Script src="https://js.stripe.com/v3/" async />
      </React.Placeholder>
    </div>
  );
}

export default App;

<Stylesheet>

Lazy load a stylesheet.

props

  • href: string
import React from 'react';
import { Stylesheet } from 'react-async-elements';

function App() {
  return (
    <div>
      <h1>Styles</h1>
      <React.Placeholder delayMs={300} fallback={'loading...'}>
        <Stylesheet href="style.css" />
      </React.Placeholder>
    </div>
  );
}

export default App;

Todo

  • [ ] <IFrame>
  • [ ] <Embed>

Playing with Suspense

If you want to play around with suspense features, you'll need to enable suspense somehow. That means either building React yourself. Or, using this handy dandy starter we made.

https://github.com/palmerhq/react-suspense-starter

Authors


MIT License