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

@livelix/react-utils

v1.4.6

Published

This library has a few react utilities.

Downloads

19

Readme

React Utilities

This library has a few react utilities.

useAsyncCall hook

This is a helper hook for making async calls.

Arguments
name | type | required | default | note | |------------------------------|---------------------------------------------------------------------------------------------|----------|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | function | async Function | yes | | the function will receive all the parameters from the execute call | | options | { onSuccess?: Function, onError?: Function, preventExecutionWhileLoading?: boolean; } | no | {} | a configuration object | | onSuccess | Function | no | undefined | a function to call after a successful call execution. Will receive the response as an argument. | | onError | Function | no | undefined | a function to call when the execution fail. Will receive the error as an argument. | | preventExecutionWhileLoading | boolean | no | true | whether to prevent the call execution if there's a previous call loading. This is useful in forms because it will prevent the form from being submitted again while the form is being submitted. |

It returns an object with the following properties:

  1. execute - the function you'll have to call. It receives any arguments you send to it and passes it to the function you provided to the hook.
  2. isLoading - whether the function is being executed right now. You can use it to display a loading indicator.
  3. isSuccess - whether the function was called successfully. You can use it to display a message if the call was successful.
  4. isFailed - whether the function call failed. You can use it to display an error message.
  5. error - the Error thrown when calling the function
  6. response - the response of the function call

Typescript Example

You can check the demo here.

import * as React from "react";
import { render } from "react-dom";
import { useAsyncCall } from "@livelix/react-utils";

interface User {
  email: string;
}

function App() {
  const call = useAsyncCall<User>(() => {
    return new Promise((resolve) => {
      setTimeout(() => {
        resolve({ email: "[email protected]" });
      }, 2000);
    });
  });

  return (
    <div>
      {call.isSuccess ? (
        <p>User email: {String(call.response?.email)}</p>
      ) : (
        <button onClick={call.execute}>
          {call.isLoading ? "Loading..." : "Get User"}
        </button>
      )}
    </div>
  );
}

render(<App />, document.getElementById("root"));
}

useStorageState hook

This hook is exactly as the useState hook from react, with the exception that this hook will store and get the value from the local storage.

Usage
import { useStorageState } from "@livelix/react-utils";

// First argument is the initial state
// Second argument is the storage key
// Third argument is the local storage - can be window.localStorage for web or AsyncStorage for react native
const [state, setState] = useStorageState('initialValue', 'storageKey', window.localStorage);