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

@anhur/vite

v0.1.0

Published

Vite plugin for @anhur/core: builds content, rebuilds on change, error overlay, serves assets

Readme

@anhur/vite

⚡ Vite plugin for Anhur.

It builds your content before the app, makes anhur/generated importable, rebuilds when content changes, shows build errors in the browser overlay, and serves copied assets.

📦 Install

bun add @anhur/core @anhur/vite

🚀 Setup

import { defineConfig } from "vite";
import anhur from "@anhur/vite";

export default defineConfig({
  plugins: [anhur()],
});

Put anhur.config.ts in the Vite root (or pass configPath), and point TypeScript at the output:

// tsconfig.json
{
  "compilerOptions": {
    "paths": { "anhur/generated": ["./.anhur/generated"] },
  },
}
import { allPosts, getPost } from "anhur/generated";

No separate anhur build step is needed — the plugin builds on vite dev and vite build (including vite build --watch).

🔁 Dev

  • Uses Vite's file watcher. Changes to content folders, the config, and files the config imports trigger a rebuild (debounced); unrelated files do not.
  • Only changed generated modules are rewritten, so Vite's normal HMR picks them up.
  • A failed build keeps the dev server running: the error (with file and field) shows in the overlay and the terminal, and the last good output stays in place. Fixing the file reloads the page.
  • Changes made while the first build runs are picked up by a rebuild right after it.
  • server.restart() keeps rebuilding, also with an inline plugin instance.
  • Copied assets are served under their URL prefix, with single Range requests (video seeking), ETag / If-None-Match, correct content types and X-Content-Type-Options: nosniff. SVGs also get Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; img-src data: 'self'; sandbox; send the same headers from your production server or CDN. Dotfiles and paths outside the assets folder are never served.

Each build logs one line:

[anhur] rebuilt 12 document(s) in 48ms → .anhur/generated (2 written, 0 removed; posts 8, authors 4)

📦 Build

A failed content build fails vite build with the diagnostics. The assets of this build (the files listed in .anhur-assets.json, never leftovers of earlier builds) are added to the client output (for example dist/anhur-assets/) when they are served locally; with a CDN base and storage, @anhur/assets uploads them instead. When the assets base equals the Vite base, the files go to the root of the output.

With vite build --watch, a content edit runs one content build; the Rollup rebuild caused by the rewritten generated modules reuses it.

Do not run vite build while vite dev uses the same assets folder: both remove files the other one does not use.

⚙️ Options

anhur({
  // Config file relative to the Vite root. Default: anhur.config.{ts,mts,js,mjs}
  configPath: "./content/anhur.config.ts",
});

The Vite base is applied to local asset URLs (base: "/app/" → /app/anhur-assets/…).

Without Vite, use the anhur CLI from @anhur/core (anhur build, anhur check, anhur watch).

License

MIT