@wrksz/themesv0.5.0

Getting Started

Install and configure @wrksz/themes in your Next.js app.

Edit on GitHub

Last updated on

Installation

bun add @wrksz/themes
npm install @wrksz/themes
pnpm add @wrksz/themes
yarn add @wrksz/themes

Setup

Add ThemeProvider to your root layout. Add suppressHydrationWarning to <html> to prevent hydration warnings caused by the inline theme script that runs before React hydrates.

app/layout.tsx
import { ThemeProvider } from "@wrksz/themes";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body>
        <ThemeProvider>{children}</ThemeProvider>
      </body>
    </html>
  );
}

Usage

Use the useTheme hook in any Client Component to read and update the current theme.

components/theme-toggle.tsx
"use client";

import { useTheme } from "@wrksz/themes/client";

export function ThemeToggle() {
  const { resolvedTheme, setTheme } = useTheme();

  return (
    <button
      type="button"
      onClick={() => setTheme(resolvedTheme === "dark" ? "light" : "dark")}
    >
      Toggle theme
    </button>
  );
}

Requirements

  • Next.js 16+
  • React 19+

@wrksz/themes is a drop-in replacement for next-themes - no API changes needed. See Why not next-themes? for a full comparison.

Next steps

On this page