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

@assistant-ui/next

v0.0.23

Published

Next.js integration for assistant-ui: the withAui() config wrapper and the "use generative" directive compiler that colocates a tool's schema, server-only execute, and client-only render in one file.

Readme

@assistant-ui/next

Next.js integration for assistant-ui: the withAui() config wrapper and the compiler for the "use generative" directive. Colocate a tool's schema, server-only execute, and client-only render in one file; the compiler emits a different module per build target so each side only loads what it needs.

See SPEC.md for the full design.

Why

"use client" is whole-module, so it can't keep a tool's zod schema readable on the server while keeping its render on the client. And a backend execute holds secrets (DB handles, API keys) that must never reach the browser bundle. "use generative" routes each property to the right place.

Every tool must declare an execute, and you wrap the default export in defineToolkit({ ... }) (both are enforced — the compiler errors otherwise). You don't declare a tool's kind: the compiler infers it from the execute and writes a type field back into the output.

| how you author the execute | kind | where it runs | | ----------------------------------------- | ---------- | ---------------------------- | | execute with a "use client" directive | frontend | client | | execute (plain) | backend | server (server-only guard) | | execute: humanTool() | human | — (the UI supplies a result) |

A plain execute is server-only by default — you can only run one in the browser by opting in with "use client", so secrets can't leak by omission.

Authoring

"use generative";
import { z } from "zod";
import { defineToolkit } from "@assistant-ui/react";
import { db } from "@/db"; // server-only
import { Chart } from "@/ui/chart"; // client-only

export default defineToolkit({
  weather: {
    description: "Show the weather for a city.",
    parameters: z.object({ city: z.string() }),
    execute: async ({ city }) => db.weather.get(city), // backend → stays on the server
    render: (props) => <Chart data={props} />, // stays on the client
  },
});

The server build keeps parameters + execute (guarded by import "server-only", tagged type: "backend") and drops render and @/ui/chart. The client build keeps parameters + render (under "use client") and drops execute and @/db. A frontend tool marks its execute with "use client":

execute: async ({ city }) => {
  "use client";
  return navigator.geolocation /* … runs in the browser, kept client-side */;
},

Wiring into Next.js

Wrap your config. Detection is by the "use generative" directive — there is no filename convention; modules without the directive pass through untouched.

// next.config.ts
import { withAui } from "@assistant-ui/next";

export default withAui({
  /* your Next config */
});

withAui applies the loader to your TS/TSX. To limit how many files it scans, narrow the globs: withAui(config, { rules: ["*.generative.tsx"] }).

Import the module bare from both sides — the loader rewrites it into a facade that resolves to the right build per layer (no query, no per-file config):

// a client component → resolves to the client build (schema + render)
import toolkit from "@/lib/chat.generative";

// a route handler (react-server layer) → resolves to the server build (schema + execute)
import toolkit from "@/lib/chat.generative";

With the AI SDK, convert the server build to a ToolSet (see AISDKToolkit in @assistant-ui/ai-sdk).

Validated on Next 16.2.6 (Turbopack). Turbopack honors the loader-emitted "use client", but compiles one output per resource path — so the server build is selected by its own ?generative-env=server query rather than by build layer. Clear .next after changing the loader (Turbopack caches loader output).

License

MIT