AgentSkillsCN

frontend-integration

针对 React 和 Flutter 与凯拉什 SDK 工作流的前端集成指南,涵盖设置、API 集成、状态管理以及最佳实践。在咨询“前端集成”“React 集成”“Flutter 集成”“前端开发者”“UI 集成”“React 与凯拉什”“Flutter 与凯拉什”“前端工作流”“API 客户端”“React Query”或“Flutter 状态管理”等相关问题时,可参考本指南。

SKILL.md
--- frontmatter
name: frontend-integration
description: "Frontend integration guides for React and Flutter with Kailash SDK workflows, including setup, API integration, state management, and best practices. Use when asking about 'frontend integration', 'React integration', 'Flutter integration', 'frontend developer', 'UI integration', 'React with Kailash', 'Flutter with Kailash', 'frontend workflow', 'API client', 'React query', or 'Flutter state management'."

Kailash Frontend Integration

Guides for integrating Kailash workflows with frontend frameworks including React and Flutter.

Overview

Frontend integration patterns for:

  • React applications with Kailash workflows
  • Flutter mobile/desktop apps with Kailash
  • API client setup and configuration
  • State management patterns
  • Real-time updates and streaming

Reference Documentation

React Integration

  • react-integration-quick - React integration quick start
    • Setup with Nexus API
    • React Query integration
    • TypeScript types
    • Error handling
    • State management
    • Real-time updates

Flutter Integration

  • flutter-integration-quick - Flutter integration quick start
    • HTTP client setup
    • Dart models
    • State management (Riverpod/Bloc)
    • Error handling
    • Platform-specific code

General Frontend

  • frontend-developer - Frontend development guide
    • Architecture patterns
    • API integration
    • Authentication
    • Error handling
    • Best practices

Integration Patterns

React + Nexus

typescript
import { useQuery } from '@tanstack/react-query';

// Call Kailash workflow via Nexus API
const { data, isLoading, error } = useQuery({
  queryKey: ['workflow', workflowId],
  queryFn: () => fetch(`/api/workflow/${workflowId}`, {
    method: 'POST',
    body: JSON.stringify({ input: 'data' })
  }).then(res => res.json())
});

Flutter + Nexus

dart
import 'package:http/http.dart' as http;

// Call Kailash workflow
Future<Map<String, dynamic>> executeWorkflow(String workflowId, Map<String, dynamic> input) async {
  final response = await http.post(
    Uri.parse('$baseUrl/api/workflow/$workflowId'),
    body: jsonEncode(input),
  );
  return jsonDecode(response.body);
}

Architecture Patterns

Recommended Stack

React Applications:

  • API Layer: Nexus (multi-channel platform)
  • State Management: React Query / Zustand
  • HTTP Client: Fetch API / Axios
  • Type Safety: TypeScript with generated types
  • UI Framework: Shadcn, Material-UI, or custom

Flutter Applications:

  • API Layer: Nexus (multi-channel platform)
  • State Management: Riverpod / Bloc
  • HTTP Client: http package / Dio
  • Type Safety: Dart with generated models
  • UI Framework: Material 3 / Cupertino

Backend Architecture

code
Frontend (React/Flutter)
    ↓
Nexus API (Port 8000)
    ↓
Kailash Workflows
    ↓
DataFlow (Database)
    ↓
PostgreSQL/SQLite

When to Use This Skill

Use this skill when you need to:

  • Integrate React with Kailash workflows
  • Build Flutter apps with Kailash backend
  • Set up API clients for Kailash
  • Implement frontend state management
  • Handle errors in frontend applications
  • Configure real-time updates
  • Generate TypeScript/Dart types

Best Practices

API Integration

  • ✅ Use Nexus for auto-generated APIs
  • ✅ Implement proper error handling
  • ✅ Use type-safe clients (TypeScript/Dart)
  • ✅ Cache responses appropriately
  • ✅ Handle loading and error states
  • ❌ NEVER expose API keys in frontend code
  • ❌ NEVER skip input validation

State Management

  • ✅ Use React Query for server state (React)
  • ✅ Use Riverpod/Bloc for app state (Flutter)
  • ✅ Implement optimistic updates
  • ✅ Handle offline scenarios
  • ❌ NEVER store sensitive data in client state

Performance

  • ✅ Implement pagination for large datasets
  • ✅ Use debouncing for search/filter
  • ✅ Cache API responses
  • ✅ Lazy load components
  • ❌ NEVER fetch all data at once

Related Skills

Support

For frontend integration help, invoke:

  • react-specialist - React integration patterns
  • flutter-specialist - Flutter integration patterns
  • frontend-developer - Frontend architecture
  • nexus-specialist - API configuration