bansimplified-react-boilerplate/
│
├─ public/ # Static files
│ └── vite.svg # Vite logo/placeholder image
├─ src/ # Source code
│ ├─ App.tsx # Main App component
│ ├─ index.css # Global CSS styles (includes Tailwind directives)
│ ├─ main.tsx # Application entry point (renders React to DOM)
│ ├─ assets/ # Static assets (images, icons, fonts)
│ │ └── react.svg
│ ├─ components/ # Reusable UI components (Button, Card, Modal, etc.)
│ │ ├─ layout/
│ │ │ └── LoadingPage.tsx
│ │ └─ ui/
│ ├─ contexts/ # React contexts for state management
│ │ └── TanstackProvider.tsx # TanStack Query provider
│ ├─ hooks/ # Custom React hooks
│ │ ├─ use-mobile.ts
│ │ ├─ useLogout.tsx
│ ├─ lib/ # Library utilities and configurations
│ │ ├─ socket.ts
│ │ ├─ supabase.ts # Supabase client configuration
│ │ └─ supebase.ts # (Possible duplicate/typo of supabase.ts)
│ ├─ middleware/ # Middleware for routing and auth
│ │ └── authMiddleware.ts
│ ├─ pages/ # Page components for routing (using TanStack React Router with file-based routing)
│ │ ├─ NotFound.tsx
│ │ ├─ (auth)/ # Auth-related pages
│ │ ├─ (dashboard)/ # Dashboard pages
│ │ ├─ (information)/ # Information pages (corrected from 'infromation')
│ │ └─ (root)/ # Root pages
│ ├─ routes/ # Routing configuration (TanStack React Router)
│ │ ├─ _root.tsx
│ │ └─ routers/
│ │ ├─ dash.routes.ts
│ │ └─ root.route.ts
│ ├─ styles/ # Application styling
│ ├─ types/ # Global TypeScript type definitions
│ │ ├─ app/
│ │ │ └── auth.type.ts
│ │ └─ lib-defs/
│ │ └── env.d.ts
│ └─ utils/ # General utility functions (helpers, formatters)
│ ├─ redirect.ts
│ └─ utils.ts
├─ .gitignore # Git ignore rules
├─ components.json # UI component registry (for shadcn/ui)
├─ eslint.config.js # ESLint configuration
├─ index.html # HTML entry point
├─ package-lock.json # NPM dependency lock file
├─ package.json # Project dependencies and scripts
├─ postcss.config.js # PostCSS configuration (processes Tailwind CSS)
├─ tailwind.config.js # Tailwind CSS configuration
├─ tsconfig.app.json # TypeScript config for application code
├─ tsconfig.json # Main TypeScript configuration
├─ tsconfig.node.json # TypeScript config for Node/bundler code
└── vite.config.ts # Vite build tool configurationHere's a breakdown of what each folder in the project is for:
-
public/: This directory contains static assets that are not processed by the build tool. Files here are served at the root path. It's suitable for assets likerobots.txtor web manifest files. -
src/: This is where all your application's source code lives.-
App.tsx: Main application component that sets up providers and routing. -
assets/: For static assets like images, icons, and fonts that you import directly into your components. These assets are processed and bundled by Vite. -
components/: Holds reusable UI components (e.g.,Button,Card,Modalfrom shadcn/ui). Subfolders includelayout/for layout components likeLoadingPage.tsxandui/for primitive UI elements. -
contexts/: React contexts for global state management, includingTanstackProvider.tsxfor TanStack Query (React Query). -
hooks/: Custom React hooks for logic reuse, includinguse-mobile.tsfor mobile detection,useLogout.tsxfor logout functionality. -
lib/: Library initializations and utilities, includingsupabase.tsfor Supabase client configuration andsocket.tsfor socket connections. -
middleware/: Middleware for routing and authentication, such asauthMiddleware.ts. -
pages/: Contains the main page components for your application using TanStack React Router with file-based routing. Subfolders like(auth)/,(dashboard)/,(information)/,(root)/group related pages. -
routes/: Routing configuration using TanStack React Router, including_root.tsxand subfolderrouters/withdash.routes.tsandroot.route.ts. -
styles/: Centralized application styling files. -
types/: Global TypeScript type definitions, includingapp/auth.type.tsfor auth types andlib-defs/env.d.tsfor environment types. -
utils/: General utility functions, such asredirect.tsfor navigation helpers andutils.tsfor general helpers.
-
This project is built using the following technologies (versions from package.json):
- Frontend Framework: React (v19.2.0) with TypeScript (TSX files)
- Build Tool: Vite (v7.2.4)
- Styling: Tailwind CSS (v3.4.18) with PostCSS and Autoprefixer
- Routing: TanStack React Router (v1.140.1) with file-based routing (react-router-dom v7.10.1 as fallback/secondary)
- Data Management: TanStack Query (v5.90.12) for server-state management and caching
- Backend & Authentication: Supabase (@supabase/supabase-js v2.86.2)
- Real-time: Socket.io-client (v4.8.1)
- HTTP Client: Axios (v1.13.2)
- Icons: Lucide React (v0.555.0)
- UI Components: shadcn/ui (based on components.json)
- Utilities: clsx (v2.1.1), tailwind-merge (v3.4.0), class-variance-authority (v0.7.1), tailwindcss-animate (v1.0.7)
- Development Tools: ESLint (v9.39.1), TypeScript (v5.9.3), PostCSS (v8.5.6), @tailwindcss/vite (v4.1.17)
-
Clone the Repository Run the following command to download the project code to your local machine:
git clone https://github.com/BanSimplified567/bansimplified-react-boilerplate.git
Replace the URL with your actual Git repository if different.
-
Navigate to the Project Directory
cd bansimplified-react-boilerplate -
Install Dependencies
npm install
This will install all required Node.js packages listed in
package.json. -
Verify Supabase Connection File The file
src/lib/supabase.tsshould exist with content to set up the Supabase client (update if needed):import { createClient } from '@supabase/supabase-js'; // Pull Supabase credentials from environment variables const supabaseUrl = import.meta.env.VITE_SUPABASE_URL; const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY; // Create the Supabase client export const supabase = createClient(supabaseUrl, supabaseAnonKey);
-
Create Environment Variables Example File Create a
.env.examplefile in the root directory (if not present) with placeholder values for Supabase and Google OAuth configuration:VITE_SUPABASE_URL=your_supabase_project_url_here VITE_SUPABASE_ANON_KEY=your_supabase_anon_key_here VITE_GOOGLE_CLIENT_ID=your_google_client_id_here VITE_GOOGLE_CLIENT_SECRET=your_google_client_secret_here VITE_GITHUB_CLIENT_ID=your_github_client_id_here VITE_GITHUB_CLIENT_SECRET=your_github_client_secret_here
-
Set Up Environment Variables Copy
.env.exampleto.env(create if needed) and fill in your actual keys:copy .env.example .env
(Use
copyon Windows; adjust for your OS.) -
Set Up Google OAuth To integrate Google OAuth with Supabase:
a. In Google Cloud Console:
- Go to Google Cloud Console.
- Create a new project or select an existing one.
- Enable the Google+ API (or relevant APIs) if needed.
- Navigate to APIs & Services > Credentials.
- Configure the OAuth consent screen (app name, user support email, developer contact).
- Click Create Credentials > OAuth 2.0 Client ID.
- Select Web application.
- Add Authorized JavaScript origins (e.g.,
http://localhost:5173for dev). - Add Authorized redirect URIs using your Supabase project's auth callback:
https://<your-project-ref>.supabase.co/auth/v1/callback. - Note the generated Client ID and Client Secret (generate secret if not provided).
b. In Supabase Dashboard:
- Go to your Supabase project dashboard.
- Navigate to Authentication > Providers.
- Enable Google provider.
- Paste the Client ID and Client Secret from Google.
- Save changes.
c. Update .env: Add to your
.envfile:VITE_GOOGLE_CLIENT_ID=your_generated_client_id VITE_GOOGLE_CLIENT_SECRET=your_generated_client_secret
-
Set Up GitHub OAuth To integrate GitHub OAuth with Supabase:
a. In GitHub Developer Settings:
- Go to GitHub Settings.
- Navigate to Developer settings > OAuth Apps.
- Click New OAuth App.
- Provide Application name (e.g., your app name).
- Set Homepage URL (e.g.,
http://localhost:5173for dev). - Set Authorization callback URL to your Supabase project's auth callback:
https://<your-project-ref>.supabase.co/auth/v1/callback. - Click Register application.
- Copy the Client ID and generate/click Generate a new client secret to get the Client Secret.
b. In Supabase Dashboard:
- Go to your Supabase project dashboard.
- Navigate to Authentication > Providers.
- Enable GitHub provider.
- Paste the Client ID and Client Secret from GitHub.
- Save changes.
c. Update .env: Add to your
.envfile:VITE_GITHUB_CLIENT_ID=your_generated_client_id VITE_GITHUB_CLIENT_SECRET=your_generated_client_secret
-
Test the Setup Run the development server:
npm run dev
Open http://localhost:5173 (default Vite port). Verify Supabase connection, TanStack Query setup in contexts, routing with TanStack React Router, Google and GitHub OAuth by testing login flows, checking browser console for errors, and ensuring redirects/auth middleware work with the Supabase callback.