Nuxt Version โ
Halolight Nuxt version is built on Nuxt 3 with Vue 3.5 + Composition API + TypeScript, providing an out-of-the-box full-stack development experience.
Live Preview: https://halolight-nuxt.h7ml.cn/
GitHub: https://github.com/halolight/halolight-nuxt
Tech Stack โ
| Technology | Version | Description |
|---|---|---|
| Nuxt | 3.10 | Vue full-stack framework |
| Vue | 3.5+ | Progressive framework |
| TypeScript | 5.7 | Type safety |
| Tailwind CSS | 3.x (CDN) | Atomic CSS |
| Pinia | 0.5 | State management |
| VueUse | 10.x | Composables utility library |
| Mock.js | 1.x | Data mocking |
Core Features โ
- Full-Stack Development: Built-in Nitro server for unified frontend and backend development
- Auto Import: Automatic import of components, composables, and APIs
- File-Based Routing: Automatic routing based on file system
- SSR/SSG: Optional server-side rendering and static generation
- Command Palette:
โ/Ctrl + Kfor quick navigation - Hot Reload: Excellent HMR development experience
- Module Ecosystem: Rich Nuxt module extensions
Directory Structure โ
halolight-nuxt/
โโโ nuxt.config.ts # Nuxt configuration
โโโ app.vue # App root component
โโโ pages/ # File-based routing
โ โโโ index.vue # Home page
โ โโโ login.vue # Login
โ โโโ register.vue # Register
โ โโโ forgot-password.vue # Forgot password
โ โโโ reset-password.vue # Reset password
โ โโโ terms.vue # Terms of service
โ โโโ privacy.vue # Privacy policy
โ โโโ dashboard/ # Dashboard
โ โ โโโ index.vue
โ โโโ users/ # User management
โ โ โโโ index.vue
โ โโโ messages/ # Messages
โ โ โโโ index.vue
โ โโโ analytics/ # Analytics
โ โ โโโ index.vue
โ โโโ profile/ # User profile
โ โ โโโ index.vue
โ โโโ settings/ # System settings
โ โโโ index.vue
โโโ components/ # Auto-imported components
โ โโโ common/ # Common components
โ โโโ AppHeader.vue
โ โโโ AppSidebar.vue
โ โโโ AppFooter.vue
โ โโโ AppTabs.vue
โ โโโ CommandMenu.vue
โ โโโ ToastContainer.vue
โโโ composables/ # Composable functions
โ โโโ useTheme.ts
โ โโโ useToast.ts
โ โโโ useCommandMenu.ts
โโโ layouts/ # Layouts
โ โโโ default.vue # Admin layout
โ โโโ auth.vue # Auth layout
โโโ middleware/ # Middleware
โ โโโ auth.global.ts
โโโ plugins/ # Plugins
โ โโโ pinia-persist.client.ts
โโโ stores/ # Pinia stores
โ โโโ auth.ts
โ โโโ ui-settings.ts
โ โโโ dashboard.ts
โ โโโ layout.ts
โ โโโ tabs.ts
โโโ utils/ # Utility functions
โ โโโ index.ts
โ โโโ mock.ts
โโโ assets/css/ # Style files
โ โโโ main.css
โ โโโ tailwind.css
โโโ tests/ # Test files
โ โโโ unit/
โโโ .github/ # GitHub Actions
โ โโโ workflows/
โ โโโ ci.yml
โ โโโ deploy.yml
โโโ public/ # Static assetsQuick Start โ
Installation โ
bash
git clone https://github.com/halolight/halolight-nuxt.git
cd halolight-nuxt
pnpm installEnvironment Variables โ
bash
cp .env.example .env.localenv
# .env example
NUXT_PUBLIC_API_BASE=/api
NUXT_PUBLIC_MOCK=true
NUXT_PUBLIC_DEMO_EMAIL=admin@halolight.h7ml.cn
NUXT_PUBLIC_DEMO_PASSWORD=123456
NUXT_PUBLIC_SHOW_DEMO_HINT=true
NUXT_PUBLIC_APP_TITLE=Admin Pro
NUXT_PUBLIC_BRAND_NAME=HalolightStart Development โ
bash
pnpm devVisit http://localhost:3000
Build for Production โ
bash
pnpm build
pnpm previewCode Checking and Testing โ
bash
# Type checking
pnpm typecheck
# Code linting
pnpm lint
pnpm lint:fix
# Run tests
pnpm test
pnpm test:run
pnpm test:coverageDemo Account โ
- Email:
admin@halolight.h7ml.cn - Password:
123456
Core Features โ
State Management (Pinia) โ
ts
// stores/auth.ts
export const useAuthStore = defineStore('auth', () => {
const user = ref<User | null>(null)
const token = ref('')
const loading = ref(false)
const error = ref('')
const isAuthenticated = computed(() => !!token.value && !!user.value)
async function login(credentials: LoginCredentials) {
loading.value = true
error.value = ''
try {
// Login logic
const result = await mockLogin(credentials)
user.value = result.user
token.value = result.token
} catch (e) {
error.value = e.message
throw e
} finally {
loading.value = false
}
}
function logout() {
user.value = null
token.value = ''
navigateTo('/login')
}
return { user, token, loading, error, isAuthenticated, login, logout }
})Authentication Middleware โ
ts
// middleware/auth.global.ts
export default defineNuxtRouteMiddleware((to) => {
const authStore = useAuthStore()
// Public pages list
const publicPages = ['/login', '/register', '/forgot-password', '/reset-password']
if (publicPages.includes(to.path)) {
return
}
if (!authStore.isAuthenticated) {
return navigateTo({
path: '/login',
query: { redirect: to.fullPath },
})
}
})Data Fetching โ
vue
<script setup lang="ts">
// Using useFetch with automatic SSR handling
const { data: users, pending, error, refresh } = await useFetch('/api/users', {
query: { page: 1, limit: 10 },
})
// Using useAsyncData with custom key
const { data: stats } = await useAsyncData('dashboard-stats', () =>
$fetch('/api/dashboard/stats')
)
</script>Page Routes โ
| Path | Page | Layout |
|---|---|---|
/ | Home | - |
/login | Login | auth |
/register | Register | auth |
/forgot-password | Forgot password | auth |
/reset-password | Reset password | auth |
/terms | Terms of service | auth |
/privacy | Privacy policy | auth |
/dashboard | Dashboard | default |
/users | User management | default |
/messages | Messages | default |
/analytics | Analytics | default |
/profile | User profile | default |
/settings | System settings | default |
Route Configuration โ
vue
<!-- pages/login.vue -->
<script setup lang="ts">
definePageMeta({
layout: 'auth',
})
</script>vue
<!-- pages/dashboard/index.vue -->
<script setup lang="ts">
definePageMeta({
layout: 'default',
})
</script>Configuration โ
Nuxt Configuration โ
ts
// nuxt.config.ts
export default defineNuxtConfig({
compatibilityDate: '2025-11-30',
devtools: { enabled: false },
modules: [
'@pinia/nuxt',
'@vueuse/nuxt',
],
css: ['~/assets/css/main.css'],
runtimeConfig: {
public: {
apiBase: '/api',
mock: true,
demoEmail: 'admin@halolight.h7ml.cn',
demoPassword: '123456',
showDemoHint: true,
appTitle: 'Admin Pro',
brandName: 'Halolight',
},
},
app: {
head: {
title: 'Admin Pro',
script: [
{ src: 'https://cdn.tailwindcss.com' },
],
},
},
})Deployment โ
Node.js Server โ
bash
pnpm build
node .output/server/index.mjsDocker โ
dockerfile
FROM node:20-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 ["node", ".output/server/index.mjs"]Vercel โ
bash
npx vercelCloudflare Pages โ
ts
// nuxt.config.ts
export default defineNuxtConfig({
nitro: {
preset: 'cloudflare-pages',
},
})Comparison with Other Versions โ
| Feature | Nuxt Version | Vue Version | Next.js Version |
|---|---|---|---|
| State Management | Pinia | Pinia | Zustand |
| Data Fetching | useFetch | Axios | TanStack Query |
| Form Validation | Native | VeeValidate + Zod | React Hook Form + Zod |
| Server | Built-in Nitro | Separate backend | API Routes |
| Styling | Tailwind CDN | Tailwind | Tailwind |
| Routing | File-based routing | Vue Router | App Router |
| SSR | Built-in support | Requires configuration | Built-in support |