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

gpc-react

v0.0.8

Published

Collection of React tools for the GP Joule Connect team

Readme

GPC-React

Collection of React tools for use at the GP Joule Connect team

Licence: Unlicensed, only for private use at GP Joule Connect GmbH

Table of Contents

  1. Installation
  2. Hooks

Installation

To use these hooks, install the gpc-react library:

npm install gpc-react

Hooks:

useWindowDimensions

useWindowDimensions provides the current window dimensions (width and height). It listens to the resize event and updates the values in real-time as the window size changes. If the window object is not available (e.g., server-side rendering), both width and height will be null.

Usage example:

import { useWindowDimensions } from 'gpc-react';

import BigComponent from './BigComponent'
import SmallComponent from './SmallComponent'
import TallComponent from './TallComponent'
import ShortComponent from './ShortComponent'

const VariableSizeComponent = () => {
  const { width, height } = useWindowDimensions();

  return (
    <div>
      {width > 1000 ?  <BigComponent /> : <SmallComponent>}
      {height > 500 ?  <TallComponent /> : <ShortComponent>}
    </div>
  );
};

export default VariableSizeComponent;

useScreens

useScreens helps detect common screen resolutions such as mobile, tablet, Full HD, 4K, and 8K. It provides boolean values for each screen size category, allowing you to conditionally render components based on the current screen width. The hook initializes screenSizes based on the current screen width and updates dynamically on window resize.

Returns
  • isMobile: booleantrue if the width is 750 pixels or less.
  • isTablet: booleantrue if the width is between 751 and 1024 pixels.
  • isFullHD: booleantrue if the width is between 1025 and 1920 pixels.
  • is4K: booleantrue if the width is between 1921 and 3840 pixels.
  • is8K: booleantrue if the width is greater than 3840 pixels.

Usage Example:

import { useScreens } from 'gpc-react';

import MobileView from './MobileView';
import TabletView from './TabletView';
import FullHDView from './FullHDView';

const ResponsiveComponent = () => {
  const { isMobile, isTablet, isFullHD } = useScreens();

  return (
    <div>
      {isMobile && <MobileView />}
      {isTablet && <TabletView />}
      {isFullHD && <FullHDView />}
    </div>
  );
};

export default ResponsiveComponent;

useBrowserStorage

useBrowserStorage provides a convenient interface for interacting with both sessionStorage and localStorage. It allows you to set, retrieve, and remove items from browser storage, stringifying and parsing values to set and retrieve respectively. The parameter type (optional) selects which storage: "session" or "local", it defaults to "session" if nothing is given.

-Syntax:

  // Parameter types
  // key: string;
  // value: all objects;
  // type?: "session" | "local", defaults to "session";
  setItem(key, value, type?)
  getItem(key, type?)
  removeItem(key, type?)

Usage example:

import { useBrowserStorage } from 'gpc-react';

const StorageHandlingComponent = () => {
  const { value, setItem, getItem, removeItem } = useBrowserStorage();

  // Set an item in localStorage:
  setItem("myKey", { name: "Alice", age: 25 }, "local");

  // Retrieve the item:
  const user = getItem("myKey", "local");
  console.log(user); // Output: { name: "Alice", age: 25 }

  // Remove the item:
  removeItem("myKey", "local");

  // In sessionStorage:
  setItem("myKey", { name: "Alice", age: 25 });
  // Same as: setItem("myKey", { name: "Alice", age: 25 }, "session");
  getItem("myKey");
  removeItem("myKey");
}

export default StorageHandlingComponent;