chore: Updated getting started with manual setup
555cc917
1 file(s) · +332 −0
| 2 | 2 | ||
| 3 | 3 | bhvr is a framework used to build apps that are not tied down to a single provider, and each piece can be deployed in multiple places. |
|
| 4 | 4 | ||
| 5 | + | ## Quickstart |
|
| 6 | + | ||
| 5 | 7 | ::::steps |
|
| 6 | 8 | ||
| 7 | 9 | ### Create a New Project |
|
| 128 | 130 | From there you can select multiple [deployment options](/deployment/client/orbiter) |
|
| 129 | 131 | ||
| 130 | 132 | :::: |
|
| 133 | + | ||
| 134 | + | ## Manual Setup |
|
| 135 | + | ||
| 136 | + | There are few other ways you can get started with bhvr outside of the CLI |
|
| 137 | + | ||
| 138 | + | ### Clone or Use GitHub Template |
|
| 139 | + | ||
| 140 | + | If you visit the [bhvr repo](https://github.com/stevedylandev/bhvr) you can click the "Use This Template" button in the top right. |
|
| 141 | + | ||
| 142 | + |  |
|
| 143 | + | ||
| 144 | + | Alternatively you can clone the template |
|
| 145 | + | ||
| 146 | + | ```bash [terminal] |
|
| 147 | + | git clone https://github.com/stevedylandev/bhvr |
|
| 148 | + | ``` |
|
| 149 | + | ||
| 150 | + | ### Create from Scratch |
|
| 151 | + | ||
| 152 | + | To recreate bhvr from scratch you can do the following |
|
| 153 | + | ||
| 154 | + | ::::steps |
|
| 155 | + | ||
| 156 | + | #### Install Bun |
|
| 157 | + | ||
| 158 | + | ```bash [terminal] |
|
| 159 | + | curl -fsSL https://bun.sh/install | bash |
|
| 160 | + | ``` |
|
| 161 | + | ||
| 162 | + | #### Setup Project |
|
| 163 | + | ||
| 164 | + | ```bash [terminal] |
|
| 165 | + | mkdir bhvr |
|
| 166 | + | cd bhvr |
|
| 167 | + | bun init -y |
|
| 168 | + | rm index.ts |
|
| 169 | + | mkdir shared |
|
| 170 | + | ``` |
|
| 171 | + | ||
| 172 | + | #### Update Root Files |
|
| 173 | + | ||
| 174 | + | Update `tsconfig.json` with the following settings |
|
| 175 | + | ||
| 176 | + | ```json |
|
| 177 | + | { |
|
| 178 | + | "compilerOptions": { |
|
| 179 | + | // Environment setup & latest features |
|
| 180 | + | "lib": ["ESNext", "DOM", "DOM.Iterable"], |
|
| 181 | + | "target": "ESNext", |
|
| 182 | + | "module": "ESNext", |
|
| 183 | + | "moduleDetection": "force", |
|
| 184 | + | "jsx": "react-jsx", |
|
| 185 | + | "allowJs": true, |
|
| 186 | + | ||
| 187 | + | // Path resolution |
|
| 188 | + | "baseUrl": "./", |
|
| 189 | + | "paths": { |
|
| 190 | + | "@server/*": ["./server/src/*"], |
|
| 191 | + | "@client/*": ["./client/src/*"], |
|
| 192 | + | "@shared/*": ["./shared/src/*"] |
|
| 193 | + | }, |
|
| 194 | + | ||
| 195 | + | // Module resolution |
|
| 196 | + | "moduleResolution": "bundler", |
|
| 197 | + | "allowSyntheticDefaultImports": true, |
|
| 198 | + | "esModuleInterop": true, |
|
| 199 | + | "verbatimModuleSyntax": true, |
|
| 200 | + | ||
| 201 | + | // Strictness and best practices |
|
| 202 | + | "strict": true, |
|
| 203 | + | "forceConsistentCasingInFileNames": true, |
|
| 204 | + | "noFallthroughCasesInSwitch": true, |
|
| 205 | + | "noUncheckedIndexedAccess": true, |
|
| 206 | + | "experimentalDecorators": true, |
|
| 207 | + | ||
| 208 | + | // Output control |
|
| 209 | + | "skipLibCheck": true, |
|
| 210 | + | ||
| 211 | + | // Optional strict flags (disabled by default) |
|
| 212 | + | "noUnusedLocals": false, |
|
| 213 | + | "noUnusedParameters": false, |
|
| 214 | + | "noPropertyAccessFromIndexSignature": false |
|
| 215 | + | } |
|
| 216 | + | } |
|
| 217 | + | ``` |
|
| 218 | + | ||
| 219 | + | Update the `package.json` with the following contents |
|
| 220 | + | ||
| 221 | + | ```json |
|
| 222 | + | { |
|
| 223 | + | "name": "bhvr", |
|
| 224 | + | "version": "0.3.0", |
|
| 225 | + | "description": "A monorepo template built with Bun, Hono, Vite, and React", |
|
| 226 | + | "license": "MIT", |
|
| 227 | + | "workspaces": [ |
|
| 228 | + | "./server", |
|
| 229 | + | "./client", |
|
| 230 | + | "./shared" |
|
| 231 | + | ], |
|
| 232 | + | "scripts": { |
|
| 233 | + | "dev:client": "cd client && bun run dev", |
|
| 234 | + | "dev:server": "cd server && bun run dev", |
|
| 235 | + | "dev:shared": "cd shared && bun run dev", |
|
| 236 | + | "dev": "concurrently \"bun run dev:shared\" \"bun run dev:server\" \"bun run dev:client\"", |
|
| 237 | + | "build:client": "cd client && bun run build", |
|
| 238 | + | "build:shared": "cd shared && bun run build", |
|
| 239 | + | "build:server": "cd server && bun run build", |
|
| 240 | + | "build": "bun run build:shared && bun run build:client", |
|
| 241 | + | "postinstall": "bun run build:shared && bun run build:server" |
|
| 242 | + | }, |
|
| 243 | + | "keywords": [ |
|
| 244 | + | "bun", |
|
| 245 | + | "hono", |
|
| 246 | + | "react", |
|
| 247 | + | "vite", |
|
| 248 | + | "monorepo" |
|
| 249 | + | ], |
|
| 250 | + | "devDependencies": { |
|
| 251 | + | "bun-types": "latest", |
|
| 252 | + | "concurrently": "^9.1.2" |
|
| 253 | + | }, |
|
| 254 | + | "peerDependencies": { |
|
| 255 | + | "typescript": "^5.0.0" |
|
| 256 | + | } |
|
| 257 | + | } |
|
| 258 | + | ``` |
|
| 259 | + | ||
| 260 | + | #### Setup Client |
|
| 261 | + | ||
| 262 | + | Setup Vite with your preferences |
|
| 263 | + | ||
| 264 | + | ```bash [terminal] |
|
| 265 | + | bun create vite@latest client |
|
| 266 | + | cd client |
|
| 267 | + | ``` |
|
| 268 | + | ||
| 269 | + | Update the `package.json` file |
|
| 270 | + | ||
| 271 | + | ```json |
|
| 272 | + | { |
|
| 273 | + | "name": "client", |
|
| 274 | + | "private": true, |
|
| 275 | + | "version": "0.0.1", |
|
| 276 | + | "type": "module", |
|
| 277 | + | "scripts": { |
|
| 278 | + | "dev": "vite", |
|
| 279 | + | "build": "tsc -b && vite build", |
|
| 280 | + | "lint": "eslint .", |
|
| 281 | + | "preview": "vite preview" |
|
| 282 | + | }, |
|
| 283 | + | "dependencies": { |
|
| 284 | + | "react": "^19.0.0", |
|
| 285 | + | "react-dom": "^19.0.0", |
|
| 286 | + | "shared": "workspace:*", // [!code focus] |
|
| 287 | + | "server": "workspace:*" // [!code focus] |
|
| 288 | + | }, |
|
| 289 | + | "devDependencies": { |
|
| 290 | + | "@eslint/js": "^9.22.0", |
|
| 291 | + | "@types/node": "^22.15.2", // [!code focus] |
|
| 292 | + | "@types/react": "^19.0.10", |
|
| 293 | + | "@types/react-dom": "^19.0.4", |
|
| 294 | + | "@vitejs/plugin-react": "^4.3.4", |
|
| 295 | + | "eslint": "^9.22.0", |
|
| 296 | + | "eslint-plugin-react-hooks": "^5.2.0", |
|
| 297 | + | "eslint-plugin-react-refresh": "^0.4.19", |
|
| 298 | + | "globals": "^16.0.0", |
|
| 299 | + | "typescript": "~5.7.2", |
|
| 300 | + | "typescript-eslint": "^8.26.1", |
|
| 301 | + | "vite": "^6.3.1" |
|
| 302 | + | } |
|
| 303 | + | } |
|
| 304 | + | ``` |
|
| 305 | + | ||
| 306 | + | Update the `tsconfig.json` file |
|
| 307 | + | ||
| 308 | + | ```json |
|
| 309 | + | { |
|
| 310 | + | "extends": "../tsconfig.json", // [!code focus] |
|
| 311 | + | "files": [], |
|
| 312 | + | "references": [{ "path": "./tsconfig.node.json" }, { "path": "./tsconfig.app.json"}] |
|
| 313 | + | } |
|
| 314 | + | ``` |
|
| 315 | + | ||
| 316 | + | Update the `vite.config.ts` file |
|
| 317 | + | ||
| 318 | + | ```typescript |
|
| 319 | + | import { defineConfig } from 'vite' |
|
| 320 | + | import react from '@vitejs/plugin-react' |
|
| 321 | + | import path from 'path' // [!code focus] |
|
| 322 | + | ||
| 323 | + | export default defineConfig({ |
|
| 324 | + | plugins: [react()], |
|
| 325 | + | resolve: { // [!code focus] |
|
| 326 | + | alias: { // [!code focus] |
|
| 327 | + | "@client": path.resolve(__dirname, "./src"), // [!code focus] |
|
| 328 | + | "@server": path.resolve(__dirname, "../server/src"), // [!code focus] |
|
| 329 | + | "@shared": path.resolve(__dirname, "../shared/src") // [!code focus] |
|
| 330 | + | } |
|
| 331 | + | } |
|
| 332 | + | }) |
|
| 333 | + | ``` |
|
| 334 | + | ||
| 335 | + | #### Setup Server |
|
| 336 | + | ||
| 337 | + | Create `server` repo with Hono |
|
| 338 | + | ||
| 339 | + | ```bash [terminal] |
|
| 340 | + | bun create hono@latest server |
|
| 341 | + | cd server |
|
| 342 | + | ``` |
|
| 343 | + | ||
| 344 | + | Update the `tsconfig.json` file |
|
| 345 | + | ||
| 346 | + | ```json |
|
| 347 | + | { |
|
| 348 | + | "extends": "../tsconfig.json", // [!code focus] |
|
| 349 | + | "compilerOptions": { |
|
| 350 | + | // Environment settings |
|
| 351 | + | "lib": ["ESNext"], |
|
| 352 | + | "target": "ESNext", |
|
| 353 | + | "module": "ESNext", |
|
| 354 | + | "jsx": "react-jsx", |
|
| 355 | + | "jsxImportSource": "hono/jsx", |
|
| 356 | + | ||
| 357 | + | // Types |
|
| 358 | + | "types": ["bun-types"], |
|
| 359 | + | ||
| 360 | + | // Output settings |
|
| 361 | + | "declaration": true, // [!code focus] |
|
| 362 | + | "outDir": "dist", // [!code focus] |
|
| 363 | + | "noEmit": false, // [!code focus] |
|
| 364 | + | "emitDecoratorMetadata": true, // [!code focus] |
|
| 365 | + | ||
| 366 | + | // Module resolution |
|
| 367 | + | "moduleResolution": "bundler", |
|
| 368 | + | "allowImportingTsExtensions": false |
|
| 369 | + | }, |
|
| 370 | + | "include": ["src/**/*"], |
|
| 371 | + | "exclude": ["node_modules", "dist"] |
|
| 372 | + | } |
|
| 373 | + | ``` |
|
| 374 | + | ||
| 375 | + | Update the `package.json` file |
|
| 376 | + | ||
| 377 | + | ```json |
|
| 378 | + | { |
|
| 379 | + | "name": "server", |
|
| 380 | + | "version": "0.0.1", |
|
| 381 | + | "main": "dist/index.js", // [!code focus] |
|
| 382 | + | "types": "dist/index.d.ts", // [!code focus] |
|
| 383 | + | "scripts": { |
|
| 384 | + | "build": "tsc", |
|
| 385 | + | "dev": "bun run --hot src/index.ts" |
|
| 386 | + | }, |
|
| 387 | + | "dependencies": { |
|
| 388 | + | "hono": "^4.7.7", |
|
| 389 | + | "shared": "workspace:*" // [!code focus] |
|
| 390 | + | }, |
|
| 391 | + | "devDependencies": { |
|
| 392 | + | "@types/bun": "latest" |
|
| 393 | + | } |
|
| 394 | + | } |
|
| 395 | + | ``` |
|
| 396 | + | ||
| 397 | + | #### Setup Shared |
|
| 398 | + | ||
| 399 | + | Initialize the directory |
|
| 400 | + | ||
| 401 | + | ```bash [terminal] |
|
| 402 | + | cd shared |
|
| 403 | + | bun init -y |
|
| 404 | + | mkdir src |
|
| 405 | + | mv index.ts src/index.ts |
|
| 406 | + | ``` |
|
| 407 | + | ||
| 408 | + | Update the `tsconfig.json` file |
|
| 409 | + | ||
| 410 | + | ```json |
|
| 411 | + | { |
|
| 412 | + | "extends": "../tsconfig.json", // [!code focus] |
|
| 413 | + | "compilerOptions": { |
|
| 414 | + | // Environment setup |
|
| 415 | + | "lib": ["ESNext"], |
|
| 416 | + | "target": "ESNext", |
|
| 417 | + | "module": "ESNext", |
|
| 418 | + | ||
| 419 | + | // Output configuration |
|
| 420 | + | "declaration": true, // [!code focus] |
|
| 421 | + | "outDir": "./dist", // [!code focus] |
|
| 422 | + | "noEmit": false, // [!code focus] |
|
| 423 | + | ||
| 424 | + | // Type checking |
|
| 425 | + | "strict": true, |
|
| 426 | + | "skipLibCheck": true, |
|
| 427 | + | ||
| 428 | + | // Additional checks |
|
| 429 | + | "noFallthroughCasesInSwitch": true, |
|
| 430 | + | "noUncheckedIndexedAccess": true |
|
| 431 | + | }, |
|
| 432 | + | "include": ["src/**/*"], // [!code focus] |
|
| 433 | + | "exclude": ["node_modules", "**/*.test.ts", "dist"] // [!code focus] |
|
| 434 | + | } |
|
| 435 | + | ``` |
|
| 436 | + | ||
| 437 | + | Update the `package.json` file |
|
| 438 | + | ||
| 439 | + | ```json |
|
| 440 | + | { |
|
| 441 | + | "name": "shared", |
|
| 442 | + | "version": "0.0.1", |
|
| 443 | + | "main": "dist/index.js", |
|
| 444 | + | "types": "dist/index.d.ts", |
|
| 445 | + | "scripts": { |
|
| 446 | + | "build": "tsc", |
|
| 447 | + | "dev": "tsc --watch" |
|
| 448 | + | }, |
|
| 449 | + | "devDependencies": { |
|
| 450 | + | "typescript": "^5.2.2" |
|
| 451 | + | } |
|
| 452 | + | } |
|
| 453 | + | ``` |
|
| 454 | + | ||
| 455 | + | #### Start Up bhvr 🦫 |
|
| 456 | + | ||
| 457 | + | ```bash [terminal] |
|
| 458 | + | bun install |
|
| 459 | + | bun dev |
|
| 460 | + | ``` |
|
| 461 | + | ||
| 462 | + | :::: |
|