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

@greenonsoftware/react-kit

v0.1.0

Published

A comprehensive React solutions toolkit for building modern web applications

Readme

@greenonsoftware/react-kit

A collection of first-class React hooks to enhance your application's functionality with minimal setup.

Installation & Setup

You can install the package using npm or yarn:

npm install @greenonsoftware/react-kit

or

yarn add @greenonsoftware/react-kit

or via the ShadCN approach

  1. Go to the repository.
  2. Copy the file containing the implemented utility (it is designed to be copied from a single file). In addition, you can copy test file. As is 100% isolated from other files.

1. useSimpleFeature - show/hide UI and manage simple features

This hook provides a simple way to manage a boolean state with easy-to-use functions to toggle, set, or reset the state.

import { useSimpleFeature } from '@greenonsoftware/react-kit';

const MyComponent = (props: { flag: boolean }) => {
  const modal = useSimpleFeature();
  // or with initial state
  const modal = useSimpleFeature(true);
  // or with the result as complex initial calculations
  const modal = useSimpleFeature(calculateFlag);
  // or based on the properties from component
  const modal = useSimpleFeature(props.flag);
  const modal = useSimpleFeature(() => props.flag);

  return (
    <div>
      <p>Status: {modal.isOn ? 'On' : 'Off'}</p>
      <button onClick={modal.toggle}>Toggle</button>
      <button onClick={modal.on}>Turn On</button>
      <button onClick={modal.off}>Turn Off</button>
      <button onClick={modal.reset}>Reset</button>
    </div>
  );
};

Parameters

  • defaultState (optional) - A setter to initialize the state. Default is false.

2. useFeature - Manage feature state with additional data

This hooks is enhanced version of useSimpleFeature. In addition, it allows you to store data that is determined by generic parameter.

import { useFeature } from '@greenonsoftware/react-kit';

type UserConfig = { id: number };

const MyComponent = () => {
  const feature = useFeature<UserConfig>();
  const feature = useFeature();
  // or with initial state
  const feature = useFeature({ is: 'on', data: 42 });
  // or dynamically
  const feature = useFeature({ is: 'off' });
  const feature = useFeature(() => ({ is: 'off' }));

  if (feature.is === `on`) {
    // Data is only available when feature is "on".
    console.log(feature.data);
  }

  return (
    <div>
      <p>Accessing data not allowed without proper check 💢: {feature.data}</p>
      <p>Feature state: {feature.is}</p>
      <button onClick={() => feature.on(100)}>Turn On with Data</button>
      <button onClick={feature.off}>Turn Off</button>
      <button onClick={feature.reset}>Reset</button>
    </div>
  );
};

Parameters

  • defaultState (optional) - A setter to initialize the state. Default is { is: 'off' }.

3. context - Create Contexts with Zero Boilerplate

This mechanism follows best practices described in this article: Common Mistakes in Using React Context API.

You can create a context more easily based on specific conditions using the following API—all strongly typed.

// @@@ user.context.tsx @@@
import { useState } from 'react';
import { context } from '@greenonsoftware/react-kit';

// Passing a hook to define logic and return a value
export const [UserProvider, useUserContext] = context(() => {
  const [counter, setCounter] = useState(0);

  return { counter, setCounter };
});

// @@@ app.tsx @@@
import React from 'react';
import { UserProvider, useUserContext } from './user.context';

const UserView = () => {
  // Strongly typed
  const { counter, setCounter } = useUserContext();

  return (
    <div>
      <h1>Counter: {counter}</h1>
      <button onClick={() => setCounter(10)}>Increment</button>
    </div>
  );
};

const ConnectedUserView = () => (
  <UserProvider>
    <UserView />
  </UserProvider>
);

If you want to pass initial properties to Provider do it as follows:

// @@@ user.context.tsx @@@
import { useState } from 'react';
import { context } from '@greenonsoftware/react-kit';

// Assigning the value passed from "UserProvider"
export const [UserProvider, useUserContext] = context((props: { initialCounter: number }) => {
  const [counter, setCounter] = useState(props.initialCounter);

  return { counter, setCounter };
});

// @@@ app.tsx @@@
import React from 'react';
import { UserProvider, useUserContext } from './user.context';

const UserView = () => {
  const { counter, setCounter } = useUserContext();

  return (
    <div>
      <h1>Counter: {counter}</h1>
      <button onClick={() => setCounter(10)}>Increment</button>
    </div>
  );
};

const ConnectedUserView = () => (
  // Passing an initial state
  // may be also on server side, ...etc
  <UserProvider initialCounter={12}>
    <UserView />
  </UserProvider>
);

Last, if you need to memoize things do it at hook level:

const useCounter = (props: { initialCounter: number }) => {
  const [counter, setCounter] = useState(props.initialCounter);

  return useMemo(() => ({ counter, setCounter }), [counter]);
};

export const [UserProvider, useUserContext] = context(useCounter);

Parameters

  • useHook (required) – A hook that defines the logic and returns the context value to be propagated. This hook can accept an optional parameter as a callback. If specified, you must pass props to provider.

    // When specifying arguments in the callback
    const [SomeProvider, useSomeContext] = context(({ initialState }: { initialState: string }) => {
      console.log(initialState); // Prints 1 and "something"
      // any additional logic...
    });
    
    // TypeScript enforces passing these arguments as props to the provider
    <SomeProvider initialState="something">
      <SomeOtherComponent />
    </SomeProvider>;

License

MIT License