๐Ÿ””Welcome

HaloLight multi-framework admin dashboard docs is now live!

Supports 12+ framework versions. Welcome to try.

Skip to content

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 โ€‹

TechnologyVersionDescription
Next.js14.xReact full-stack framework (App Router)
React18.xUI library
TypeScript5.xType safety
Tailwind CSS4.xAtomic CSS
shadcn/uilatestUI component library (28 components)
Zustand5.xState management (6 Stores)
TanStack Query5.xServer state
React Hook Form7.xForm handling
Zod4.xData validation
react-grid-layout1.xDrag-and-drop layout
Recharts3.xChart visualization
Framer Motion12.xAnimation effects
Mock.js1.xData mocking
next-pwa5.xPWA 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.json

Quick Start โ€‹

Installation โ€‹

bash
git clone https://github.com/halolight/halolight.git
cd halolight
pnpm install

Environment Variables โ€‹

bash
cp .env.example .env.local
env
# .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=Halolight

Start Development โ€‹

bash
pnpm dev

Visit http://localhost:3000

Build for Production โ€‹

bash
pnpm build
pnpm start

Core Features โ€‹

1. Configurable Dashboard โ€‹

Supports 9 widget types with drag-and-drop, resize, add and remove capabilities:

Widget TypeDescriptionData Source
statsStatistics card (4 metrics)useDashboardStats
chart-lineLine chart (visit trends)useDashboardVisits
chart-barBar chart (sales statistics)useDashboardSales
chart-piePie chart (traffic distribution)useDashboardPie
recent-usersRecent users listuseDashboardUsers
notificationsNotifications listuseDashboardNotifications
tasksTodo tasksuseDashboardTasks
calendarToday's scheduleuseDashboardCalendar
quick-actionsQuick action shortcutsStatic config
tsx
// 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 col

2. Multi-Account Authentication System โ€‹

tsx
// 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 โ€‹

tsx
// 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 all

4. Page State Caching (Keep-Alive) โ€‹

tsx
// 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 โ€‹

tsx
// 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 mobile

7. Real-time Notifications (WebSocket) โ€‹

tsx
// providers/websocket-provider.tsx
const { status, lastMessage, sendMessage, reconnect } = useWebSocket()

// Listen for new notifications
useRealtimeNotifications((notification) => {
  console.log('New notification:', notification)
})

8. Permission System โ€‹

tsx
// 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:

PresetNameDescription
defaultShadcn ยท NeutralOfficial default neutral colors
blueShadcn ยท BlueBlue primary + cool-toned charts
emeraldShadcn ยท EmeraldFresh green, ideal for data display
amberShadcn ยท AmberAmber/orange, warm and vibrant
violetShadcn ยท VioletHigh-saturation purple, tech feel
roseShadcn ยท RoseRose primary, contrasting charts
tealShadcn ยท TealTeal primary, modern feel
slateShadcn ยท SlateLow-saturation gray-blue, utilitarian
oceanLegacy ยท Ocean BlueBlue-green gradient
sunsetLegacy ยท Sunset OrangeOrange-pink contrast
auroraLegacy ยท Aurora GreenCyan-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 โ€‹

PathPagePermission
/Redirect to dashboard-
/loginLoginPublic
/registerRegisterPublic
/forgot-passwordForgot passwordPublic
/reset-passwordReset passwordPublic
/dashboardConfigurable dashboarddashboard:view
/accountsAccount & permissionssettings:view
/analyticsAnalyticsanalytics:view
/calendarCalendarcalendar:view
/documentsDocument managementdocuments:view
/filesFile storagefiles:view
/messagesMessage centermessages:view
/notificationsNotification centernotifications:view
/usersUser managementusers:view
/settingsSystem settingssettings:view
/settings/teamsTeam settingssettings:view
/settings/teams/rolesRole managementsettings:view
/profileUser profilesettings:view
/docsHelp docsdocuments:view
/privacyPrivacy policyPublic
/termsTerms of servicePublic

PWA Support โ€‹

The project has complete PWA integration:

Configuration โ€‹

js
// 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 โ€‹

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 โ€‹

ts
// 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 โ€‹

js
// 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 โ€‹

bash
vercel

Docker โ€‹

dockerfile
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.

bash
pnpm cf:build
pnpm cf:deploy

Static Export โ€‹

bash
# next.config.mjs
export default { output: 'export' }

pnpm build
# Output to out/ directory