# Development
bun dev # Start dev server with hot reload
bun build # Production build
bun preview # Preview production build
# Code Quality
bun check # Run Biome linter (auto-fixes with --write)
bun pretty # Run Prettier formatter (auto-fixes)
bun format # Custom format script
# Utilities
bun i18n:gen # Generate i18n translations
bun assets:gen # Generate assetsNo test framework is currently configured in this project.
- Use
@/*path alias for internal imports (configured in tsconfig.json) - External imports first, then internal imports
- Use
import typefor type-only imports
import { useState } from 'react';
import { useListTodos } from '@/services/hooks/todo/use-list-todos';
import type { TodoDto } from '@/types/dto/todo.dto';- Spaces for indentation (Biome configured)
- Single quotes for strings and imports
- Biome organizes imports automatically (
bun check) - Prettier for additional formatting (
bun pretty)
- Strict mode enabled
- Use
interfacefor DTOs and object shapes - Use
enumfor fixed constants - Define types before implementation
// ✅ Good
export interface TodoDto {
id: number;
title: string;
completed: boolean;
}
// ❌ Avoid
export const todoDto = { ... };- Components: PascalCase (e.g.,
RouteComponent,ToastProvider) - Files: kebab-case (e.g.,
use-list-todos.ts,todo.dto.ts) - Functions/Variables: camelCase (e.g.,
formatTime,isEnabled) - Constants: UPPER_SNAKE_CASE (e.g.,
TOKEN_STORAGE_TYPE) - Custom Hooks:
useprefix (e.g.,useToast,useListTodos) - Types/Interfaces: PascalCase, descriptive names (e.g.,
TodoDto,ToastContextType)
src/
├── helpers/ # Utilities (axios, i18n, utils, constants)
├── services/
│ ├── hooks/ # Custom React hooks (grouped by feature)
│ └── endpoints.ts # API endpoint definitions
├── types/
│ ├── dto/ # Data Transfer Objects
│ └── enums/ # Enum definitions
├── providers/ # React context providers
├── routes/ # TanStack router routes
└── locales/ # i18n translation files
- Use i18n for user-facing messages:
i18n.t('errorKey', { ns: 'exception' }) - Global error handling via axios interceptors (see
axios-instance.ts) - Throw descriptive errors in hooks:
if (!context) {
throw new Error('useToast must be used within a ToastProvider');
}- Use TanStack Router for routing with file-based routes
- Use TanStack Query for data fetching with custom hooks
- Store feature hooks in
src/services/hooks/{feature}/ - Export
Routecomponent from route files:
export const Route = createFileRoute('/')({
component: RouteComponent,
});- TanStack Router plugin configured in
rsbuild.config.tsfor file-based routing - Route tree auto-generated to
src/route-tree.gen.ts - Route files with
~prefix are ignored (e.g.,~shared, ~video-card.tsx) - Auto code splitting enabled for performance
- Server base path configured via
envConfig.base - All routes defined in
src/routes/with pattern*.tsx - Route generation happens automatically when running
bun devorbun build- no separate command needed
- Layouts use
_route.tsxsuffix (e.g.,/home/_route.tsxfor home layout) - Layout components export an
<Outlet />to render child routes (similar to Next.js_layout.tsx):
// src/routes/home/_route.tsx (layout)
import { createFileRoute, Outlet } from '@tanstack/react-router';
export const Route = createFileRoute('/home/_route')({
component: HomeLayout,
});
function HomeLayout() {
return (
<div>
<header>Home Layout</header>
<Outlet /> {/* Child routes render here */}
</div>
);
}// src/routes/home/index.tsx (child route)
import { createFileRoute } from '@tanstack/react-router';
export const Route = createFileRoute('/home/')({
component: HomeComponent,
});- Environment vars in
.env(see.env.example) - Config object via
envConfigfrom@/helpers/constants/env-config - Never commit secrets or actual
.envfiles
- Run
bun checkto fix linting issues - Run
bun prettyto format code - Verify build with
bun build - Commits only when explicitly requested
- Build: Rsbuild, Bun, TypeScript
- Styling: Tailwind CSS
- Routing: @tanstack/react-router
- Data: @tanstack/react-query, axios
- UI: shadcn/ui
- Internationalization: react-i18next
- Linting: Biome, Prettier
- CodeStructure: param camelCase, file name kebeb-case, module based all place inside /routes (example: /user/~components, /user/index.tsx, ...) types, enums, dto of that module also place inside that module