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

@stax-ui/vite-plugin

v0.5.1

Published

Vite plugin for Stax applications

Readme

@stax-ui/vite-plugin

Vite plugin for Stax SSR applications. Provides server-code stripping for client builds and an SSR dev server with HMR.

Installation

pnpm add -D @stax-ui/vite-plugin

Quick Start

// vite.config.ts
import { defineConfig } from "vite";
import { staxPlatform } from "@stax-ui/vite-plugin";

export default defineConfig({
  plugins: [
    staxPlatform({ entry: "src/vite-entry.ts" }),
  ],
});

Only needed when using @stax-ui/platform for SSR. Pure SPA apps don't need this plugin.

What It Does

The plugin provides two capabilities:

1. Server-Code Stripping (Client Builds)

When Vite builds the client bundle, the plugin removes server-only code from route definitions so that server dependencies (database clients, file system access, etc.) don't get bundled into the browser.

Loaders — the first argument to Route.get() is replaced with null:

// Source
Route.get(
  ({ params }) => db.getUser(params.id),  // server-only loader
  (user) => UserPage({ user }),
)

// Client bundle
Route.get(
  null,                                    // stripped
  (user) => UserPage({ user }),
)

Mutation handlers — the handler function in Route.post/put/del() is replaced with a throw stub. The action key is preserved since the client needs it to compute action URLs:

// Source
Route.post("create", (body) =>
  Effect.gen(function* () {
    const svc = yield* PostService;
    return yield* svc.createPost(body.content);
  }),
)

// Client bundle
Route.post("create", () => { throw new Error("server only"); })

This stripping only applies to client builds — SSR builds and dev-mode SSR modules keep the full server code.

2. SSR Dev Server (Dev Mode)

When entry is provided, the plugin runs an SSR dev server during vite dev:

  • Intercepts incoming requests (skips Vite internal paths and static assets)
  • Loads your entry module via server.ssrLoadModule() for HMR support
  • Calls your entry's render(request) function with a standard Web Request
  • Injects Vite's HMR client into HTML responses
  • Displays readable error pages with stack traces on failure

Entry Module

The entry file must export a render function:

// src/vite-entry.ts
import { HttpApp, HttpRouter } from "@effect/platform";
import { Layer } from "effect";
import { Platform } from "@stax-ui/platform";

import { App } from "./App.js";
import { router } from "./routes.js";

const staxRoutes = Platform.toHttpRoutes(router, {
  app: App,
  document: {
    title: "My App",
    scripts: ["/src/client.ts"],
    head: '<link rel="stylesheet" href="/src/styles.css">',
  },
});

const app = HttpRouter.empty.pipe(HttpRouter.concat(staxRoutes));

const { handler } = HttpApp.toWebHandlerLayer(app, MyServiceLayer);

export async function render(request: Request): Promise<Response> {
  return handler(request);
}

The render function receives a standard Web Request and must return a Response. Use HttpApp.toWebHandlerLayer from @effect/platform to bridge Effect's HTTP handlers to the Web API.

Options

staxPlatform({
  // Path to SSR entry module. Enables the dev server when provided.
  entry: "src/vite-entry.ts",

  // File patterns to apply stripping to (default: /\.(tsx?|jsx?)$/)
  include: /\.(tsx?|jsx?)$/,

  // File patterns to exclude from stripping
  exclude: /\.test\./,
})

| Option | Type | Default | Description | |---|---|---|---| | entry | string | — | SSR entry module path. Enables dev server when set. | | include | RegExp | /\.(tsx?\|jsx?)$/ | Files to apply server-code stripping to | | exclude | RegExp | — | Files to exclude from stripping |

API Reference

| Export | Description | |---|---| | staxPlatform(options?) | Create the Vite plugin | | stripServerCode(code) | Strip server code from a string (exported for testing) |