open-index/open-npm huggingface dataset:
npm package: @hytde/ssr
Description: Server-side rendering middleware for HyTDE. It consumes the slotified `.ssr.json` output from the Vite plugin, prefetches eligible requests, renders HTML, and embeds the SSR state for client hydration.
Author: Yoshiki Shibukawa
Latest version: 0.1.2

# @hytde/ssr

Server-side rendering middleware for HyTDE. It consumes the slotified `.ssr.json` output from the Vite plugin, prefetches eligible requests, renders HTML, and embeds the SSR state for client hydration.

## Install

```
npm install @hytde/ssr
```

## Usage

```ts
import { Hono } from "hono";
import { serve } from "@hono/node-server";
import { ssrMiddleware } from "@hytde/ssr";

const app = new Hono();
app.use(
  "*",
  ssrMiddleware({
    templateRoot: "./dist",
    apiBaseUrl: "http://127.0.0.1:8787",
    timeoutMs: 5000,
    debug: false
  })
);

serve({ fetch: app.fetch, port: 5175 });
```

## Configuration

- `templateRoot`: Directory containing `.ssr.json` files (defaults to `process.cwd()`).
- `apiBaseUrl`: Optional base URL for server-side fetches.
- `timeoutMs`: Per-request timeout (default 5000ms).
- `getAuthHeaders`: Hook to attach auth headers based on the incoming request.
- `debug`: When true, SSR failures render stack traces instead of a generic error page.

## Notes

- SSR prefetches `hy-get`/`hy-post` requests that run on startup. `hy-stream` and `hy-action` remain client-only.
- The SSR response embeds `<script id="hy-ssr-state" type="application/json">` for hydration.
- Mocking is not supported in SSR mode.

## Local server

`npm run ssr-server` starts the simple server entry shipped with this package.
npm package: @hytde/vite-plugin
Description: ```bash npm install -D @hytde/vite-plugin ```
Author: Yoshiki Shibukawa
Latest version: 0.1.2

# HyTDE Vite Plugin

## Install

```bash
npm install -D @hytde/vite-plugin
```

## Usage

```ts
import { defineConfig } from "vite";
import hyTde from "@hytde/vite-plugin";

export default defineConfig({
  plugins: [
    ...hyTde({
      inputPaths: ["."],
      tailwindSupport: true
    })
  ]
});
```

## Tailwind CSS v4

`tailwindSupport` enables Tailwind v4 processing in precompiled/SSR builds.
Standalone builds keep using the CDN script and ignore this option.

- `tailwindSupport: true`
  - Registers a virtual stylesheet with `@import "tailwindcss"`.
- `tailwindSupport: "src/styles.css"`
  - Uses the provided CSS file and validates it contains `@import "tailwindcss"`.

This plugin works alongside the official Vite Tailwind plugin (`@tailwindcss/vite`).

```ts
import tailwindcss from "@tailwindcss/vite";

export default defineConfig({
  plugins: [
    tailwindcss(),
    ...hyTde({ tailwindSupport: "src/styles.css" })
  ]
});
```

## Troubleshooting

- Missing `tailwindcss`: install `tailwindcss@^4.0.0`.
- Missing `@import "tailwindcss"`: add it to your CSS entry or enable the virtual entry.