A modern full-stack web application template built with Bun, React, TypeScript, and Prisma.
- Runtime: Bun (fast, modern JavaScript runtime)
- Frontend: React 19 + TypeScript
- Styling: Tailwind CSS + Shadcn UI components
- State Management: Valtio + custom useLocal hook
- Database: PostgreSQL with Prisma ORM
- Authentication: Better Auth (ready to implement)
- Multi-site Support: Single codebase, multiple sites
- File-based Routing: Custom router library
rcore-template/
├── backend/ # Backend API and server logic
│ ├── src/
│ │ ├── api/ # API endpoints
│ │ ├── lib/ # Shared backend utilities
│ │ └── index.tsx
├── frontend/ # React frontend application
│ ├── src/
│ │ ├── components/
│ │ ├── lib/
│ │ ├── pages/
│ │ └── entry/
├── shared/ # Shared code between frontend and backend
│ ├── prisma/ # Database schema
│ └── types/ # TypeScript type definitions
└── scripts/ # Build and deployment scripts
- Bun (latest version)
- PostgreSQL database
- Node.js (for some tooling compatibility)
- Clone the repository:
git clone <repository-url>
cd rcore-template- Install dependencies:
bun install- Set up environment variables:
cp .env.example .env
# Edit .env with your database credentials- Generate Prisma client:
cd shared && bun prisma generate && cd ..- Initialize the database:
cd shared && bun prisma migrate dev --name init && cd ..Run the development server:
bun run devThe application will be available at:
- Main site: http://localhost:7000
bun run prodEdit config.json to configure your sites:
{
"sites": {
"main": {
"devPort": 7000,
"domains": ["localhost:7000"],
"isDefault": true
}
}
}The template includes a basic schema with:
- User management
- Session handling
- Posts/Comments system
- Tags
- Settings
Modify shared/prisma/schema.prisma to fit your needs.
Use useLocal for component-specific state:
import { useLocal } from "@/lib/hooks/use-local";
const local = useLocal({data: []}, async () => {
// async init function
local.data = ['loaded'];
local.render();
});Use Valtio for shared state between components:
// Create state file
import { proxy } from "valtio";
export const state = {
write: proxy({ data: "hello" }),
reset() { this.write.data = "hello"; }
}
// Use in component
import { useSnapshot } from "valtio";
const read = useSnapshot(state.write);Create API endpoints using defineAPI:
import { defineAPI } from "rlib/server";
export default defineAPI({
name: "example",
url: "/api/example",
async handler(args: { param: string }) {
// Your API logic here
return { success: true };
},
});- Install Fly CLI
- Update
fly.tomlwith your app name - Deploy:
bun run flyMIT