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

@gofreego/tsutils

v0.1.10

Published

A comprehensive React + TypeScript library with common utilities, components, theme system, and HTTP client

Readme

@gofreego/tsutils

A comprehensive React + TypeScript library providing common utilities, components, theme system, and HTTP client for your projects.

Installation

npm install @gofreego/tsutils

or

yarn add @gofreego/tsutils

Optional: Material UI (for ThemeToggle component)

If you want to use the ThemeToggle component, install Material UI:

npm install @mui/material @mui/icons-material @emotion/react @emotion/styled

Features

  • 🎨 Theme System - Customizable theme provider with light/dark mode and localStorage persistence
  • 🔘 Theme Toggle - Material UI round button for theme switching
  • 💾 LocalStorage Utility - Type-safe localStorage wrapper with error handling
  • 🔧 Utilities - Common utility functions (debounce, throttle, formatDate, etc.)
  • 🌐 HTTP Client - Type-safe HTTP client with timeout and error handling
  • 🧩 Components - Pre-built React components
  • 📦 Tree-shakeable - Only import what you need
  • 🎯 TypeScript - Full type safety out of the box

Usage

Theme System

import { ThemeProvider, useTheme, ThemeToggle, lightTheme, darkTheme } from '@gofreego/tsutils'

function App() {
  return (
    <ThemeProvider initialMode="light">
      <YourApp />
    </ThemeProvider>
  )
}

function YourComponent() {
  const { theme, themeMode, setThemeMode, toggleTheme } = useTheme()
  
  return (
    <div style={{ 
      backgroundColor: theme.colors.background,
      color: theme.colors.text 
    }}>
      <p>Current theme: {themeMode}</p>
      
      {/* Material UI Theme Toggle Button */}
      <ThemeToggle />
      
      {/* Toggle between light and dark */}
      <button onClick={toggleTheme}>
        Toggle Theme
      </button>
      
      {/* Set specific theme */}
      <button onClick={() => setThemeMode('dark')}>
        Dark Mode
      </button>
      <button onClick={() => setThemeMode('light')}>
        Light Mode
      </button>
    </div>
  )
}

// Theme persists automatically in localStorage
// Works across different apps on the same domain
function CustomThemedApp() {
  return (
    <ThemeProvider initialMode="dark" storageKey="my-app-theme">
      <YourApp />
    </ThemeProvider>
  )
}

HTTP Client

import { HttpClient } from '@gofreego/tsutils'

const client = new HttpClient({
  baseURL: 'https://api.example.com',
  timeout: 5000,
  headers: {
    'Authorization': 'Bearer token'
  }
})

// GET request
const response = await client.get('/users')

// POST request
const newUser = await client.post('/users', {
  name: 'John Doe',
  email: '[email protected]'
})

Utilities

import { debounce, throttle, formatDate, cn, LocalStorage } from '@gofreego/tsutils'

// Debounce function
const debouncedSearch = debounce((query: string) => {
  console.log('Searching for:', query)
}, 300)

// Throttle function
const throttledScroll = throttle(() => {
  console.log('Scrolling...')
}, 100)

// Format date
const formatted = formatDate(new Date(), {
  year: 'numeric',
  month: 'short',
  day: 'numeric'
})

// Combine class names
const className = cn('base-class', condition && 'conditional-class', 'another-class')

// LocalStorage utility
// Save data
LocalStorage.setItem('user', { name: 'John', id: 123 })
LocalStorage.setItem('theme', 'dark')

// Get data
const user = LocalStorage.getItem<{ name: string; id: number }>('user')
const theme = LocalStorage.getItem<string>('theme')

// Check if key exists
if (LocalStorage.hasItem('user')) {
  console.log('User data exists')
}

// Remove item
LocalStorage.removeItem('theme')

// Get all keys
const keys = LocalStorage.keys()

// Clear all
LocalStorage.clear()

Components

import { Button } from '@gofreego/tsutils'

function Example() {
  return (
    <>
      <Button variant="primary" size="md" onClick={() => alert('Clicked!')}>
        Primary Button
      </Button>
      
      <Button variant="outline" size="lg">
        Outline Button
      </Button>
    </>
  )
}

API Reference

Theme

  • ThemeProvider - Context provider for theme
    • Props: initialMode, initialTheme, storageKey
    • Automatically persists theme to localStorage
  • useTheme() - Hook to access and update theme
    • theme - Current theme object
    • themeMode - Current theme mode ('light' | 'dark')
    • setTheme(theme) - Set custom theme
    • setThemeMode(mode) - Set theme mode
    • toggleTheme() - Toggle between light and dark
  • ThemeToggle - Material UI round button component for theme switching
    • Props: lightModeTooltip, darkModeTooltip, showTooltip
    • Automatically updates localStorage
  • lightTheme - Predefined light theme
  • darkTheme - Predefined dark theme
  • defaultTheme - Default theme (alias for lightTheme)

HTTP Client

  • HttpClient - HTTP client class with methods: get(), post(), put(), patch(), delete()

Utilities

  • debounce(func, wait) - Debounce function calls
  • throttle(func, wait) - Throttle function calls
  • formatDate(date, options) - Format dates
  • cn(...classes) - Combine class names
  • LocalStorage - Safe localStorage wrapper with TypeScript support
    • getItem<T>(key) - Get item from localStorage
    • setItem<T>(key, value) - Set item in localStorage
    • removeItem(key) - Remove item from localStorage
    • hasItem(key) - Check if key exists
    • keys() - Get all keys
    • clear() - Clear all items

Development

# Install dependencies
npm install

# Build the library
npm run build

# Watch mode for development
npm run dev

# Type check
npm run typecheck

Publishing

# Login to npm
npm login

# Publish to npm
npm publish --access public

License

MIT

Author

gofreego