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

@spellcraft/ui

v0.2.0

Published

Static GPT Tailwind generator for Next.js.

Downloads

4

Readme

Static GPT Tailwind generator for Next.js.

Under development.

Use GPT-4 to generate Tailwind styles from natural language descriptions.

Generated styles are saved to a JSON cache and injected into the application at build-time: No production fetch requests, no FOUC.

Demo

Play with the useSpell() hook in a pre-configured Next.js project on CodeSandbox.

Usage

IMPORTANT: You must set the getStaticProps export in order to load your styles from the JSON cache at build-time.

After following the Setup instructions below, you can generate styles using the useSpell() hook, like so:

// src/pages/index.tsx
import { useSpell } from "@spellcraft/ui/client";
import { withStylesCache } from "@spellcraft/ui/server";

export default function Home () {
  const styles = useSpell("purple text in small font");

  return (
    <main>
      <span className={styles}>
        hello world
      </span>
    </main>
  );
}

export const getStaticProps = withStylesCache();

Note: In production, the hook will not cause a re-render: It is only used to fetch new styles and add them to the cache in dev mode.

Setup

First, ensure you create a .env file with your OpenAI API key:

# .env
OPENAI_API_KEY="YOUR-KEY-HERE"

You'll need to configure the following pages to use UI Spells:

  1. pages/_document.tsx
  2. pages/_app.tsx
  3. pages/api/spellcraft.ts

And for every page you use UI Spells, you'll need to ensure getStaticProps exists and is wrapped:

export const getStaticProps = withStylesCache();

We'll go over how to set this up below.


1. Wrap _document.tsx with withDocument():

This adds support for SSR-compatible dynamic Tailwind with @twind/next.

// pages/_document.tsx

import { withDocument } from "@spellcraft/ui/document";
export default withDocument();

2. Wrap _app.tsx with withApp():

This wraps your app with a cache provider and utilities from @twind/next.

// pages/app.tsx

import { StrictMode } from "react";
import { type AppProps } from "next/app";

import { withApp } from "@spellcraft/ui/client";

export const MyApp = ({ Component, pageProps }: AppProps) => {
  return (
    <StrictMode>
      <Component {...pageProps} />
    </StrictMode>
  );
};

export default withApp(MyApp);

3. Add API route to pages/api/spellcraft.ts:

This endpoint is used only in development mode to update your styles cache.

When you publish to production, this endpoint will not run, and the styles will be loaded from the static JSON file at build-time only.

// pages/api/spellcraft.ts

import { StylesAPI } from "@spellcraft/ui/server";
export default StylesAPI;

That's it!

With pages/_document.tsx, pages/_app.tsx, and pages/api/spellcraft.ts configured, you're ready to use the useSpell() hook.