or

September 14, 2025 Β· View on GitHub

πŸš€ Vite SSR + Hono Server

A modern SSR (Server-Side Rendering) setup using Vite and vite-ssr, powered by a fast Hono server.


πŸ“¦ Quickstart via Git (Gitpick)

You can clone just this folder from a monorepo or template using:

bunx gitpick Mirza-Glitch/vite-hono-ssr/solid-ssr my-app

# or

npx degit Mirza-Glitch/vite-hono-ssr/solid-ssr my-app

🧱 Stack

  • ⚑️ Vite – blazing fast dev server & bundler
  • 🌐 Hono – ultrafast web framework for building backend APIs & SSR apps
  • πŸ“¦ Optional: Bun, Node.js, or Deno (your choice)

πŸ“ Project Structure

.
β”œβ”€β”€ dist/                   # Built files (client + server)
β”‚   β”œβ”€β”€ client/
β”‚   β”‚   └── index.html/         # index file with other assets
β”‚   └── server/
β”‚       └── entry-server.js
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ entry-client.ts     # Vite client entry
β”‚   β”œβ”€β”€ entry-server.ts     # vite-ssr server entry
β”‚   └── router/              # App pages (code-based routing)
β”œβ”€β”€ server.ts               # Hono server
β”œβ”€β”€ index.html              # Vite HTML template
└── vite.config.ts

πŸ“¦ Install Dependencies

bun install

πŸ§ͺ Development

bun run dev
  • Starts Vite and uses it as middleware
  • Hono handles SSR and static file fallback

πŸ—οΈ Build

bun run build

This will:

  1. Build the client-side app: vite build
  2. Build the SSR entry and manifest

πŸš€ Start (Production)

bun run preview

Starts the Hono server in production mode, serving pre-built assets and handling SSR.


βš™οΈ Custom Static File Handling

Static files (like .js, .css, .png) are served only if the request has a file extension. All other routes are handled via SSR.

Example in server.ts:

if (/\.[^\/]+$/.test(c.req.path)) {
  serveStatic({
    root: "./dist/client",
  })(c, next);
}

πŸ”Œ Backend Integration

Easily extend this setup by adding your own Hono RPC, tRPC, or even REST routes of your own choice to handle backend logic alongside SSR.


🀝 Contributions

Feel free to open issues or submit pull requests! Whether it’s a bug fix, new template, or just some ✨ polish ✨ β€” your contributions are always welcome.