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:
- Build the client-side app:
vite build - 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.