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

@faultlens/react

v0.1.0

Published

A beautiful, themeable React component for displaying API/HTTP error states with animated SVG icons, 3 icon variants, compact mode, and full TypeScript support.

Readme

@faultlens/react

Beautiful, themeable React components for displaying API/HTTP error states with animated SVG icons.

npm version TypeScript License: MIT

Features

  • 🎨 12 Error Codes — Built-in configs for 400, 401, 403, 404, 408, 429, 500, 502, 503, 504, network errors, and unknown errors
  • 3 Icon Variants — Default (animated), Minimal (line-based), and Filled (bold shapes)
  • 🎭 Themeable — Full theming system with per-error-code overrides, custom colors, and custom icons
  • 📱 Compact Mode — Inline-friendly compact layout for notifications/toasts
  • 🔧 Technical Details — Expandable panel with request ID, timestamp, stack trace, and copy-to-clipboard
  • Tree-Shakeable — Only import what you need
  • 🔤 TypeScript — Full type definitions included
  • ⚛️ Next.js Ready"use client" directives included

Installation

npm install @faultlens/react

Peer Dependencies

npm install react react-dom lucide-react

The component uses Tailwind CSS classes for styling. If you're using Tailwind in your project, the styles will work automatically. Ensure your Tailwind config scans the package:

// tailwind.config.js
module.exports = {
  content: [
    // ... your paths
    './node_modules/@faultlens/react/dist/**/*.{js,mjs,cjs}',
  ],
};

Quick Start

import { ErrorDetail } from '@faultlens/react';

function MyErrorPage() {
  return (
    <ErrorDetail
      error={{ code: 404, message: 'Page not found' }}
      onGoHome={() => navigate('/')}
      onGoBack={() => navigate(-1)}
    />
  );
}

API Reference

<ErrorDetail />

| Prop | Type | Default | Description | |---|---|---|---| | error | ApiError | required | Error object with code and optional details | | onRetry | () => void | — | Handler for retry action | | onGoHome | () => void | — | Handler for go home action | | onGoBack | () => void | — | Handler for go back action | | onLogin | () => void | — | Handler for login action | | onContactSupport | () => void | — | Handler for contact support action | | onRefresh | () => void | — | Handler for refresh action | | showTechnicalDetails | boolean | true | Show expandable technical details panel | | compact | boolean | false | Use compact inline layout | | className | string | '' | Additional CSS classes | | theme | ErrorThemeConfig | — | Direct theme override (takes priority over context) |

ApiError

interface ApiError {
  code: number | string;    // HTTP status code or custom code
  message?: string;         // Custom error message
  details?: string;         // Additional details
  requestId?: string;       // Request tracking ID
  timestamp?: string;       // ISO timestamp
  stackTrace?: string;      // Stack trace for debugging
  url?: string;             // Request URL
}

Supported Error Codes

| Code | Title | Icon | Severity | |---|---|---|---| | 400 | Bad Request | Warning triangle | warning | | 401 | Unauthorized | Lock | warning | | 403 | Access Denied | Shield with X | critical | | 404 | Not Found | Magnifying glass | info | | 408 | Request Timeout | Clock | warning | | 429 | Too Many Requests | Speedometer | warning | | 500 | Internal Server Error | Server on fire | critical | | 502 | Bad Gateway | Broken chain | critical | | 503 | Service Unavailable | Gears | warning | | 504 | Gateway Timeout | Clock | warning | | network | Network Error | WiFi disconnected | critical | | unknown | Something Went Wrong | Sad face | info |

Compact Mode

For inline error display (toasts, notifications, sidebars):

<ErrorDetail
  error={{ code: 500, message: 'Server error' }}
  onRetry={() => refetch()}
  compact
/>

Theming

Using Theme Provider

Wrap your app or a section with ErrorThemeProvider:

import { ErrorDetail, ErrorThemeProvider } from '@faultlens/react';

const myTheme = {
  name: 'My Custom Theme',
  iconVariant: 'minimal',       // 'default' | 'minimal' | 'filled'
  borderRadius: '0.75rem',
  overrides: {
    404: {
      title: 'Oops! Page Missing',
      description: 'We couldn\'t find what you\'re looking for.',
      colors: {
        primary: '#6366F1',
        background: '#EEF2FF',
      },
    },
  },
};

function App() {
  return (
    <ErrorThemeProvider theme={myTheme}>
      <ErrorDetail error={{ code: 404 }} onGoHome={() => navigate('/')} />
    </ErrorThemeProvider>
  );
}

Direct Theme Prop

Pass a theme directly to a single instance:

<ErrorDetail
  error={{ code: 500 }}
  theme={{ iconVariant: 'filled', borderRadius: '2rem' }}
  onRetry={() => refetch()}
/>

Theme Override Options

interface ErrorCodeOverride {
  title?: string;
  description?: string;
  suggestion?: string;
  severity?: 'critical' | 'warning' | 'info';
  iconType?: string;
  customIcon?: React.ComponentType;
  colors?: {
    primary?: string;
    background?: string;
    backgroundEnd?: string;
    border?: string;
    text?: string;
    badgeBg?: string;
    badgeText?: string;
  };
  actions?: ErrorAction[];
}

Icon Variants

Default — Animated SVGs with CSS keyframe animations

Minimal — Clean line-based icons with subtle animations

Filled — Bold, filled shapes with vibrant colors

Switch globally via theme:

<ErrorThemeProvider theme={{ iconVariant: 'filled' }}>
  {/* All ErrorDetail instances use filled icons */}
</ErrorThemeProvider>

Using Icons Standalone

import { AnimatedErrorIcon, iconMap, minimalIconMap, filledIconMap } from '@faultlens/react';

// Convenience component
<AnimatedErrorIcon iconType="notFound" />

// Direct from map
const ServerErrorIcon = iconMap['serverError'];
<ServerErrorIcon />

Utilities

import { getErrorConfig, serializeTheme, parseTheme } from '@faultlens/react';

// Get default config for any error code
const config = getErrorConfig(404);
console.log(config.title); // "Not Found"

// Serialize/parse themes for storage
const json = serializeTheme(myTheme);
const theme = parseTheme(json);

License

MIT