An opinionated React starter kit for rapid frontend development. Built with TypeScript, Vite, and a modern stack, this starter provides authentication, routing, state management, and seamless backend integration out of the box.
Live Demo | Backend Counterpart
- React 18 - UI library
- TypeScript 5 - Type safety
- Vite 5 - Fast build tool with SWC
- Redux Toolkit 2 - State management
- Ant Design 5 - Component library
- Tailwind CSS 3 - Utility-first CSS
- React JSS - CSS-in-JS for dynamic styling
- Lucide - Icon library
- OpenAPI Fetch - Type-safe API client from OpenAPI schemas
- Axios - HTTP client (fetch implementation)
- React Router 6 - Client-side routing
- ahooks - React hooks library
- Firebase - Firestore (ex: real-time background job status), Storage, Cloud Messaging
- hCaptcha - Bot protection
- i18next - i18n framework with multi-language support (English, Urdu)
- JWT Authentication - Access/refresh token flow with automatic token refresh
- Role-Based Access Control (RBAC) - Route-level permission checks
- Firebase Integration - Firestore for real-time updates (e.g., background job status), Storage, Cloud Messaging
- hCaptcha Protection - Bot prevention on public routes
- Config-based Routing - Declarative route definitions with automatic menu generation
- Per-route Layouts - Empty, Auth, and Dashboard layouts
- Nested Routes - Support for parent/child/grandchild routes
- Protected Routes - Public/private route configuration
- Dark/Light Mode - System-aware theme switching with Tailwind integration
- i18n Support - Multi-language with RTL support (English, Urdu)
- Ant Design Components - Pre-configured with custom theming
- Responsive Layouts - Mobile-first design patterns
- Redux Toolkit - Slices, thunks, and async state handling
- OpenAPI Type Generation - Automatic type-safe API client from backend schema
- Server-side Pagination - Built-in
ServerPaginatedTablecomponent - Global Error Handling - Centralized error management with automatic token refresh on 401
- Three Environments - Separate dev, test, and production configs
- Automatic Loading States - Built-in loading management for async operations
- Feature-based Structure - Clean separation between lib (shared) and modules (features)
- Code Quality Tools - ESLint, Prettier, and Husky pre-commit hooks
- CI/CD Pipeline - Automated deployment to Firebase Hosting via GitHub Actions
- Node.js 20+ and npm 10+
- Backend running - This starter requires rayon_gcp_express_psql_starter running locally or deployed
-
Clone the repository:
git clone https://github.com/rayonstudios/rayon_react_starter cd rayon_react_starter -
Install dependencies:
npm install
-
Configure environment (optional):
By default,
.env.developmentpoints tohttp://localhost:3000/api/v1. Update if your backend runs elsewhere. -
Start development server:
npm run dev
The app will be available at http://localhost:5173 with hot module replacement enabled.
npm run dev # Start dev server (uses .env.development)
npm run test # Start test server (uses .env.test)
npm run prod # Start prod server (uses .env.production)npm run build:dev # Build for development
npm run build:test # Build for test environment
npm run build:prod # Build for productionnpm run gen-types:dev # Generate types from dev backend OpenAPI schema
npm run gen-types:test # Generate types from test backend
npm run gen-types:prod # Generate types from prod backendnpm run lint # Run ESLint
npm run preview # Preview production build locallyThree environment files are included:
| File | Backend URL | Purpose |
|---|---|---|
.env.development |
https://rayon-gcp-express-psql-starter-dev-*.run.app/api/v1 |
Development environment (can be changed to localhost:3000 for local backend) |
.env.test |
https://rayon-gcp-express-psql-starter-test-*.run.app/api/v1 |
Testing environment for QA |
.env.production |
https://be.starters.rayonstudios.com/api |
Production environment |
VITE_API_BASE_URL=http://localhost:3000/api/v1 # Backend API URL
VITE_ENV=dev # Environment identifier
VITE_HCAPTCHA_SITE_KEY=your-site-key # hCaptcha site key
VITE_FIREBASE_AUTH_ENABLED=true # Enable/disable Firebase features
VITE_FIREBASE_API_KEY=your-firebase-api-key # Firebase API key (required in .env.local)Important: Create a .env.local file (gitignored) with your VITE_FIREBASE_API_KEY to access Firebase services. This key is consumed by src/lib/firebase/firebase.service.ts and is required for Firestore, and Cloud Messaging functionality.
Example .env.local:
VITE_FIREBASE_API_KEY=AIzaSyC...your-actual-keyThis starter is designed to work with rayon_gcp_express_psql_starter backend.
The starter automatically generates TypeScript types from the backend's OpenAPI schema:
- Backend exposes schema at
/api/v1/openapi.json - Script fetches schema from
VITE_API_BASE_URL - Types are generated in
src/lib/types/openapi-fetch.d.ts - API client is fully typed for all backend endpoints
Run type generation manually:
npm run gen-types:dev # Fetch schema from dev backend
npm run gen-types:test # Fetch schema from test backend
npm run gen-types:prod # Fetch schema from prod backendNote: Type generation runs automatically when starting dev servers (npm run dev, etc.).
Use the pre-configured openapi-fetch client for type-safe API calls:
import apiClient, { withApiResponseHandling } from "@/lib/openapi-fetch.config";
// Type-safe API call with automatic error handling
const { data } = await withApiResponseHandling(
apiClient.GET("/users/{id}", {
params: { path: { id: userId } },
})
);Features:
- Full TypeScript type inference for request/response
- Automatic token refresh on 401 errors
- Global error handling for 403 (permission errors)
- Request/response interceptors
rayon_react_starter/
├── .github/workflows/ # CI/CD pipelines (Firebase deployment)
├── .husky/ # Git hooks (pre-commit)
├── public/ # Static assets
├── scripts/ # Build scripts (OpenAPI type generation)
├── src/
│ ├── lib/ # Shared, reusable code
│ │ ├── components/ # Shared UI components
│ │ ├── contexts/ # React contexts (theme, language)
│ │ ├── firebase/ # Firebase configuration
│ │ ├── hooks/ # Custom React hooks
│ │ ├── layouts/ # Layout components (auth, dashboard, empty)
│ │ ├── redux/ # Redux store, slices, middleware
│ │ ├── router/ # Routing configuration
│ │ ├── styles/ # Global styles
│ │ ├── translations/ # i18n translation files
│ │ ├── types/ # TypeScript type definitions
│ │ └── utils/ # Utility functions
│ ├── modules/ # Feature-specific code
│ │ ├── auth/ # Authentication module
│ │ ├── file/ # File management
│ │ ├── posts/ # Posts module
│ │ └── user/ # User management
│ └── pages/ # Page components
│ ├── 404/
│ ├── auth/ # Login, forgot password, reset password
│ ├── posts/
│ ├── settings/
│ └── users/
├── .env.development # Dev environment variables
├── .env.test # Test environment variables
├── .env.production # Prod environment variables
├── firebase.json # Firebase Hosting config
├── tailwind.config.js # Tailwind CSS config
├── tsconfig.json # TypeScript config
└── vite.config.ts # Vite build config
lib/- Reusable, feature-independent codemodules/- Feature-specific code organized by domainpages/- Page components that compose modules and lib components- snake_case - Used for file and folder names
Advanced table component with built-in server-side operations:
import ServerPaginatedTable from '@/lib/components/server-paginated-table/server-paginated-table';
<ServerPaginatedTable
url="/users" // API endpoint
columns={columns} // Column definitions
filters={[ // Optional filter configurations
{
label: "Status",
type: "select",
key: "status",
filterProps: {
options: [
{ label: "Active", value: "active" },
{ label: "Inactive", value: "inactive" }
]
}
}
]}
/>Features:
- Server-side pagination, sorting, and filtering
- URL state management (filters persist in URL)
- Automatic loading and error states
- Ant Design Table integration
- ServerPaginatedSelect - Lazy-loaded select with server-side search
- FilePicker / ImagePicker - File upload with preview
- ServerImg - Optimized image loading with fallback
- AlertPopup - Confirmation dialogs
- ErrorBoundary - React error boundaries
- PageSpinner - Loading states
The project deploys to Firebase Hosting with three targets:
| Branch | Target | URL |
|---|---|---|
main |
prod |
https://fe.starters.rayonstudios.com |
dev |
dev |
Firebase preview URL |
test |
test |
Firebase preview URL |
Deployments are triggered automatically via GitHub Actions on push to main, dev, or test branches.
Workflow:
- Install dependencies
- Generate types from backend OpenAPI schema
- Build for the target environment
- Deploy to Firebase Hosting
Note: Manual deployments are not recommended. Use the CI/CD pipeline by pushing to the appropriate branch.
- Shared code →
lib/folder - Feature-specific code →
modules/folder - Page components →
pages/folder - Use snake_case for file and folder names
- Type generation runs automatically with
npm run dev- no need to run manually - Use Redux Toolkit for state management
- Leverage OpenAPI Fetch for type-safe API calls
- Use
ServerPaginatedTablefor data tables - No need for try-catch in services unless handling specific errors - global error handler is in place
- Define routes in
src/lib/router/router-config.tsx - Specify layout type (
empty,auth,dashboard) - Configure auth requirements (
public,private,none) - Set allowed roles for RBAC
-
Automatic Loading States: The project uses a status enhancer that automatically tracks loading states for all async thunks
-
Use
useIsLoadinghook: Listen to thunk loading states without manual state managementimport { useIsLoading } from "@/lib/redux/enhancers/status.enhancer"; // Automatically tracks loading state of 'fetchUsers' thunk in 'user' slice const isLoading = useIsLoading("user", "fetchUsers");
-
No manual status management needed: The enhancer automatically sets
{thunkName}Statusfield toLOADING,IDLE, orFAILED -
Works across all slices: Any thunk in any slice gets automatic loading state tracking
- E2E test support
- Analytics and error reporting integration
- Convert to CLI-based scaffolding tool
We welcome contributions! Whether it's bug fixes, new features, or documentation improvements, your help is appreciated.
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name - Make your changes following the code style guidelines
- Test thoroughly
- Commit with clear messages:
git commit -m "feat: add dark mode toggle" - Push to your fork:
git push origin feature/your-feature-name - Open a Pull Request
- Follow the existing code style (snake_case for files, ESLint/Prettier configs)
- Update documentation for user-facing changes
- Test changes in at least the dev environment
This project is licensed under the MIT License. See the LICENSE file for details.
Built by Rayon Studios. If this starter helped you ship faster, consider giving it a ⭐ on GitHub!