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

@api-hooks/npm

v2.7.0

Published

React hooks for the npm registry API, built on @tanstack/react-query

Downloads

375

Readme

@api-hooks/npm

React hooks for the npm registry API, built on npmjs-api-client and @tanstack/react-query.

npm npm downloads CI License: MIT TypeScript

Requirements

| Peer dependency | Version | | --------------- | ------- | | react | >=19.0.0 | | @tanstack/react-query | ^5.0.0 |

Installation

npm install @api-hooks/npm @tanstack/react-query

Setup

Wrap your application with a QueryClientProvider once at the root:

import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { NpmClientProvider } from '@api-hooks/npm';

const queryClient = new QueryClient();

export default function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <NpmClientProvider>
        <YourApp />
      </NpmClientProvider>
    </QueryClientProvider>
  );
}

For authenticated registry endpoints, such as org hooks, pass a token through NpmClientProvider:

const token = 'npm_...';

<NpmClientProvider options={{ token }}>
  <YourApp />
</NpmClientProvider>

Hooks

Query hooks return a UseQueryResult — you get the full TanStack Query API: data, isLoading, isFetching, isError, error, refetch, and more.

Audit hooks (useNpmAudit, useNpmAuditQuick) return a UseMutationResult since they perform POST requests.

Package hooks

| Hook | Description | Returns | | ---- | ----------- | ------- | | useNpmPackage(name) | Full packument (all versions metadata) | NpmPackument | | useNpmPackageVersion(name, version) | Manifest for a specific version | NpmPackageVersion | | useNpmPackageLatest(name) | Manifest for the latest dist-tag | NpmPackageVersion | | useNpmPackageVersions(name) | All published versions (oldest → newest) | NpmPackageVersion[] | | useNpmPackageDistTags(name) | Dist-tags map (latest, next, …) | NpmDistTags | | useNpmPackageMaintainers(name) | Current maintainers of the package | NpmPerson[] | | useNpmPackageDownloads(name, options?) | Total download count for a period | NpmDownloadPoint | | useNpmPackageVersionDownloads(name, version, options?) | Download count for a specific version | NpmVersionDownloadPoint | | useNpmPackageDownloadRange(name, options?) | Per-day download breakdown | NpmDownloadRange | | useNpmPackageScore(name) | Quality, popularity & maintenance score (npms.io) | NpmsScore | | useNpmPackageSize(name) | Publish & install size (Packagephobia) | PackagephobiaSize | | useNpmPackageCdnStats(name, options?) | CDN usage statistics (jsDelivr) | JsdelivrStats |

Version hooks

| Hook | Description | Returns | | ---- | ----------- | ------- | | useNpmPackageVersionDownloads(name, version, options?) | Download count for a specific version | NpmVersionDownloadPoint | | useNpmPackageVersionSize(name, version) | Publish & install size for a specific version | PackagephobiaSize | | useNpmPackageVersionFiles(name, version) | File tree of a published version (unpkg) | UnpkgFile | | useNpmPackageVersionCdnStats(name, version, options?) | CDN stats for a specific version (jsDelivr) | JsdelivrStats | | useNpmPackageVersionDependencies(name, version) | Resolved dependency graph (deps.dev) | DepsDevDependencies |

Bulk & audit hooks

| Hook | Description | Returns | | ---- | ----------- | ------- | | useNpmBulkDownloads(packages, options?) | Download counts for multiple packages at once | NpmBulkDownloads | | useNpmAudit() | Full security audit with advisories (POST) | NpmAuditResult | | useNpmAuditQuick() | Quick audit — vulnerability counts only (POST) | NpmAuditQuickResult |

Maintainer hooks

| Hook | Description | Returns | | ---- | ----------- | ------- | | useNpmMaintainer(username) | Public profile of an npm user | NpmUser | | useNpmMaintainerPackages(username, options?) | Packages published by a user | NpmSearchResult | | useNpmMaintainerPackagesInfinite(username, options?) | Infinite-scroll variant of useNpmMaintainerPackages | InfiniteData<NpmSearchResult> | | useNpmMaintainerAvatar(username) | Gravatar URL when a public email is available | string \| undefined |

User hooks

| Hook | Description | Returns | | ---- | ----------- | ------- | | useNpmUser(username) | Authenticated user profile | NpmAuthenticatedUser | | useNpmUserPackages(username, params?) | Packages published by a user | string[] | | useNpmWhoami(options?) | Username associated with the auth token | NpmWhoami |

Search hooks

| Hook | Description | Returns | | ---- | ----------- | ------- | | useNpmSearch(text, options?) | Full-text search across the registry | NpmSearchResult | | useNpmSearchInfinite(text, options?) | Infinite-scroll variant of useNpmSearch | InfiniteData<NpmSearchResult> |

Top / ranking hooks

| Hook | Description | Returns | | ---- | ----------- | ------- | | useNpmTopPackages(options?) | Top packages by npm's default ranking | NpmSearchResult | | useNpmTopByPopularity(options?) | Top packages weighted by popularity | NpmSearchResult | | useNpmTopByQuality(options?) | Top packages weighted by quality | NpmSearchResult | | useNpmTopByMaintenance(options?) | Top packages weighted by maintenance | NpmSearchResult | | useNpmTopByKeyword(keyword, options?) | Top packages for a keyword | NpmSearchResult | | useNpmTopByScope(scope, options?) | Top packages for a scope | NpmSearchResult |

Organization hooks

Organization hooks require a registry token with org access.

| Hook | Description | Returns | | ---- | ----------- | ------- | | useNpmOrgPackages(org, options?) | Packages an org can access | NpmOrgPackages | | useNpmOrgTeams(org, options?) | Teams in an org | string[] | | useNpmOrgMembers(org, options?) | Members and roles in an org | NpmOrgMembers | | useNpmOrgTeamMembers(org, team, options?) | Members in an org team | string[] |


API Reference

useNpmPackage(name)

Fetches the full packument for a package — all published versions, dist-tags, maintainers, README, and more.

import { useNpmPackage } from '@api-hooks/npm';

function PackageInfo() {
  const { data, isLoading, isError } = useNpmPackage('react');

  if (isLoading) return <p>Loading…</p>;
  if (isError) return <p>Package not found.</p>;

  return (
    <div>
      <h1>{data.name}</h1>
      <p>Latest: {data['dist-tags'].latest}</p>
    </div>
  );
}

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | enabled | boolean | true | Disable the query (also disabled when name is empty) | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmPackageVersion(name, version)

Fetches the manifest for a specific published version.

const { data } = useNpmPackageVersion('react', '18.2.0');

console.log(data?.dist.tarball);

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | enabled | boolean | true | Disabled when name or version is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmPackageLatest(name)

Shorthand for the latest dist-tag. Shares the cache with useNpmPackageVersion(name, 'latest').

const { data } = useNpmPackageLatest('typescript');

console.log(data?.version); // e.g. '5.7.0'

useNpmPackageVersions(name)

Returns all published versions as an array sorted from oldest to newest.

const { data: versions } = useNpmPackageVersions('react');

versions?.forEach(v => console.log(v.version));

useNpmPackageDistTags(name)

Returns the dist-tags map for a package.

const { data: tags } = useNpmPackageDistTags('react');
// { latest: '18.2.0', next: '19.0.0-beta.1' }

useNpmPackageMaintainers(name)

Returns the current maintainers of a package.

const { data: maintainers } = useNpmPackageMaintainers('react');

maintainers?.forEach(m => console.log(m.name, m.email));

useNpmPackageDownloads(name, options?)

Fetches the total download count for a package over a period.

const { data } = useNpmPackageDownloads('react', { period: 'last-week' });

console.log(data?.downloads); // e.g. 12345678

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | period | NpmDownloadPeriod | 'last-month' | 'last-day', 'last-week', 'last-month', 'last-year', or 'YYYY-MM-DD:YYYY-MM-DD' | | enabled | boolean | true | Disabled when name is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmPackageVersionDownloads(name, version, options?)

Fetches the download count for a specific package version over the previous 7 days.

const { data } = useNpmPackageVersionDownloads('react', '18.2.0');

console.log(data?.downloads); // e.g. 123456

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | period | NpmVersionDownloadPeriod | 'last-week' | npm currently supports only 'last-week' for version downloads | | enabled | boolean | true | Disabled when name or version is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmPackageDownloadRange(name, options?)

Fetches the per-day download breakdown — ideal for rendering charts.

const { data } = useNpmPackageDownloadRange('react', { period: 'last-month' });

data?.downloads.forEach(d => console.log(d.day, d.downloads));

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | period | NpmDownloadPeriod | 'last-month' | Same as useNpmPackageDownloads | | enabled | boolean | true | Disabled when name is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmPackageScore(name)

Fetches the quality, maintenance, and popularity score from npms.io.

const { data } = useNpmPackageScore('react');

console.log(data?.score.final);                          // 0.97
console.log(data?.evaluation.popularity.dependentsCount); // 15000

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | enabled | boolean | true | Disabled when name is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmPackageSize(name)

Fetches the publish size and full install size (including all transitive deps) from Packagephobia.

const { data } = useNpmPackageSize('react');

console.log(data?.install.pretty); // '300 kB'
console.log(data?.install.bytes);  // 307200

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | enabled | boolean | true | Disabled when name is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmPackageCdnStats(name, options?)

Fetches CDN usage statistics from jsDelivr — reflects browser/frontend usage complementing npm install counts.

const { data } = useNpmPackageCdnStats('react');

console.log(data?.rank);  // 1
console.log(data?.total); // 1234567890

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | groupBy | 'version' \| 'date' | 'version' | How to group results | | period | 'day' \| 'week' \| 'month' \| 'year' | 'month' | Time window | | enabled | boolean | true | Disabled when name is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmPackageVersionDownloads(name, version, options?)

Fetches download counts for a specific version. npm only exposes this for 'last-week'.

const { data } = useNpmPackageVersionDownloads('react', '18.2.0');

console.log(data?.downloads); // 500000

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | period | 'last-week' | 'last-week' | Only period supported by npm | | enabled | boolean | true | Disabled when name or version is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmPackageVersionSize(name, version)

Fetches publish & install size for a specific version from Packagephobia.

const { data } = useNpmPackageVersionSize('react', '18.2.0');

console.log(data?.install.pretty); // '300 kB'

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | enabled | boolean | true | Disabled when name or version is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmPackageVersionFiles(name, version)

Fetches the complete file tree of a published version from unpkg — useful for auditing package contents.

const { data } = useNpmPackageVersionFiles('react', '18.2.0');

data?.files?.forEach(f => console.log(f.path, f.size));

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | enabled | boolean | true | Disabled when name or version is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmPackageVersionCdnStats(name, version, options?)

Fetches CDN stats for a specific version from jsDelivr, grouped by file by default.

const { data } = useNpmPackageVersionCdnStats('react', '18.2.0');

console.log(data?.total); // 1000000

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | groupBy | 'file' \| 'date' | 'file' | How to group results | | period | 'day' \| 'week' \| 'month' \| 'year' | 'month' | Time window | | enabled | boolean | true | Disabled when name or version is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmPackageVersionDependencies(name, version)

Fetches the fully resolved dependency graph from deps.dev — exact resolved versions for all direct and transitive dependencies.

const { data } = useNpmPackageVersionDependencies('react', '18.2.0');

const direct = data?.nodes.filter(n => n.relation === 'DIRECT') ?? [];
direct.forEach(n => console.log(`${n.versionKey.name}@${n.versionKey.version}`));

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | enabled | boolean | true | Disabled when name or version is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmBulkDownloads(packages, options?)

Fetches download counts for multiple packages in a single request (max 128 packages).

const { data } = useNpmBulkDownloads(['react', 'vue', 'angular']);

console.log(data?.['react'].downloads); // 18591460
console.log(data?.['vue'].downloads);   // 4200000

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | period | NpmDownloadPeriod | 'last-month' | Same periods as useNpmPackageDownloads | | enabled | boolean | true | Disabled when packages is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmAudit()

Runs a full security audit against the npm registry. Accepts a lock-file-shaped payload and returns detailed advisory objects with recommended actions.

Returns a UseMutationResult — call mutate(payload) or mutateAsync(payload) to trigger the audit.

const { mutate, data, isPending } = useNpmAudit();

function handleAudit() {
  mutate({
    name: 'my-app',
    version: '1.0.0',
    requires: { lodash: '^4.17.11' },
    dependencies: {
      lodash: { version: '4.17.11', integrity: 'sha512-...' },
    },
  });
}

console.log(data?.metadata.vulnerabilities);
// { info: 0, low: 0, moderate: 1, high: 0, critical: 0 }

useNpmAuditQuick()

Same as useNpmAudit but returns only vulnerability counts by severity — no advisory details or actions. Faster and lighter.

const { mutate, data } = useNpmAuditQuick();

mutate({ name: 'my-app', version: '1.0.0', dependencies: { /* ... */ } });

const { high, critical } = data?.metadata.vulnerabilities ?? {};
if ((high ?? 0) + (critical ?? 0) > 0) {
  console.error('Critical vulnerabilities found!');
}

useNpmMaintainerAvatar(username)

Returns the public Gravatar URL for an npm user when a public email is available.

const { data: avatarUrl } = useNpmMaintainerAvatar('sindresorhus');

return avatarUrl ? <img src={avatarUrl} alt="sindresorhus" /> : null;

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | enabled | boolean | true | Disabled when username is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmMaintainer(username)

Fetches the public profile of an npm user. No authentication required.

const { data: user } = useNpmMaintainer('sindresorhus');

console.log(user?.name, user?.email);

Throws NpmApiError(404) if the user has no published packages.

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | enabled | boolean | true | Disabled when username is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmMaintainerPackages(username, options?)

Searches for all packages published by a user, with pagination support.

const { data } = useNpmMaintainerPackages('sindresorhus', { size: 25, from: 0 });

console.log(`${data?.total} packages`);
data?.objects.forEach(o => console.log(o.package.name, o.package.version));

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | size | number | 20 | Results per page (max 250) | | from | number | 0 | Pagination offset | | quality | number | — | Scoring weight 0–1 | | popularity | number | — | Scoring weight 0–1 | | maintenance | number | — | Scoring weight 0–1 | | enabled | boolean | true | Disabled when username is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmMaintainerPackagesInfinite(username, options?)

Infinite-scroll variant of useNpmMaintainerPackages. Each call to fetchNextPage() advances the from offset by size. Results accumulate in data.pages.

import { useNpmMaintainerPackagesInfinite } from '@api-hooks/npm';

function MaintainerPackageList({ username }: { username: string }) {
  const { data, hasNextPage, fetchNextPage, isFetchingNextPage } =
    useNpmMaintainerPackagesInfinite(username, { size: 10 });

  const allPackages = data?.pages.flatMap(p => p.objects) ?? [];

  return (
    <>
      <ul>
        {allPackages.map(o => (
          <li key={o.package.name}>{o.package.name}</li>
        ))}
      </ul>
      {hasNextPage && (
        <button onClick={() => fetchNextPage()} disabled={isFetchingNextPage}>
          Load more
        </button>
      )}
    </>
  );
}

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | size | number | 20 | Results per page (max 250) | | quality | number | — | Scoring weight 0–1 | | popularity | number | — | Scoring weight 0–1 | | maintenance | number | — | Scoring weight 0–1 | | enabled | boolean | true | Disabled when username is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmSearch(text, options?)

Full-text search across the npm registry.

const { data } = useNpmSearch('react state management', { size: 10 });

data?.objects.forEach(o => {
  console.log(o.package.name, o.score.final);
});

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | size | number | 20 | Results per page (max 250) | | from | number | 0 | Pagination offset | | quality | number | — | Scoring weight 0–1 | | popularity | number | — | Scoring weight 0–1 | | maintenance | number | — | Scoring weight 0–1 | | enabled | boolean | true | Disabled when text is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmSearchInfinite(text, options?)

Infinite-scroll variant of useNpmSearch. Each call to fetchNextPage() advances the from offset by size. Results accumulate in data.pages.

import { useNpmSearchInfinite } from '@api-hooks/npm';

function InfiniteSearch() {
  const { data, hasNextPage, fetchNextPage, isFetchingNextPage } =
    useNpmSearchInfinite('react', { size: 10 });

  const allPackages = data?.pages.flatMap(p => p.objects) ?? [];

  return (
    <>
      <ul>
        {allPackages.map(o => (
          <li key={o.package.name}>{o.package.name}</li>
        ))}
      </ul>
      {hasNextPage && (
        <button onClick={() => fetchNextPage()} disabled={isFetchingNextPage}>
          Load more
        </button>
      )}
    </>
  );
}

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | size | number | 20 | Results per page (max 250) | | quality | number | — | Scoring weight 0–1 | | popularity | number | — | Scoring weight 0–1 | | maintenance | number | — | Scoring weight 0–1 | | enabled | boolean | true | Disabled when text is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmTopPackages(options?)

Returns top packages according to npm search's default ranking.

const { data } = useNpmTopPackages({ n: 10 });

data?.objects.forEach(o => console.log(o.package.name, o.score.final));

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | n | number | 20 | Number of packages to return (max 250) | | enabled | boolean | true | Disable the query | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmTopByPopularity(options?)

Returns top packages weighted by popularity.

const { data } = useNpmTopByPopularity({ n: 10 });

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | n | number | 20 | Number of packages to return (max 250) | | enabled | boolean | true | Disable the query | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmTopByQuality(options?)

Returns top packages weighted by quality.

const { data } = useNpmTopByQuality({ n: 10 });

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | n | number | 20 | Number of packages to return (max 250) | | enabled | boolean | true | Disable the query | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmTopByMaintenance(options?)

Returns top packages weighted by maintenance.

const { data } = useNpmTopByMaintenance({ n: 10 });

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | n | number | 20 | Number of packages to return (max 250) | | enabled | boolean | true | Disable the query | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmTopByKeyword(keyword, options?)

Returns top packages for a keyword.

const { data } = useNpmTopByKeyword('react', { n: 10 });

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | n | number | 20 | Number of packages to return (max 250) | | enabled | boolean | true | Disabled when keyword is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmTopByScope(scope, options?)

Returns top packages for a scope. The scope may include or omit the leading @.

const { data } = useNpmTopByScope('@types', { n: 10 });

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | n | number | 20 | Number of packages to return (max 250) | | enabled | boolean | true | Disabled when scope is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmOrgPackages(org, options?)

Returns all packages an org has access to, keyed by package name. Requires a registry token with org access.

const { data } = useNpmOrgPackages('npmcli');

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | enabled | boolean | true | Disabled when org is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmOrgTeams(org, options?)

Returns all teams in an org. Requires a registry token with org access.

const { data } = useNpmOrgTeams('npmcli');

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | enabled | boolean | true | Disabled when org is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmOrgMembers(org, options?)

Returns all members in an org, keyed by username. Requires a registry token with org access.

const { data } = useNpmOrgMembers('npmcli');

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | enabled | boolean | true | Disabled when org is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmOrgTeamMembers(org, team, options?)

Returns all usernames in an org team. Requires a registry token with org access.

const { data } = useNpmOrgTeamMembers('npmcli', 'cli');

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | enabled | boolean | true | Disabled when org or team is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmWhoami(options?)

Returns the npm username associated with the configured auth token. Useful for validating a token without knowing the username in advance.

Requires a registry auth token — throws NpmApiError(401) if no token is set or the token is invalid.

const npm = new NpmClient({ token: 'npm_...' });

// Pass the token via NpmClientProvider
<NpmClientProvider options={{ token: 'npm_...' }}>
  <App />
</NpmClientProvider>

// Then in your component:
const { data } = useNpmWhoami();

console.log(data?.username); // 'pilmee'

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | enabled | boolean | true | Disable the query | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmUser(username)

Fetches the authenticated profile of an npm user via the registry's user endpoint. Returns richer data than useNpmMaintainer — includes tfa, email, created, and updated fields.

const { data } = useNpmUser('sindresorhus');

console.log(data?.name, data?.email);

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | enabled | boolean | true | Disabled when username is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


useNpmUserPackages(username, params?)

Fetches the list of package names published by an npm user. Returns a string[].

const { data: packages } = useNpmUserPackages('sindresorhus');

packages?.forEach(name => console.log(name));

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | enabled | boolean | true | Disabled when username is empty | | queryOptions | QueryOverrides<TData> | undefined | Override TanStack Query options (staleTime, retry, gcTime, select, etc.) |


License

MIT © ElJijuna