Next.js Version โ
HaloLight Next.js version is built on Next.js 14 App Router with React 18 + TypeScript.
Live Preview: https://halolight.h7ml.cn/
GitHub: https://github.com/halolight/halolight
Tech Stack โ
| Technology | Version | Description |
|---|---|---|
| Next.js | 14.x | React full-stack framework (App Router) |
| React | 18.x | UI library |
| TypeScript | 5.x | Type safety |
| Tailwind CSS | 4.x | Atomic CSS |
| shadcn/ui | latest | UI component library (28 components) |
| Zustand | 5.x | State management (6 Stores) |
| TanStack Query | 5.x | Server state |
| React Hook Form | 7.x | Form handling |
| Zod | 4.x | Data validation |
| react-grid-layout | 1.x | Drag-and-drop layout |
| Recharts | 3.x | Chart visualization |
| Framer Motion | 12.x | Animation effects |
| Mock.js | 1.x | Data mocking |
| next-pwa | 5.x | PWA support |
Directory Structure โ
halolight/
โโโ src/
โ โโโ app/ # App Router pages
โ โ โโโ (auth)/ # Auth route group
โ โ โ โโโ login/ # Login
โ โ โ โโโ register/ # Register
โ โ โ โโโ forgot-password/ # Forgot password
โ โ โ โโโ reset-password/ # Reset password
โ โ โ โโโ layout.tsx # Auth layout
โ โ โโโ (dashboard)/ # Dashboard route group
โ โ โ โโโ page.tsx # Dashboard home (configurable)
โ โ โ โโโ accounts/ # Account & permissions
โ โ โ โโโ analytics/ # Analytics
โ โ โ โโโ calendar/ # Calendar
โ โ โ โโโ docs/ # Help docs
โ โ โ โโโ documents/ # Document management
โ โ โ โโโ files/ # File storage
โ โ โ โโโ messages/ # Message center
โ โ โ โโโ notifications/ # Notification center
โ โ โ โโโ profile/ # User profile
โ โ โ โโโ users/ # User management
โ โ โ โโโ settings/ # System settings
โ โ โ โ โโโ teams/ # Team management
โ โ โ โ โโโ roles/ # Role management
โ โ โ โโโ layout.tsx # Dashboard layout
โ โ โโโ (legal)/ # Legal route group
โ โ โ โโโ privacy/ # Privacy policy
โ โ โ โโโ terms/ # Terms of service
โ โ โ โโโ layout.tsx
โ โ โโโ layout.tsx # Root layout
โ โ โโโ error.tsx # Error page
โ โ โโโ not-found.tsx # 404 page
โ โโโ components/
โ โ โโโ ui/ # shadcn/ui components (28)
โ โ โโโ layout/ # Layout components (11)
โ โ โ โโโ admin-layout.tsx # Admin layout
โ โ โ โโโ sidebar.tsx # Collapsible sidebar
โ โ โ โโโ header.tsx # Header (notifications/errors/user menu)
โ โ โ โโโ footer.tsx # Footer
โ โ โ โโโ tab-bar.tsx # Multi-tab navigation
โ โ โ โโโ command-menu.tsx # Command palette (โK)
โ โ โ โโโ quick-settings.tsx # UI settings panel
โ โ โ โโโ theme-toggle.tsx # Theme toggle
โ โ โ โโโ pending-overlay.tsx # Loading overlay
โ โ โโโ dashboard/ # Dashboard components
โ โ โ โโโ configurable-dashboard.tsx # Configurable dashboard
โ โ โ โโโ charts.tsx # Chart components
โ โ โ โโโ stats-card.tsx # Stats card
โ โ โ โโโ recent-activity.tsx # Recent activity
โ โ โโโ shared/ # Shared components
โ โโโ hooks/ # React Hooks (15)
โ โ โโโ use-users.ts # User CRUD
โ โ โโโ use-teams.ts # Team management
โ โ โโโ use-messages.ts # Message management
โ โ โโโ use-notifications.ts # Notification management
โ โ โโโ use-calendar.ts # Calendar data
โ โ โโโ use-documents.ts # Document management
โ โ โโโ use-files.ts # File management
โ โ โโโ use-dashboard.ts # Dashboard state
โ โ โโโ use-dashboard-data.ts # Dashboard data Hook collection
โ โ โโโ use-chart-palette.ts # Chart palette (theme-aware)
โ โ โโโ use-action-mutation.ts # Server Action wrapper
โ โ โโโ use-keep-alive.tsx # Page state caching
โ โ โโโ use-tdk.ts # TDK management
โ โ โโโ use-title.ts # Page title
โ โโโ stores/ # Zustand Stores (6)
โ โ โโโ auth-store.ts # Auth state (with multi-account)
โ โ โโโ ui-settings-store.ts # UI settings
โ โ โโโ dashboard-store.ts # Dashboard state
โ โ โโโ navigation-store.ts # Navigation state
โ โ โโโ tabs-store.ts # Tab state
โ โ โโโ error-store.ts # Error collection
โ โโโ providers/ # React Providers (8)
โ โ โโโ app-providers.tsx # Provider aggregation
โ โ โโโ auth-provider.tsx # Auth Provider
โ โ โโโ theme-provider.tsx # Theme Provider
โ โ โโโ query-provider.tsx # TanStack Query
โ โ โโโ error-provider.tsx # Error handling
โ โ โโโ permission-provider.tsx # Permission check
โ โ โโโ websocket-provider.tsx # WebSocket real-time notifications
โ โ โโโ keep-alive-provider.tsx # Page keep-alive
โ โโโ actions/ # Server Actions
โ โโโ config/ # Configuration
โ โ โโโ routes.ts # Routes & permissions config
โ โ โโโ tdk.ts # TDK config
โ โโโ lib/ # Utility library
โ โ โโโ api/ # API client
โ โโโ mock/ # Mock data (9 modules)
โ โโโ middleware.ts # Middleware (auth + security headers)
โโโ public/
โ โโโ manifest.json # PWA manifest
โ โโโ sw.js # Service Worker
โ โโโ icons/ # PWA icons (8 sizes)
โ โโโ screenshots/ # PWA screenshots
โ โโโ fonts/ # Self-hosted fonts
โโโ next.config.mjs # Next.js + PWA config
โโโ tailwind.config.js
โโโ tsconfig.json
โโโ package.jsonQuick Start โ
Installation โ
git clone https://github.com/halolight/halolight.git
cd halolight
pnpm installEnvironment Variables โ
cp .env.example .env.local# .env.local example
NEXT_PUBLIC_API_URL=/api
NEXT_PUBLIC_MOCK=true # Enable Mock data
NEXT_PUBLIC_DEMO_EMAIL=admin@halolight.h7ml.cn
NEXT_PUBLIC_DEMO_PASSWORD=123456
NEXT_PUBLIC_SHOW_DEMO_HINT=false
NEXT_PUBLIC_WS_URL= # WebSocket URL
NEXT_PUBLIC_APP_TITLE=Admin Pro
NEXT_PUBLIC_BRAND_NAME=HalolightStart Development โ
pnpm devVisit http://localhost:3000
Build for Production โ
pnpm build
pnpm startCore Features โ
1. Configurable Dashboard โ
Supports 9 widget types with drag-and-drop, resize, add and remove capabilities:
| Widget Type | Description | Data Source |
|---|---|---|
stats | Statistics card (4 metrics) | useDashboardStats |
chart-line | Line chart (visit trends) | useDashboardVisits |
chart-bar | Bar chart (sales statistics) | useDashboardSales |
chart-pie | Pie chart (traffic distribution) | useDashboardPie |
recent-users | Recent users list | useDashboardUsers |
notifications | Notifications list | useDashboardNotifications |
tasks | Todo tasks | useDashboardTasks |
calendar | Today's schedule | useDashboardCalendar |
quick-actions | Quick action shortcuts | Static config |
// Dashboard edit mode
const { isEditing, setIsEditing, addWidget, removeWidget, resetToDefault } = useDashboardStore()
// Responsive layout (columns auto-adapt)
// lg: 12 cols, md: 8 cols, sm: 4 cols, xs: 2 cols, mobile: 1 col2. Multi-Account Authentication System โ
// stores/auth-store.ts
interface AuthState {
user: AccountWithToken | null
accounts: AccountWithToken[] // Multi-account list
activeAccountId: string | null // Current account
login: (data: LoginRequest) => Promise<void>
register: (data: RegisterRequest) => Promise<void>
logout: () => Promise<void>
switchAccount: (accountId: string) => Promise<void> // Quick account switch
forgotPassword: (email: string) => Promise<void>
resetPassword: (token: string, password: string) => Promise<void>
checkAuth: () => Promise<void>
}
// Cookie-based token storage with "Remember me" support (7 days / 1 day)
Cookies.set("token", response.token, {
expires: data.remember ? 7 : 1,
secure: process.env.NODE_ENV === "production",
sameSite: "strict",
})3. Multi-Tab Navigation โ
// stores/tabs-store.ts
interface Tab {
id: string
title: string
path: string
icon?: string
closable?: boolean // Home tab not closable
}
// Context menu features
- Refresh page
- Close tab
- Close others
- Close right tabs
- Close all4. Page State Caching (Keep-Alive) โ
// hooks/use-keep-alive.tsx
// Auto save/restore scroll position
useScrollRestore()
// Save form state
const [values, saveValues, clearCache] = useFormCache('filter-form', initialValues)
// Save custom state
const [state, setState] = useStateCache('my-key', initialValue)5. Command Palette (โK) โ
Supports keyboard quick navigation, theme switching, account switching, logout and more.
6. UI Settings Panel โ
// Theme mode
setTheme('light' | 'dark' | 'system')
// Skin switching (with View Transitions animation)
setSkin(skinPreset)
// Layout controls
setShowFooter(boolean) // Show/hide footer
setShowTabBar(boolean) // Show/hide tab bar
setMobileHeaderFixed(boolean) // Fixed header on mobile
setMobileTabBarFixed(boolean) // Fixed tab bar on mobile7. Real-time Notifications (WebSocket) โ
// providers/websocket-provider.tsx
const { status, lastMessage, sendMessage, reconnect } = useWebSocket()
// Listen for new notifications
useRealtimeNotifications((notification) => {
console.log('New notification:', notification)
})8. Permission System โ
// Route permission config
export const ROUTE_PERMISSIONS: Record<string, Permission> = {
"/": "dashboard:view",
"/users": "users:view",
"/analytics": "analytics:view",
// ...
}
// Permission check
const { hasPermission } = usePermission()
if (hasPermission("users:delete")) {
// Show delete button
}
// Permission guard component
<PermissionGuard permission="users:delete" fallback={<Disabled />}>
<DeleteButton />
</PermissionGuard>Skin Presets โ
Supports 11 skin presets with live preview and smooth transition animations:
| Preset | Name | Description |
|---|---|---|
default | Shadcn ยท Neutral | Official default neutral colors |
blue | Shadcn ยท Blue | Blue primary + cool-toned charts |
emerald | Shadcn ยท Emerald | Fresh green, ideal for data display |
amber | Shadcn ยท Amber | Amber/orange, warm and vibrant |
violet | Shadcn ยท Violet | High-saturation purple, tech feel |
rose | Shadcn ยท Rose | Rose primary, contrasting charts |
teal | Shadcn ยท Teal | Teal primary, modern feel |
slate | Shadcn ยท Slate | Low-saturation gray-blue, utilitarian |
ocean | Legacy ยท Ocean Blue | Blue-green gradient |
sunset | Legacy ยท Sunset Orange | Orange-pink contrast |
aurora | Legacy ยท Aurora Green | Cyan-green + purple |
UI Components โ
Based on shadcn/ui, 28 components integrated:
- Forms: Button, Input, InputClear, Textarea, Select, Checkbox, Switch, Label
- Data Display: Table, Card, Badge, Avatar, Skeleton
- Feedback: Dialog, Sheet, AlertDialog, Tooltip, Popover
- Navigation: Tabs, DropdownMenu, ContextMenu, Command, ScrollArea
- Layout: Separator
- Enhanced: BackToTop, CookieConsent, CommandInputClear, InputClearForm
Page Routes โ
| Path | Page | Permission |
|---|---|---|
/ | Redirect to dashboard | - |
/login | Login | Public |
/register | Register | Public |
/forgot-password | Forgot password | Public |
/reset-password | Reset password | Public |
/dashboard | Configurable dashboard | dashboard:view |
/accounts | Account & permissions | settings:view |
/analytics | Analytics | analytics:view |
/calendar | Calendar | calendar:view |
/documents | Document management | documents:view |
/files | File storage | files:view |
/messages | Message center | messages:view |
/notifications | Notification center | notifications:view |
/users | User management | users:view |
/settings | System settings | settings:view |
/settings/teams | Team settings | settings:view |
/settings/teams/roles | Role management | settings:view |
/profile | User profile | settings:view |
/docs | Help docs | documents:view |
/privacy | Privacy policy | Public |
/terms | Terms of service | Public |
PWA Support โ
The project has complete PWA integration:
Configuration โ
// next.config.mjs
import withPWA from "next-pwa"
const pwaConfig = withPWA({
dest: "public",
register: true,
skipWaiting: true,
disable: process.env.NODE_ENV === "development",
runtimeCaching: [
// Font caching (1 year)
{ urlPattern: /\.(?:woff|woff2|ttf)$/i, handler: "CacheFirst", ... },
// Image caching (24 hours)
{ urlPattern: /\.(?:jpg|png|svg|webp)$/i, handler: "StaleWhileRevalidate", ... },
// Next.js static assets (1 year)
{ urlPattern: /\/_next\/static\/.+\.(js|css)$/i, handler: "CacheFirst", ... },
// Page data (1 hour)
{ urlPattern: /\/_next\/data\/.+\.json$/i, handler: "NetworkFirst", ... },
],
})Features โ
- Offline Access: Service Worker caches static assets
- Install to Desktop: Supports Add to Home Screen
- Self-hosted Fonts: Inter + JetBrains Mono
- Icon Support: 8 sizes (72x72 ~ 512x512)
- Screenshot Showcase: Desktop + Mobile
manifest.json โ
{
"name": "Admin Pro Management System",
"short_name": "Admin Pro",
"display": "standalone",
"orientation": "portrait-primary",
"categories": ["business", "productivity"],
"lang": "zh-CN"
}Security Features โ
Middleware Security Headers โ
// middleware.ts
response.headers.set("Content-Security-Policy", csp)
response.headers.set("X-Content-Type-Options", "nosniff")
response.headers.set("X-Frame-Options", "DENY")
response.headers.set("Referrer-Policy", "strict-origin-when-cross-origin")
response.headers.set("X-XSS-Protection", "1; mode=block")
response.headers.set("Permissions-Policy", "camera=(), microphone=(), geolocation=()")Authentication Protection โ
- Cookie security attributes (
secure,sameSite: strict) - Logged-in users cannot access login page
- Unauthenticated users redirected to login (with redirect parameter)
Build Optimization โ
// next.config.mjs
{
// Package import optimization - reduce bundle size
experimental: {
optimizePackageImports: [
"@radix-ui/react-*",
"lucide-react",
"framer-motion",
"@tanstack/react-query",
"recharts",
"zustand",
],
},
// Remove console in production
compiler: {
removeConsole: { exclude: ["error", "warn"] },
},
// Disable source maps
productionBrowserSourceMaps: false,
// Image optimization
images: {
formats: ["image/avif", "image/webp"],
},
}Deployment โ
Vercel (Recommended) โ
vercelDocker โ
FROM node:18-alpine
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN npm install -g pnpm && pnpm install --frozen-lockfile
COPY . .
RUN pnpm build
EXPOSE 3000
CMD ["pnpm", "start"]Cloudflare Pages โ
The project supports deployment to Cloudflare Pages, see Cloudflare version.
pnpm cf:build
pnpm cf:deployStatic Export โ
# next.config.mjs
export default { output: 'export' }
pnpm build
# Output to out/ directory