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

treesap

v0.4.2

Published

Opinionated Vite-first Node SSR framework.

Downloads

238

Readme

Treesap

Treesap is a Vite-first Node SSR framework.

This package provides:

  • a small request/response app runtime for Node
  • support for any fetch-compatible server app, including Hono
  • router and middleware primitives
  • static file serving with sensible cache defaults
  • a treesap/vite entry for Vite dev and production builds
  • explicit islands support built on sapling-island

Install

npm install treesap vite hono

Vite Config

import react from "@vitejs/plugin-react";
import { defineTreesapConfig } from "treesap/vite";

export default defineTreesapConfig({
  appEntry: "src/server/app.tsx",
  browserEntry: "src/treesap-client.ts",
  islands: {
    entries: {
      counter: "src/islands/counter.ts",
    },
  },
  plugins: [react()],
});

Server App

import { renderToString } from "hono/jsx/dom/server";
import { createApp } from "treesap";

export function createServerApp() {
  const app = createApp();

  app.get("/", (ctx) => {
    return ctx.html(renderToString(<h1>Hello</h1>));
  });

  return app;
}

Build with vite build, then run the server bundle with:

node dist/server/main.js

If your browser entry lives somewhere else, set browserEntry explicitly rather than relying on a fixed file location.

Hono Server App

Treesap only requires that your server factory return an object with fetch(request). That means a Hono app works without a second dev server:

/** @jsxImportSource hono/jsx */
import { Hono } from "hono";
import { jsxRenderer } from "hono/jsx-renderer";

export function createServerApp() {
  const app = new Hono();

  app.use("/*", jsxRenderer());

  app.get("/", (c) => {
    return c.render(<h1>Hello from Hono</h1>);
  });

  app.get("/api/health", (c) => c.json({ ok: true }));

  return app;
}

In production, mount your own static middleware for dist/client, for example @hono/node-server/serve-static.

Layout Assets

Render your browser assets from server layouts with getViteBrowserAssets():

import { getViteBrowserAssets } from "treesap/vite";

export default function BaseLayout(props: { children: string | object }) {
  const browserAssets = getViteBrowserAssets({
    devStyles: ["/src/styles/main.css"],
  });

  return (
    <html>
      <head>
        {browserAssets.styles.map((href) => (
          <link rel="stylesheet" href={href} />
        ))}
        {browserAssets.scripts.map((src) => (
          <script type="module" src={src}></script>
        ))}
      </head>
      <body>{props.children}</body>
    </html>
  );
}

Use devStyles when you want an eager stylesheet <link> during development to avoid a flash of unstyled content before the browser entry module loads.

Islands

Register island client entries explicitly in defineTreesapConfig():

import { defineTreesapConfig } from "treesap/vite";

export default defineTreesapConfig({
  appEntry: "src/server/app.tsx",
  browserEntry: "src/treesap-client.ts",
  islands: {
    entries: {
      counter: "src/islands/counter.ts",
    },
  },
});

Then render them from server JSX with Island:

/** @jsxImportSource hono/jsx */
import { Island } from "treesap";

export function CounterSection() {
  return (
    <Island name="counter" loading="visible">
      <div>
        <button type="button" data-island-increment="">
          Increment
        </button>
        <span data-island-count="">0</span>
      </div>
    </Island>
  );
}

Island client modules should export a default mount function:

export default function mount(root: HTMLElement) {
  const button = root.querySelector("[data-island-increment]");
  const output = root.querySelector("[data-island-count]");
  let count = 0;

  button?.addEventListener("click", () => {
    count += 1;
    if (output) {
      output.textContent = String(count);
    }
  });
}

Recommended convention: keep island entries in src/islands/, but registration is explicit and no filesystem discovery is required.

Exports

  • treesap: createApp, createRouter, serve, Context, cors, serveStatic, Island
  • treesap/vite: defineTreesapConfig, getViteBrowserAssets, getViteEntryAssets, getViteModuleAsset, treesap