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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@mehdashti/react-core

v0.1.1

Published

Core React providers and hooks for Smart Platform applications

Downloads

148

Readme

@mehdashti/react-core

Core React providers and hooks for Smart Platform applications.

Installation

pnpm add @mehdashti/react-core

Features

  • ThemeProvider: Dark/light theme management with RTL support
  • QueryProvider: TanStack Query client setup with optimized defaults
  • ErrorBoundary: Global error handling with fallback UI
  • AppConfigProvider: Application configuration management
  • AppProviders: Convenient wrapper combining all providers

Usage

Quick Start

Wrap your app with AppProviders:

import { AppProviders } from '@mehdashti/react-core'
import { QueryClient } from '@tanstack/react-query'

const queryClient = new QueryClient()

function App() {
  return (
    <AppProviders queryClient={queryClient}>
      <YourApp />
    </AppProviders>
  )
}

ThemeProvider

import { ThemeProvider, useTheme } from '@mehdashti/react-core'

function ThemeToggle() {
  const { theme, setTheme, isDark } = useTheme()

  return (
    <button onClick={() => setTheme(isDark ? 'light' : 'dark')}>
      Toggle theme
    </button>
  )
}

function App() {
  return (
    <ThemeProvider defaultTheme="system" defaultDirection="ltr">
      <ThemeToggle />
    </ThemeProvider>
  )
}

ErrorBoundary

import { ErrorBoundary } from '@mehdashti/react-core'

function App() {
  return (
    <ErrorBoundary
      fallback={(error) => (
        <div>Error: {error.message}</div>
      )}
      onError={(error, errorInfo) => {
        console.error('Error caught:', error, errorInfo)
      }}
    >
      <YourApp />
    </ErrorBoundary>
  )
}

AppConfigProvider

import { AppConfigProvider, useAppConfig } from '@mehdashti/react-core'

function ConfigDisplay() {
  const { config, updateConfig } = useAppConfig()

  return (
    <div>
      <p>API URL: {config.apiUrl}</p>
      <button onClick={() => updateConfig({ apiUrl: 'https://new-api.com' })}>
        Update API URL
      </button>
    </div>
  )
}

function App() {
  return (
    <AppConfigProvider initialConfig={{ apiUrl: 'https://api.example.com' }}>
      <ConfigDisplay />
    </AppConfigProvider>
  )
}

API

Providers

AppProviders

Combines all providers in one component.

Props:

  • children: ReactNode - Your application
  • queryClient?: QueryClient - TanStack Query client (optional)
  • theme?: ThemeProviderProps - Theme provider config (optional)
  • errorBoundary?: ErrorBoundaryProps - Error boundary config (optional)
  • appConfig?: AppConfigProviderProps - App config provider config (optional)

ThemeProvider

Props:

  • children: ReactNode
  • defaultTheme?: 'light' | 'dark' | 'system' (default: 'system')
  • defaultDirection?: 'ltr' | 'rtl' (default: 'ltr')
  • storageKey?: string (default: 'smart-platform-theme')

QueryProvider

Props:

  • children: ReactNode
  • queryClient?: QueryClient - Custom query client (optional, creates default if not provided)

ErrorBoundary

Props:

  • children: ReactNode
  • fallback?: ReactNode | ((error: Error, errorInfo: ErrorInfo) => ReactNode) - Custom fallback UI
  • onError?: (error: Error, errorInfo: ErrorInfo) => void - Error callback

AppConfigProvider

Props:

  • children: ReactNode
  • initialConfig?: AppConfig - Initial configuration

Hooks

useTheme()

Returns:

  • theme: 'light' | 'dark' | 'system' - Current theme
  • setTheme: (theme) => void - Update theme
  • direction: 'ltr' | 'rtl' - Current direction
  • setDirection: (direction) => void - Update direction
  • isDark: boolean - Whether dark theme is active
  • isRTL: boolean - Whether RTL is active

useAppConfig()

Returns:

  • config: AppConfig - Current configuration
  • updateConfig: (config) => void - Update configuration

Types

export type ThemeMode = 'light' | 'dark' | 'system'
export type Direction = 'ltr' | 'rtl'

export interface AppConfig {
  appName?: string
  apiUrl?: string
  enableDevTools?: boolean
  [key: string]: unknown
}

License

MIT