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

@bonfida/sns-react

v4.0.1

Published

A set of React hooks to interact with the Solana Name Service

Readme

SNS React

npm MIT License

React Query hooks for the Solana Name Service JavaScript SDK v4. The package provides a focused set of read helpers with stable cache keys and safe record handling.

Installation

Install SNS React with its peers:

npm install @bonfida/sns-react @bonfida/spl-name-service@^4.0.0 @solana/web3.js@^1.98.2 @tanstack/react-query@^5.0.0 react

SNS React supports React 18 and 19. The SNS JS SDK is a peer dependency so the application and hooks use one compatible v4 SDK instance.

Setup

Create a TanStack Query client near the application root:

import type { PropsWithChildren } from "react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

const queryClient = new QueryClient();

export function AppProviders({ children }: PropsWithChildren) {
  return (
    <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
  );
}

Pass a web3.js Connection to each hook. SNS React does not create a global RPC client or wallet provider.

Quick Start

Resolve A Domain

import { useResolve } from "@bonfida/sns-react";
import { Connection } from "@solana/web3.js";

const connection = new Connection("https://your-rpc-endpoint.example");

function Resolve() {
  const target = useResolve(connection, "example.sns");

  if (target.isPending) return <p>Loading...</p>;
  if (target.isError) return <p>{target.error.message}</p>;
  return <p>{target.data.toBase58()}</p>;
}

Use useSafeResolve instead when the JavaScript SDK's conditional SRS/SNS consistency verification is required.

Read Verified Records

import { Record } from "@bonfida/spl-name-service/record";
import { useRecords } from "@bonfida/sns-react";
import type { Connection } from "@solana/web3.js";

function Records({ connection }: { connection: Connection }) {
  const records = useRecords(
    connection,
    "example.sns",
    [Record.Url, Record.Email],
    { deserialize: true },
  );

  return (
    <ul>
      {records.data?.map((record, index) => (
        <li key={index}>{record?.deserializedContent ?? "Unavailable"}</li>
      ))}
    </ul>
  );
}

useRecords preserves request order. An entry is undefined when the account is missing or fails a required verification check.

Domain Inputs

| Hook | Input | Notes | | ------------------------------------------------------------- | ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | useResolve, useSafeResolve, useRecords, useProfilePic | Full domain such as example.sns | useSafeResolve delegates to JS SDK safe resolution and compares targets only when SRS-backed .sol resolution is enabled; other hooks inherit JS v4 domain support. | | useSubdomains | TLD-trimmed SNS parent such as example | Passed to v4 getSnsDomainKeySync. Do not include .sns. | | useSnsDomainsForOwner, usePrimaryDomain | Wallet PublicKey | Nullish input disables the query. | | useReverseLookup | Domain account PublicKey | Nullish input disables the query. |

High-level .sol reads use the JS SDK compatibility path only before finalized slot 452825395. At or after that slot they throw UnsupportedTldError. SNS React does not extend that support.

Record Safety

JS SDK v4 getMultipleRecords verifies record staleness and Right of Association (ROA). SNS React returns a record only when:

result.verified.staleness === true && result.verified.roa !== false;

verified.roa can be absent when the record type has no applicable ROA verifier. That is not a failed check. verified.roa === false is rejected.

useProfilePic uses the same checks and returns verified, deserialized content or null.

API Reference

useResolve

Resolves a full domain to its effective owner with v4 resolve.

useResolve(connection, domain, queryOptions?)

useSafeResolve

Resolves a full domain through JS SDK safeResolve. When SRS-backed .sol resolution is enabled, the .sol and corresponding .sns targets must match. Mismatches and other SDK failures are available through the query result's error and isError fields.

useSafeResolve(connection, domain, queryOptions?)

useSnsDomainsForOwner

Returns sorted v4 SnsDomain[] values with { domain, key }. Results include directly registry-owned top-level domains with valid reverse records. Tokenized domains and subdomains are not included.

useSnsDomainsForOwner(connection, ownerPublicKey, queryOptions?)

usePrimaryDomain

Returns the native v4 { domain, reverse, stale } result. A missing primary domain returns null; RPC and other SDK errors remain query errors.

usePrimaryDomain(connection, ownerPublicKey, queryOptions?)

useSubdomains

Derives a parent account from a TLD-trimmed SNS name and returns its human-readable subdomains.

useSubdomains(connection, "example", queryOptions?)

useReverseLookup

Returns the reverse name for a domain account key.

useReverseLookup(connection, domainKey, queryOptions?)

useRecords

Fetches, optionally deserializes, verifies, and filters multiple v4 records.

useRecords(
  connection,
  domain,
  records,
  { deserialize?: boolean },
  queryOptions?,
)

useProfilePic

Returns safe Record.Pic content or null.

useProfilePic(connection, domain, queryOptions?)

Documentation

License

SNS React is licensed under the MIT License.