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

@preachjs/themes

v0.0.6

Published

themes provider for preact

Readme

@preachjs/themes

Simple, lightweight theme management for Preact applications

NPM

Demo →

Highlights

  • 📦 Tiny bundle size (~413B GZipped)
  • 🤌 Simple API
  • No FOUC (in cases where preact isn't loaded on network)
  • Based on @dumbjs/persona

Install

# npm
npm install @preachjs/themes

# yarn
yarn add @preachjs/themes

# pnpm
pnpm add @preachjs/themes

Usage

import { ThemeProvider, useTheme } from '@preachjs/themes'

const Main = () => {
  return (
    <ThemeProvider>
      <App />
    </ThemeProvider>
  )
}

const App = () => {
  const { theme, setTheme } = useTheme('system')

  return (
    <>
      <p>Current Theme: {theme}</p>
      <button
        onClick={() => {
          setTheme('light')
        }}
      >
        Light
      </button>
      <button
        onClick={() => {
          setTheme('dark')
        }}
      >
        Dark
      </button>
      <button
        onClick={() => {
          setTheme('system')
        }}
      >
        System
      </button>
    </>
  )
}

Configuration

The ThemeProvider component accepts the following props:

  • defaultTheme: The initial theme to use ('light', 'dark', or 'system'). Defaults to 'system'.
  • storageKey: The key used to persist theme preference in localStorage. Defaults to 'theme'.
<ThemeProvider defaultTheme="dark" storageKey="my-app-theme">
  <App />
</ThemeProvider>

Theme Options

Three theme options are available:

  • light: Forces light theme
  • dark: Forces dark theme
  • system: Automatically switches between light and dark based on system preferences

API Reference

useTheme(defaultTheme?: string)

React hook that provides theme management functionality.

Returns:

  • theme: Current theme value ('light', 'dark', or 'system')
  • setTheme: Function to update the theme

Example:

const { theme, setTheme } = useTheme('system')

ThemeProvider

Context provider component that must wrap your application.

Props:

  • defaultTheme: Initial theme (optional)
  • storageKey: localStorage key for persistence (optional)
  • children: React nodes

Example:

<ThemeProvider defaultTheme="system">
  <App />
</ThemeProvider>

Advanced Usage

For Advanced use cases like multiple themes and different default states, you can write your own context and use @dumbjs/persona that abstracts the browser APIs to make it simpler for you to use.