bhvr
Bun Hono Vite React
rad:z2Y6uJmYYcpdvgGbFsYB8Bb3hjVgW
Visibility
public
Delegates
did:key:z6MkeU4hbdsewFMrEzs9T2gtoDoot9fdYUgVvLvXD1q2aC6k
Default branch
main → 477b1481bd93a07d16f47c064367c5105a8a1e19 (Sat Aug 9 18:48:51 2025)
Threshold
1
README.md
# bhvr đĻĢ

A full-stack TypeScript monorepo starter with shared types, using Bun, Hono, Vite, and React.
## Why bhvr?
While there are plenty of existing app building stacks out there, many of them are either bloated, outdated, or have too much of a vendor lock-in. bhvr is built with the opinion that you should be able to deploy your client or server in any environment while also keeping type safety.
## Quickstart
Make sure [bun](https://bun.sh) is installed
```bash
bun --version
```
Run the command below to make a new bhvr project
```bash
bun create bhvr@latest my-app
```
Once complete run the dev server
```bash
cd my-app
bun dev
```
> [!NOTE]
> Visit [bhvr.dev](https://bhvr.dev) for the full documentation!
## Features
- **Full-Stack TypeScript**: End-to-end type safety between client and server
- **Shared Types**: Common type definitions shared between client and server
- **Monorepo Structure**: Organized as a workspaces-based monorepo with Turbo for build orchestration
- **Modern Stack**:
- [Bun](https://bun.sh) as the JavaScript runtime and package manager
- [Hono](https://hono.dev) as the backend framework
- [Vite](https://vitejs.dev) for frontend bundling
- [React](https://react.dev) for the frontend UI
- [Turbo](https://turbo.build) for monorepo build orchestration and caching
## Project Structure
```
.
âââ client/ # React frontend
âââ server/ # Hono backend
âââ shared/ # Shared TypeScript definitions
â âââ src/types/ # Type definitions used by both client and server
âââ package.json # Root package.json with workspaces
âââ turbo.json # Turbo configuration for build orchestration
```
### Server
bhvr uses Hono as a backend API for its simplicity and massive ecosystem of plugins. If you have ever used Express then it might feel familiar. Declaring routes and returning data is easy.
```
server
âââ bun.lock
âââ package.json
âââ README.md
âââ src
â  âââ index.ts
âââ tsconfig.json
```
```typescript src/index.ts
import { Hono } from 'hono'
import { cors } from 'hono/cors'
import type { ApiResponse } from 'shared/dist'
const app = new Hono()
app.use(cors())
app.get('/', (c) => {
return c.text('Hello Hono!')
})
app.get('/hello', async (c) => {
const data: ApiResponse = {
message: "Hello BHVR!",
success: true
}
return c.json(data, { status: 200 })
})
export default app
```
If you wanted to add a database to Hono you can do so with a multitude of Typescript libraries like [Supabase](https://supabase.com), or ORMs like [Drizzle](https://orm.drizzle.team/docs/get-started) or [Prisma](https://www.prisma.io/orm)
### Client
bhvr uses Vite + React Typescript template, which means you can build your frontend just as you would with any other React app. This makes it flexible to add UI components like [shadcn/ui](https://ui.shadcn.com) or routing using [React Router](https://reactrouter.com/start/declarative/installation).
```
client
âââ eslint.config.js
âââ index.html
âââ package.json
âââ public
â  âââ vite.svg
âââ README.md
âââ src
â  âââ App.css
â  âââ App.tsx
â  âââ assets
â  âââ index.css
â  âââ main.tsx
â  âââ vite-env.d.ts
âââ tsconfig.app.json
âââ tsconfig.json
âââ tsconfig.node.json
âââ vite.config.ts
```
```typescript src/App.tsx
import { useState } from 'react'
import beaver from './assets/beaver.svg'
import { ApiResponse } from 'shared'
import './App.css'
const SERVER_URL = import.meta.env.VITE_SERVER_URL || "http://localhost:3000"
function App() {
const [data, setData] = useState<ApiResponse | undefined>()
async function sendRequest() {
try {
const req = await fetch(`${SERVER_URL}/hello`)
const res: ApiResponse = await req.json()
setData(res)
} catch (error) {
console.log(error)
}
}
return (
<>
<div>
<a href="https://github.com/stevedylandev/bhvr" target="_blank">
<img src={beaver} className="logo" alt="beaver logo" />
</a>
</div>
<h1>bhvr</h1>
<h2>Bun + Hono + Vite + React</h2>
<p>A typesafe fullstack monorepo</p>
<div className="card">
<button onClick={sendRequest}>
Call API
</button>
{data && (
<pre className='response'>
<code>
Message: {data.message} <br />
Success: {data.success.toString()}
</code>
</pre>
)}
</div>
<p className="read-the-docs">
Click the beaver to learn more
</p>
</>
)
}
export default App
```
### Shared
The Shared package is used for anything you want to share between the Server and Client. This could be types or libraries that you use in both environments.
```
shared
âââ package.json
âââ src
â  âââ index.ts
â  âââ types
â  âââ index.ts
âââ tsconfig.json
```
Inside the `src/index.ts` we export any of our code from the folders so it's usable in other parts of the monorepo
```typescript
export * from "./types"
```
By running `bun run dev` or `bun run build` it will compile and export the packages from `shared` so it can be used in either `client` or `server`
```typescript
import { ApiResponse } from 'shared'
```
## Getting Started
### Quick Start
You can start a new bhvr project using the [CLI](https://github.com/stevedylandev/create-bhvr)
```bash
bun create bhvr
```
### Installation
```bash
# Install dependencies for all workspaces
bun install
```
### Development
```bash
# Run all workspaces in development mode with Turbo
bun run dev
# Or run individual workspaces directly
bun run dev:client # Run the Vite dev server for React
bun run dev:server # Run the Hono backend
```
### Building
```bash
# Build all workspaces with Turbo
bun run build
# Or build individual workspaces directly
bun run build:client # Build the React frontend
bun run build:server # Build the Hono backend
```
### Additional Commands
```bash
# Lint all workspaces
bun run lint
# Type check all workspaces
bun run type-check
# Run tests across all workspaces
bun run test
```
### Deployment
Deplying each piece is very versatile and can be done numerous ways, and exploration into automating these will happen at a later date. Here are some references in the meantime.
**Client**
- [Orbiter](https://bhvr.dev/deployment/client/orbiter)
- [GitHub Pages](https://bhvr.dev/deployment/client/github-pages)
- [Netlify](https://bhvr.dev/deployment/client/netlify)
- [Cloudflare Pages](https://bhvr.dev/deployment/client/cloudflare-pages)
**Server**
- [Orbiter](https://bhvr.dev/deployment/server/orbiter)
- [Cloudflare Worker](https://bhvr.dev/deployment/server/cloudflare-workers)
- [Bun](https://bhvr.dev/deployment/server/railway)
- [Node.js](https://bhvr.dev/deployment/server/railway)
## Type Sharing
Types are automatically shared between the client and server thanks to the shared package and TypeScript path aliases. You can import them in your code using:
```typescript
import { ApiResponse } from 'shared/types';
```
## Learn More
- [bhvr Documentation](https://bhvr.dev)
- [Bun Documentation](https://bun.sh/docs)
- [Vite Documentation](https://vitejs.dev/guide/)
- [React Documentation](https://react.dev/learn)
- [Hono Documentation](https://hono.dev/docs)
- [Turbo Documentation](https://turbo.build/docs)
- [TypeScript Documentation](https://www.typescriptlang.org/docs/)