- ✅ Next.js 15 with App Router
- ✅ TypeScript configuration
- ✅ Tailwind CSS for styling
- ✅ Radix UI components
- ✅ Authentication flow (Phone OTP)
- ✅ State management with Zustand
- ✅ API integration patterns (SWR for GET, fetch for POST)
- ✅ Sidebar navigation
- ✅ Responsive layout
- ✅ Material Icons support
frontend/
├── app/
│ ├── (main)/ # Authenticated routes
│ │ ├── components/ # Shared components (Sidebar, etc.)
│ │ ├── api.ts # API helper functions (POST requests)
│ │ ├── store.ts # Zustand state management
│ │ ├── layout.tsx # Main layout with sidebar
│ │ └── page.tsx # Home page
│ ├── (public)/ # Public routes (login, etc.)
│ │ ├── component/ # Login components
│ │ ├── login/ # Login page
│ │ ├── api.ts # Auth API functions
│ │ └── layout.tsx # Public layout
│ ├── components/ # Global components
│ │ └── ui/ # UI components (MaterialIcon, Select)
│ ├── globals.css # Global styles
│ └── favicon.ico
├── docs/ # Documentation
│ ├── backend-api-format.md
│ ├── component-usage.md
│ ├── state-and-data.md
│ └── style-guide.md
├── public/ # Static assets
├── package.json
├── tsconfig.json
├── tailwind.config.ts
└── next.config.mjs
-
Install Dependencies
npm install
-
Configure Environment Variables Create a
.env.localfile (or copyenv.template):NEXT_PUBLIC_API_BASE_URL=http://localhost:3000
-
Run Development Server
npm run dev
-
Build for Production
npm run build npm start
import useSWR from 'swr';
function MyComponent() {
const { data, error, isLoading } = useSWR('/api/endpoint');
if (isLoading) return <div>Loading...</div>;
if (error) return <div>Error loading data</div>;
return <div>{data}</div>;
}The SWR fetcher is configured in app/(main)/layout.tsx and automatically:
- Adds authentication headers
- Handles 401 redirects
- Manages error states
import { examplePostRequest } from './api';
async function handleSubmit(data: any) {
try {
const response = await examplePostRequest(data);
console.log('Success:', response);
} catch (error) {
console.error('Error:', error);
}
}Use Zustand for global state:
import { useDashboardStore } from './store';
function MyComponent() {
const { user, setUser } = useDashboardStore();
return <div>Welcome, {user.name}</div>;
}- Use Tailwind utility classes for styling
- Global CSS variables are defined in
globals.css - Follow the no-scrollbar pattern for custom scrollable areas
Add new menu items in Sidebar.tsx:
const menuItems = [
{ id: 'home', label: 'Home', route: '/', icon: 'home' },
{ id: 'settings', label: 'Settings', route: '/settings', icon: 'settings' },
// Add more items here
];- User enters phone number on
/login - OTP is sent via SMS
- User verifies OTP
- Token is stored in localStorage
- User is redirected to dashboard
To customize the authentication flow, modify:
app/(public)/component/Signin.tsx- Login UIapp/(public)/api.ts- Auth API callsapp/(main)/layout.tsx- Auth guards
Detailed documentation is available in the docs/ folder:
- backend-api-format.md - Expected API data formats
- component-usage.md - How to use components
- state-and-data.md - State management and data flow
- style-guide.md - Styling conventions
- Update title in
app/(main)/layout.tsx - Update logo in
app/(main)/components/Sidebar.tsx - Replace favicon.ico
- Create folder under
app/(main)/ - Add
page.tsxfile - Add route to sidebar menu items
- Update Tailwind config in
tailwind.config.ts - Modify CSS variables in
globals.css - Customize Radix UI theme in layout files
npm run dev- Start development servernpm run build- Build for productionnpm start- Start production servernpm run lint- Run ESLint
- Framework: Next.js 15
- Language: TypeScript
- Styling: Tailwind CSS 4
- UI Components: Radix UI
- State Management: Zustand
- Data Fetching: SWR
- Icons: Material Icons
This template is provided as-is for creating new projects.