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

konciv-hooks

v1.1.3

Published

A collection of custom React hooks

Readme

useSearchData Hook

The useSearchData hook is a custom React hook designed to fetch and manage search data efficiently. It allows you to filter, sort, and retrieve items based on various customizable criteria such as item types, properties, location, and more.


Installation

Make sure you have all the necessary dependencies installed in your project before using this hook.

npm i konciv-hooks

Usage

Import the Hook

import { useSearchData, useApi, useSearchItem } from "konciv-hooks";

Example Implementation

Here’s how you can use the useSearchData hook in a functional React component:

import React from "react";
import { useSearchData, useApi, useSearchItem } from "konciv-hooks";

const SearchComponent = () => {
  const token = "your-auth-token"; // Replace with your actual token
  const ocpKey = "your-ocp-key"; // Replace with your actual ocpKey

  const { itemTypes, projects, globals, users, groups } = useApi(token, ocpKey); // Exclude or include whatever you need. Only does api for whats in the object.

  const { data: nameWhateverUWant, error: searchItemError, loading: searchItemLoading } = useSearchItem(token, ocpKey, itemId);

  const { searchData, allDataFetched, error, loading } = useSearchData({
    token: token, // Required
    ocpKey: ocpKey, // Required
    itemType: itemTypes?.employee, // To seach withing item type "Employee" - Required
    itemName: "Hello", // Search by item with a name "Hello" - Optional
    properties: [
      { name: "User", value: "E3GRG342-GJ123-4567890" },
      { name: "Monthly Salary", value: "40000" }, // By Default its EQ on numbers.
      { name: "Recieved", value: "200000", comparison: "GOE" }, // On number properties u can use comparions: "GOE", "LOE", "EQ", "NEQ" and so on.
      { name: "Process Step", value: "Ready for Project", operator: "OR" }, // You can add operator "OR/AND" on each property.
    ], // Filter by custom properties - Optional
    location: {
      // Optional
      locationName: "Tananger",
      subregionName: "Stavanger", // Optional
    },
    pageSize: 4200, // Number of items to fetch ""all" || number" - Optional. 2000 is default.
    propertyOperator: "AND", // Filter operator (AND/OR) - Optional. AND is default - Optional.
  });

  if (loading) return <div>Loading...</div>;
  if (error) return <div>Error: {error.message}</div>;

  return (
    <div>
      <h1>Search Results</h1>
      {allDataFetched && <p>All data fetched successfully.</p>}
      <ul>
        {searchData?.map((item) => (
          <li key={item.id}>{item.name}</li>
        ))}
      </ul>
    </div>
  );
};

export default SearchComponent;

Options

The useSearchData hook accepts an object with the following options:

| Option | Type | Description | | ------------------ | ----------------- | ----------------------------------------------------------------------------------- | | token | string | Required. Authentication token for API access. | | ocpKey | string | Required. Key for additional API security. | | itemType | Array<string> | Optional. List of item types to filter the search results. | | itemName | string | Optional. Name of the item to search for. | | properties | Array<object> | Optional. Array of property filters. Each object contains a name and value. | | location | object | Optional. Contains locationName and subregionName for location-based filtering. | | pageSize | number or 'all' | Optional. Number of items to fetch . Default is 2000. | | propertyOperator | string | Optional. Operator for property filters (AND or OR). Default is AND. |


Return Values

The hook returns an object with the following:

| Property | Type | Description | | ---------------- | --------------- | --------------------------------------------------------- | | searchData | Array<object> | Array of fetched search results. | | allDataFetched | boolean | Indicates whether all data has been successfully fetched. | | error | Error | Error object if the request fails. | | loading | boolean | Indicates whether the data is currently being fetched. |

Notes

  • Ensure proper error handling is implemented for smoother user experience.
  • Adjust the pageSize to balance between performance and result accuracy.
  • Customize the filters based on your specific use case.