๐Ÿ””Welcome

HaloLight multi-framework admin dashboard docs is now live!

Supports 12+ framework versions. Welcome to try.

Skip to content

Astro Version โ€‹

HaloLight Astro version is built on Astro 5, featuring Islands architecture with zero JS initial load and ultimate performance.

Live Preview: https://halolight-astro.h7ml.cn/

GitHub: https://github.com/halolight/halolight-astro

Tech Stack โ€‹

TechnologyVersionDescription
Astro5.xIslands architecture framework
TypeScript5.xType safety
Tailwind CSS3.xAtomic CSS
ViteBuilt-inBuild tool
@astrojs/node9.xNode.js adapter
Vitest4.xUnit testing

Core Features โ€‹

  • Islands Architecture: Zero JS by default, hydrate interactive components on demand
  • Multi-framework Support: Use React, Vue, Svelte components in the same project
  • Content-first: Static-first, ultimate initial load performance
  • SSR Support: Server-side rendering via @astrojs/node adapter
  • File-based Routing: Automatic routing based on file system
  • API Endpoints: Native support for REST API endpoints

Directory Structure โ€‹

halolight-astro/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ pages/                    # File-based routing
โ”‚   โ”‚   โ”œโ”€โ”€ index.astro          # Home
โ”‚   โ”‚   โ”œโ”€โ”€ privacy.astro        # Privacy Policy
โ”‚   โ”‚   โ”œโ”€โ”€ terms.astro          # Terms of Service
โ”‚   โ”‚   โ”œโ”€โ”€ auth/                # Auth pages
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ login.astro
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ register.astro
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ forgot-password.astro
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ reset-password.astro
โ”‚   โ”‚   โ”œโ”€โ”€ dashboard/           # Dashboard pages
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ index.astro      # Dashboard home
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ analytics.astro  # Analytics
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ users.astro      # User management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ accounts.astro   # Account management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ documents.astro  # Document management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ files.astro      # File management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ messages.astro   # Message center
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ notifications.astro
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ calendar.astro   # Calendar
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ profile.astro    # Profile
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ settings/        # Settings
โ”‚   โ”‚   โ””โ”€โ”€ api/                 # API endpoints
โ”‚   โ”‚       โ””โ”€โ”€ auth/
โ”‚   โ”‚           โ”œโ”€โ”€ login.ts
โ”‚   โ”‚           โ”œโ”€โ”€ register.ts
โ”‚   โ”‚           โ”œโ”€โ”€ forgot-password.ts
โ”‚   โ”‚           โ””โ”€โ”€ reset-password.ts
โ”‚   โ”œโ”€โ”€ layouts/                 # Layout components
โ”‚   โ”‚   โ”œโ”€โ”€ Layout.astro         # Base layout
โ”‚   โ”‚   โ”œโ”€โ”€ AuthLayout.astro     # Auth layout
โ”‚   โ”‚   โ”œโ”€โ”€ DashboardLayout.astro # Dashboard layout
โ”‚   โ”‚   โ””โ”€โ”€ LegalLayout.astro    # Legal pages layout
โ”‚   โ”œโ”€โ”€ components/              # UI components
โ”‚   โ”‚   โ””โ”€โ”€ dashboard/
โ”‚   โ”‚       โ”œโ”€โ”€ Sidebar.astro    # Sidebar
โ”‚   โ”‚       โ””โ”€โ”€ Header.astro     # Top navigation
โ”‚   โ”œโ”€โ”€ styles/                  # Global styles
โ”‚   โ”‚   โ””โ”€โ”€ globals.css
โ”‚   โ””โ”€โ”€ assets/                  # Static assets
โ”œโ”€โ”€ public/                      # Public assets
โ”œโ”€โ”€ tests/                       # Test files
โ”œโ”€โ”€ astro.config.mjs            # Astro config
โ”œโ”€โ”€ tailwind.config.mjs         # Tailwind config
โ”œโ”€โ”€ vitest.config.ts            # Test config
โ””โ”€โ”€ package.json

Quick Start โ€‹

Installation โ€‹

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

Environment Variables โ€‹

bash
cp .env.example .env.local
env
# .env.local example
PUBLIC_API_URL=/api
PUBLIC_MOCK=true
PUBLIC_DEMO_EMAIL=admin@halolight.h7ml.cn
PUBLIC_DEMO_PASSWORD=123456
PUBLIC_SHOW_DEMO_HINT=true
PUBLIC_APP_TITLE=Admin Pro
PUBLIC_BRAND_NAME=Halolight

Start Development โ€‹

bash
pnpm dev

Visit http://localhost:4321

Build for Production โ€‹

bash
pnpm build
pnpm preview

Core Features โ€‹

Islands Architecture โ€‹

Astro's Islands architecture allows pages to be static HTML by default, with JavaScript only added to interactive components:

astro
---
// Static import, no JS
import StaticCard from '../components/StaticCard.astro';
// Interactive component (can be from React/Vue/Svelte)
import Counter from '../components/Counter.tsx';
---

<!-- Pure static, zero JS -->
<StaticCard title="Statistics" />

<!-- Hydrate on page load -->
<Counter client:load />

<!-- Hydrate when visible (lazy load) -->
<Counter client:visible />

<!-- Hydrate when browser is idle -->
<Counter client:idle />

Client Directives โ€‹

DirectiveBehaviorUse Case
client:loadHydrate immediately on page loadCritical interactions
client:idleHydrate when browser is idleNon-critical interactions
client:visibleHydrate when element is visibleLazy-loaded components
client:onlyClient-side rendering onlyBrowser API dependent
client:mediaHydrate when media query matchesResponsive components

Layout System โ€‹

astro
---
// layouts/DashboardLayout.astro
import Layout from './Layout.astro';
import Sidebar from '../components/dashboard/Sidebar.astro';
import Header from '../components/dashboard/Header.astro';

interface Props {
  title: string;
  description?: string;
}

const { title, description } = Astro.props;
const currentPath = Astro.url.pathname;
---

<Layout title={title} description={description}>
  <div class="min-h-screen bg-gray-50 dark:bg-gray-900">
    <Sidebar currentPath={currentPath} />
    <div class="lg:pl-64">
      <Header title={title} />
      <main class="p-4 lg:p-6">
        <slot />
      </main>
    </div>
  </div>
</Layout>

API Endpoints โ€‹

Astro natively supports creating API endpoints:

typescript
// src/pages/api/auth/login.ts
import type { APIRoute } from 'astro';

export const POST: APIRoute = async ({ request }) => {
  const body = await request.json();
  const { email, password } = body;

  // Validation logic
  if (!email || !password) {
    return new Response(
      JSON.stringify({ success: false, message: 'Email and password are required' }),
      { status: 400, headers: { 'Content-Type': 'application/json' } }
    );
  }

  // Authentication logic...

  return new Response(
    JSON.stringify({
      success: true,
      message: 'Login successful',
      user: { id: 1, name: 'Admin', role: 'admin' },
      token: 'mock_token',
    }),
    { status: 200, headers: { 'Content-Type': 'application/json' } }
  );
};

File-based Routing โ€‹

File PathURLDescription
src/pages/index.astro/Home
src/pages/auth/login.astro/auth/loginLogin
src/pages/dashboard/index.astro/dashboardDashboard
src/pages/dashboard/[id].astro/dashboard/:idDynamic route
src/pages/api/auth/login.ts/api/auth/loginAPI endpoint

Page Routes โ€‹

PathPageDescription
/HomeLanding page
/auth/loginLoginUser login
/auth/registerRegisterUser registration
/auth/forgot-passwordForgot PasswordPassword recovery
/auth/reset-passwordReset PasswordSet new password
/dashboardDashboardData overview
/dashboard/analyticsAnalyticsChart statistics
/dashboard/usersUser ManagementUser list
/dashboard/accountsAccount ManagementAccount list
/dashboard/documentsDocument ManagementDocument list
/dashboard/filesFile ManagementFile list
/dashboard/messagesMessage CenterMessage list
/dashboard/notificationsNotificationsNotification list
/dashboard/calendarCalendarSchedule management
/dashboard/profileProfilePersonal information
/dashboard/settingsSettingsSystem settings
/privacyPrivacy PolicyLegal page
/termsTerms of ServiceLegal page

Configuration โ€‹

Astro Configuration โ€‹

javascript
// astro.config.mjs
import { defineConfig } from 'astro/config';
import tailwind from '@astrojs/tailwind';
import node from '@astrojs/node';

export default defineConfig({
  integrations: [tailwind()],
  output: 'server',  // SSR mode
  adapter: node({
    mode: 'standalone',
  }),
  server: {
    port: 4321,
    host: true,
  },
});

Output Modes โ€‹

ModeDescriptionUse Case
staticStatic site generation (SSG)Blogs, documentation
serverServer-side rendering (SSR)Dynamic applications
hybridHybrid modePartially dynamic

Deployment โ€‹

Node.js Server โ€‹

bash
pnpm build
node ./dist/server/entry.mjs

Docker โ€‹

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 4321
CMD ["node", "./dist/server/entry.mjs"]

Vercel โ€‹

bash
# Install Vercel adapter
pnpm add @astrojs/vercel

# astro.config.mjs
import vercel from '@astrojs/vercel/serverless';

export default defineConfig({
  adapter: vercel(),
});

Cloudflare Pages โ€‹

bash
# Install Cloudflare adapter
pnpm add @astrojs/cloudflare

# astro.config.mjs
import cloudflare from '@astrojs/cloudflare';

export default defineConfig({
  adapter: cloudflare(),
});

Testing โ€‹

bash
# Run tests
pnpm test

# Generate coverage report
pnpm test --coverage

Comparison with Other Frameworks โ€‹

FeatureAstroNext.jsNuxt
Default JS Size0 KB~80 KB~70 KB
Islands ArchitectureNative supportNot supportedNot supported
Multi-framework ComponentsSupportedNot supportedNot supported
SSG/SSRSupportedSupportedSupported
Learning CurveLowMediumMedium