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

arweave-renderer-react

v0.2.0

Published

This library provides React hooks for fetching arweave data(images, markdown, and videos) using React Query. All hooks follow a similar pattern and integrate with Arweave through the wayfinder library.

Readme

Arweave Renderer React

This library provides React hooks for fetching arweave data(images, markdown, and videos) using React Query. All hooks follow a similar pattern and integrate with Arweave through the wayfinder library.

Common Features

  • React Query Integration: All hooks use @tanstack/react-query for caching, background updates, and error handling
  • Type Safety: Full TypeScript support with proper type definitions
  • MIME Type Validation: Content type validation to ensure the requested media matches the expected format
  • Arweave Integration: Fetches media from Arweave using the wayfinder library
  • Consistent Error Handling: Throws descriptive errors when content type doesn't match expectations

Installation

npm i arweave-renderer-react
# Install the required peer dependencies
npm install @tanstack/react-query

Setup

Make sure to wrap your app with the React Query provider:

import { QueryClient, QueryClientProvider } from '@tanstack/react-query'

const queryClient = new QueryClient()

function App() {
  return (
    <QueryClientProvider client={queryClient}>
      {/* Your app components */}
    </QueryClientProvider>
  )
}

Hooks

useImage

Fetches and validates image content from Arweave.

const { image, isImageLoading, isImageError, error } = useImage(id);

Parameters:

  • id (string | undefined): The Arweave transaction ID of the image

Returns:

{
  image: TImage | undefined,      // Image data with src and alt properties
  isImageLoading: boolean,        // Loading state
  isImageError: boolean,          // Error state
  error: Error | null             // Error object if request failed
}

TImage Type:

{
  src: string,     // Image URL
  alt: string      // Alt text (from the tag or default "arweave image")
}

Behavior:

  • Validates that the content is an image using MIME type
  • Extracts alt text from the tags in metadata
  • Throws "Not an image" error if content type validation fails

useMarkDown

Fetches and validates markdown content from Arweave.

const { markDown, isMarkDownLoading, isMarkDownError, error } = useMarkDown(id);

Parameters:

  • id (string | undefined): The Arweave transaction ID of the markdown content

Returns:

{
  markDown: TMarkDown | undefined,    // Markdown data with text and name properties
  isMarkDownLoading: boolean,         // Loading state
  isMarkDownError: boolean,           // Error state
  error: Error | null                 // Error object if request failed
}

TMarkDown Type:

{
  text: string,    // Raw markdown content
  name: string     // Content name (from the tag or default "markdown")
}

Behavior:

  • Validates that the content is markdown using MIME type
  • Fetches the actual text content
  • Extracts name from the tags in metadata
  • Throws "Not markdown" error if content type validation fails

useVideo

Fetches and validates video content from Arweave.

const { video, isVideoLoading, isVideoError, error } = useVideo(id);

Parameters:

  • id (string | undefined): The Arweave transaction ID of the video

Returns:

{
  video: TVideo | undefined,      // Video data with src and name properties
  isVideoLoading: boolean,        // Loading state
  isVideoError: boolean,          // Error state
  error: Error | null             // Error object if request failed
}

TVideo Type:

{
  src: string,     // Video URL
  name: string     // Video name (from the tag or default "arweave video")
}

Behavior:

  • Validates that the content is a video using MIME type
  • Extracts name the tags in metadata
  • Throws "Not a video" error if content type validation fails

Error Handling

All hooks will throw errors in the following scenarios:

  • Network failures during media request
  • Content type mismatch (e.g., requesting an image but getting a video)
  • Invalid or missing transaction IDs

The React Query error boundary will catch these errors, and they can be handled through the returned error object and isError boolean.

Contributing

  • Fork the repository
  • Create your feature branch (git checkout -b feature/my-feature)
  • Commit your changes
  • Open a pull request

License

MIT