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

@anupamshandilya28/selective-context

v0.1.0

Published

A fast and lightweight React context state management library

Readme

Selective Context

A fast and lightweight state management library for React using Context API.

Installation

npm install @anupamshandilya28/selective-context
# or
yarn add @anupamshandilya28/selective-context

Features

  • Lightweight and minimalistic API
  • TypeScript support
  • Fast updates with selective re-rendering
  • Built-in Snackbar notifications
  • Zero dependencies

Usage

1. Create a store

// store.ts
import { createFastContext } from '@anupamshandilya28/selective-context';

type StoreType = {
  count: number;
  user: {
    name: string;
    isLoggedIn: boolean;
  };
};

const initialState: StoreType = {
  count: 0,
  user: {
    name: '',
    isLoggedIn: false,
  },
};

export const { Provider, useStore } = createFastContext(initialState);

2. Wrap your application with the Provider

// App.tsx
import React from 'react';
import { Provider } from './store';
import Counter from './Counter';
import UserInfo from './UserInfo';

function App() {
  return (
    <Provider>
      <h1>Fast Context Demo</h1>
      <Counter />
      <UserInfo />
    </Provider>
  );
}

export default App;

3. Use the store in your components

// Counter.tsx
import React from 'react';
import { useStore } from './store';
import { useSnackbar } from '@anupamshandilya28/selective-context';

function Counter() {
  const [count, setStore] = useStore(state => state.count);
  const { showSnackbar } = useSnackbar();

  const increment = () => {
    setStore(state => ({ count: state.count + 1 }));
    showSnackbar('Counter incremented!', 'success');
  };

  const decrement = () => {
    setStore(state => ({ count: state.count - 1 }));
    showSnackbar('Counter decremented!', 'info');
  };

  return (
    <div>
      <h2>Count: {count}</h2>
      <button onClick={increment}>Increment</button>
      <button onClick={decrement}>Decrement</button>
    </div>
  );
}

export default Counter;

Using the Snackbar

The package includes a built-in Snackbar system for notifications:

import { useSnackbar } from '@anupamshandilya28/selective-context';

function MyComponent() {
  const { showSnackbar } = useSnackbar();
  
  const handleClick = () => {
    // Show different types of notifications
    showSnackbar('Operation successful!', 'success');
    // Other options: 'error', 'info', 'warning'
  };
  
  return <button onClick={handleClick}>Show Notification</button>;
}

API Reference

createFastContext(initialState)

Creates a new context with the provided initial state.

Returns:

  • Provider: React component to wrap your application
  • useStore: Hook to access and update the store

useStore(selector)

Hook to select and subscribe to parts of the store.

Parameters:

  • selector: Function that selects a part of the store

Returns:

  • [selectedState, setStore]: Array containing the selected state and a setter function

useSnackbar()

Hook to access the snackbar functionality.

Returns:

  • showSnackbar(message, severity): Function to show a notification
  • hideSnackbar(): Function to hide the current notification

License

MIT