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

@theme-kit/react

v1.3.0

Published

React bindings for Theme Kit: provider, hooks, and runtime access.

Readme

@theme-kit/react

React 18/19 integration for Theme Kit. Provider + hooks over the framework-agnostic @theme-kit/core runtime.

Reference snippet

import { ThemeProvider, useTheme } from "@theme-kit/react";

export function App() {
  return (
    <ThemeProvider themes={themes} transition={{ enabled: true }}>
      <ThemeSwitcher />
    </ThemeProvider>
  );
}

function ThemeSwitcher() {
  const { theme, family, setFamily, toggleTheme } = useTheme();
  return (
    <button onClick={toggleTheme}>
      {theme.name} · {family}
    </button>
  );
}

Entry point (CSR)

For a client-rendered Vite/SPA app, mount the provider at the app root:

import { createRoot } from "react-dom/client";
import { ThemeProvider } from "@theme-kit/react";

createRoot(document.getElementById("root")!).render(
  <ThemeProvider themes={themes} defaultTheme="mint-light" initialMode="system">
    <App />
  </ThemeProvider>,
);

Optional: createThemeRoot (flash-free initial commit)

React's concurrent root schedules the initial commit, so the browser can paint an empty/partial frame before the themed tree is in the DOM — visible as a brief flicker on reload in some applications. createThemeRoot is an opt-in root helper that owns the root boundary and flushes only the first commit synchronously, so the very first frame is already the themed UI:

import { createThemeRoot } from "@theme-kit/react";

const handle = createThemeRoot({
  container: document.getElementById("root")!,
  themes,
  defaultTheme: "mint-light",
  initialMode: "system",
  transition: { enabled: true },
  render: ({ runtime }) => <App />,
});

The render({ runtime }) callback is the application's full composition — arbitrary provider trees (MUI, Chakra, React Query, Redux, Router, …) stay entirely under the application's control, and can derive their configuration from the Theme Kit runtime:

render: ({ runtime }) => (
  <MuiThemeProvider theme={createMuiTheme(runtime)}>
    <QueryClientProvider client={queryClient}>
      <RouterProvider router={router} />
    </QueryClientProvider>
  </MuiThemeProvider>
),

The handle exposes root (the underlying React root), runtime (the runtime created for this root), and unmount(). Only the initial render is flushed; subsequent renders keep React's normal concurrent scheduling.

Use it when you want Theme Kit to own the root initialization boundary — reload-sensitive demos, blank-frame-sensitive apps, or apps whose providers need the Theme Kit runtime at composition time. SSR/SSG apps must not use it — server-rendered HTML is hydrated with hydrateRoot() or a framework integration (@theme-kit/next, @theme-kit/remix), never replaced by a fresh createRoot.

Hooks

useTheme, useThemeValue, useThemeTokens, useThemeMode, useThemeFamily, useSetThemeMode, useSetThemeFamily, useToggleTheme, useThemeRuntime, useThemeHistory, useThemeBatch, useThemeSnapshot, useThemeRestore, useThemeTimeTravel, useThemeLifecycle, useThemePacks.

Components

ThemeProvider, ThemeScope, ThemeModeButton, ThemeInspector, plus useScopedTheme(ref, themeName) for imperative scoping.

Documentation

Full API reference and guides: Theme Kit docs. All packages: npm.