A modern, production-ready full-stack React application template combining TanStack Router with Hono for server-side rendering. This setup delivers fast, SEO-friendly applications with excellent developer experience.
# Clone the template
npx degit bskimball/tanstack-hono my-app
# Navigate to your project
cd my-app
# Run the interactive setup script
bash scripts/setup.shThe setup script will:
- Update project name in package.json
- Create .env file from .env.example
- Install dependencies (optional)
- Initialize git repository (optional)
# Clone the template
npx degit bskimball/tanstack-hono my-app
# Navigate to your project
cd my-app
# Copy environment file
cp .env.example .env
# Install dependencies
npm install
# Start development server
npm run devOpen http://localhost:3000 to see your app running!
Health Check: http://localhost:3000/api/health
- πΊ TanStack Router: Type-safe, file-based routing with powerful data loading
- β‘ Hono SSR: Ultra-fast server-side rendering with minimal overhead
- π₯ Vite: Lightning-fast development with Hot Module Replacement
- π TypeScript: Full type safety across client and server
- π¨ Tailwind CSS: Modern utility-first CSS framework
- π§Ή Biome: Fast linting, formatting, and code quality
- π§ͺ Vitest: Fast unit testing with great DX
src/
βββ components/
β βββ Header.tsx # Reusable UI components
βββ routes/ # File-based routing (auto-generated)
β βββ __root.tsx # Root layout component
β βββ index.tsx # Home page route
β βββ about.tsx # About page route
β βββ -test.ts # Test route utilities
βββ entry-client.tsx # Client-side hydration entry
βββ entry-server.tsx # Hono server with SSR setup
βββ router.tsx # Router configuration
βββ styles.css # Global styles
npm run dev # Start development server
npm run build # Build for production
npm start # Start production server
npm run test # Run tests
npm run check # Lint and format code- Request: Browser requests a URL
- Server: Hono matches route and runs TanStack Router SSR
- Render: React components render to HTML string
- Response: Full HTML sent to browser with embedded data
- Hydration: Client-side React takes over for SPA navigation
Routes are automatically generated from files in src/routes/:
// src/routes/about.tsx
import { createFileRoute } from "@tanstack/react-router";
export const Route = createFileRoute("/about")({
component: AboutPage,
});
function AboutPage() {
return <div>About us!</div>;
}import { Link } from "@tanstack/react-router";
<Link to="/about">About</Link>export const Route = createFileRoute("/users")({
loader: async () => {
const users = await fetch("/api/users").then((r) => r.json());
return { users };
},
component: UsersPage,
});
function UsersPage() {
const { users } = Route.useLoaderData();
return (
<ul>
{users.map((user) => (
<li key={user.id}>{user.name}</li>
))}
</ul>
);
}The root layout (src/routes/__root.tsx) wraps all pages:
import { Outlet, createRootRoute } from "@tanstack/react-router";
import { Header } from "../components/Header";
export const Route = createRootRoute({
component: RootLayout,
});
function RootLayout() {
return (
<>
<Header />
<main>
<Outlet />
</main>
</>
);
}SSR Advantages:
- SEO: Fully rendered HTML for search engines
- LCP: Faster Largest Contentful Paint
- Progressive Enhancement: Works without JavaScript
- Social Sharing: Rich preview cards with meta tags
Hono Benefits:
- Small Bundle: Minimal server overhead
- Edge Ready: Deploy to Cloudflare Workers, etc.
- Fast Startup: Quick cold start times
# Build and run production
docker-compose up app
# Development with hot reload
docker-compose --profile dev up devdocker build -t tanstack-hono .
docker run -p 3000:3000 tanstack-hononpm run build
npm start- Docker: Use included Dockerfile and docker-compose.yml
- Vercel/Netlify: Serverless functions
- Railway/Render: Container deployments
- Cloudflare Workers: Edge runtime
- VPS: With PM2 + Nginx
See ARCHITECTURE.md for detailed deployment strategies.
- AGENTS.md - Guide for AI agents working with this codebase
- CLAUDE.md - Claude-specific context and patterns
- ARCHITECTURE.md - Deep dive into system design
- CONTRIBUTING.md - Contribution guidelines
- SECURITY.md - Security policy and best practices
This template includes comprehensive documentation for AI coding assistants:
.cursorrulesfor Cursor IDEAGENTS.mdfor general AI agent guidelinesCLAUDE.mdfor Claude-specific context
- TanStack Router - Type-safe routing
- Hono - Ultrafast web framework
- SSR Guide - TanStack Router SSR
- Vite SSR - Vite server-side rendering
MIT License - see LICENSE file for details
Contributions are welcome! Please read CONTRIBUTING.md for guidelines.