JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q71778F
  • License MIT

VoltX Server — Hono-based HTTP server with file-based routing, SSE streaming, and static file serving

Package Exports

  • @voltx/server

Readme

@voltx/server
Hono-based HTTP server with file-based routing, SSR, and SSE streaming

npm downloads license


The HTTP layer of the VoltX framework. Built on Hono with file-based routing, React SSR (streaming), CORS, logging, error handling, and static file serving.

Installation

npm install @voltx/server

Quick Start

import { Hono } from "hono";
import { registerSSR } from "@voltx/server";

const app = new Hono();

// API routes
app.get("/api", (c) => c.json({ status: "ok" }));

// SSR — renders React on the server, hydrates on the client
registerSSR(app, null, {
  title: "My App",
  entryServer: "src/entry-server.tsx",
  entryClient: "src/entry-client.tsx",
});

export default app;

Server-Side Rendering

registerSSR() provides streaming React SSR with zero config:

  • Dev mode — works with @hono/vite-dev-server for HMR
  • Production — reads the Vite client manifest for hashed asset paths, serves pre-built SSR bundle
  • Streaming — uses renderToReadableStream for fast TTFB
  • Public env — injects window.__VOLTX_ENV__ for VITE_* variables
import { registerSSR } from "@voltx/server";

registerSSR(app, viteInstance, {
  title: "My App",
  entryServer: "src/entry-server.tsx",
  entryClient: "src/entry-client.tsx",
});
Option Type Description
title string HTML <title>
entryServer string Path to SSR entry (exports render())
entryClient string Path to client hydration entry

File-Based Routing

Drop files in api/ and they become API endpoints:

api/index.ts              → GET /api
api/chat.ts               → POST /api/chat
api/users/[id].ts         → GET /api/users/:id
api/rag/query.ts          → POST /api/rag/query

Each file exports HTTP method handlers:

import type { Context } from "@voltx/server";

export async function POST(c: Context) {
  const body = await c.req.json();
  return c.json({ message: "Hello!" });
}

export function GET(c: Context) {
  return c.json({ status: "ok" });
}

Features

  • React SSR — streaming server-side rendering with registerSSR()
  • File-based routing — Next.js-style api/ directory
  • Dynamic routes[param] and [...slug] catch-all
  • Built-in middleware — CORS, request logging, error handling
  • Static file servingpublic/ directory (favicon, robots.txt, manifest)
  • Full Hono access — use any Hono middleware or plugin

Part of VoltX

This package is part of the VoltX framework. See the monorepo for full documentation.

License

MIT — Made by the Promptly AI Team