Zigbee2MQTT WindFront is a React + TypeScript frontend for Zigbee2MQTT. It uses Vite for bundling, Tailwind CSS v4 with daisyUI v5 for styling, Zustand for global state, and react-router (hash routing) for navigation.
Key architecture notes:
- Monolithic frontend with feature/page component boundaries.
- Multi-instance support via
sourceIdxacross state and WebSocket flows. - Real-time updates via a centralized WebSocket manager.
- i18n with
react-i18nextand JSON namespaces.
- Install dependencies:
npm install - Node.js: >= 22.12.0 (required)
Optional dev environment variables:
VITE_Z2M_API_URLSandVITE_Z2M_API_NAMESfor multi-instance setups.
- Start dev server:
npm start - Start dev server with sample envs:
npm run start:envs - Preview production build:
npm run preview
Vite dev server is rooted at src/ and proxies /api to a Zigbee2MQTT WebSocket endpoint (Z2M_API_URI or ws://localhost:8579).
- Run all tests:
npm test - Run tests with coverage:
npm run test:cov
Testing details:
- Runner: Vitest (jsdom)
- Tests location:
test/ - Coverage output:
coverage/(HTML + text)
- TypeScript strict mode (ESNext target, ESM only).
- Use functional React components and hooks.
- Use 4-space indentation, LF line endings.
- Use Biome for formatting and linting:
npm run check(fix + format)npm run check:ci(CI mode)
- Always use
.jsextensions in TS/TSX imports (ESM + bundler resolution). - No barrel files or re-export-all.
Styling rules:
- Use Tailwind CSS + daisyUI classes; avoid custom CSS unless necessary.
- Prefer daisyUI component classes and semantic colors.
- Truncation pattern:
truncateon text, and ensure parent hasmin-w-0.
Naming conventions:
- Components: PascalCase
- Hooks:
useprefix (camelCase) - Utilities: camelCase
- Feature folders: kebab-case
- API properties: snake_case
src/components/: reusable components by domain/pagesrc/pages/: route-level pagessrc/layout/: layout componentssrc/hooks/: custom hookssrc/websocket/: WebSocket manager + handlerssrc/store.ts: Zustand global statesrc/i18n/locales/: translation JSON filessrc/utils.ts: shared utilities
- Production build:
npm run build - Clean build output:
npm run clean - Type checking:
npm run typecheck
Output:
- Build artifacts are generated into
dist/.
- Start Storybook:
npm run storybook - Build Storybook:
npm run build-storybook
- Keep changes aligned with existing component boundaries and
sourceIdxpatterns. - Update or add tests in
test/for behavior changes. - Run
npm run checkandnpm testbefore opening a PR.
- If API calls fail in dev, verify
Z2M_API_URIor the dev proxy target (ws://localhost:8579). - For multi-instance UI issues, confirm
sourceIdxis preserved through state, WebSocket handlers, and selectors.
- Do not hardcode secrets. Use environment variables and GitHub Secrets for CI/CD.
- Avoid logging sensitive data to the console.