๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป Use Ant Design like a Pro!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

6.1 KiB

Next.js + React 19 + Tailwind CSS + CopilotKit Integration

This document describes the integration of modern AI development stack with Ant Design Pro.

๐Ÿš€ What's New

This integration adds support for:

  • Next.js 15.1.5 - Modern React framework with React 19 support
  • Tailwind CSS 3.4 - Utility-first CSS framework, configured to work with Ant Design
  • CopilotKit 1.3.20 - AI assistant integration for modern development experience
  • React 19 - Latest React with experimental features
  • CSS-in-JS Compatibility - Seamless integration with existing antd-style

๐Ÿ“ Project Structure

ant-design-pro/
โ”œโ”€โ”€ next-pages/           # Next.js pages (new)
โ”‚   โ”œโ”€โ”€ _app.tsx         # Next.js app configuration
โ”‚   โ”œโ”€โ”€ _document.tsx    # HTML document structure
โ”‚   โ”œโ”€โ”€ index.tsx        # Homepage with integration demo
โ”‚   โ”œโ”€โ”€ demo.tsx         # Component showcase page
โ”‚   โ””โ”€โ”€ api/
โ”‚       โ””โ”€โ”€ copilotkit.ts # AI assistant API endpoint
โ”œโ”€โ”€ next-components/     # Next.js specific components (new)
โ”œโ”€โ”€ styles/             # Global styles for Next.js (new)
โ”‚   โ””โ”€โ”€ globals.css     # Tailwind CSS imports and custom styles
โ”œโ”€โ”€ src/               # Original Umi.js source (unchanged)
โ”œโ”€โ”€ config/            # Umi.js configuration (unchanged)
โ”œโ”€โ”€ next.config.js     # Next.js configuration (new)
โ”œโ”€โ”€ tailwind.config.js # Tailwind CSS configuration (new)
โ””โ”€โ”€ postcss.config.js  # PostCSS configuration (new)

๐Ÿ› ๏ธ Development Commands

Umi.js (Original Workflow)

# Start Umi.js development server on port 8000
npm run dev
npm run start:dev

# Build Umi.js for production
npm run build

# Preview Umi.js build
npm run preview

Next.js (New AI Workflow)

# Start Next.js development server on port 3001
npm run dev:next

# Build Next.js for production
npm run build:next

# Preview Next.js build
npm run preview:next

๐ŸŽฏ Key Features

1. Dual Framework Support

  • Umi.js: Traditional enterprise development workflow (port 8000)
  • Next.js: Modern AI-powered development workflow (port 3001)
  • Both frameworks can run simultaneously without conflicts

2. Technology Integration

  • React 19: Latest React features with experimental support
  • Ant Design 5.26.4: Enterprise-class UI components
  • Tailwind CSS: Utility-first styling that complements Ant Design
  • CSS-in-JS: antd-style continues to work seamlessly
  • CopilotKit: AI assistant for development help

3. AI Features

  • AI Assistant: Click the chat icon for development help
  • Context Awareness: AI understands your current page and components
  • Form Assistance: AI can help fill forms and suggest values
  • Code Suggestions: Get help with React, Ant Design, and Tailwind

๐ŸŽจ Styling Approach

Ant Design + Tailwind CSS Harmony

// You can use both Ant Design components and Tailwind classes
<Card className="shadow-lg hover:shadow-xl transition-shadow">
  <Button type="primary" className="rounded-lg bg-gradient-to-r from-blue-500 to-purple-600">
    Modern Button
  </Button>
</Card>

Configuration Details

  • Tailwind CSS is configured with important: '#__next' to avoid conflicts
  • Preflight is disabled to preserve Ant Design's base styles
  • Custom color palette includes Ant Design colors
  • Responsive breakpoints align with Ant Design's grid system

๐Ÿ”ง API Integration

CopilotKit Setup

The AI assistant is configured with:

  • Mock API endpoint (/api/copilotkit) for demonstration
  • Context-aware responses about Ant Design Pro
  • Form interaction capabilities
  • Development guidance and suggestions

Production Setup

For production use, replace the mock API with:

// In next-pages/_app.tsx
<CopilotKit runtimeUrl="https://your-ai-api-endpoint.com">

๐Ÿš€ Getting Started

  1. Install Dependencies (if not already installed):

    npm install
    
  2. Start Development:

    # For traditional development
    npm run dev
    
    # For AI-powered development
    npm run dev:next
    
  3. Visit the Apps:

  4. Try the AI Assistant:

    • Click the chat icon in the Next.js app
    • Ask questions like "Help me create a user form" or "Show me Ant Design best practices"

๐Ÿ“š Examples

Page Examples

  • Homepage (/): Integration overview and feature showcase
  • Demo Page (/demo): Comprehensive component examples with Tailwind styling

Component Examples

  • Forms with AI assistance
  • Tables with modern styling
  • Statistics cards with gradients
  • Responsive layouts using Tailwind Grid

๐Ÿค Compatibility

Browser Support

  • Modern browsers with React 19 support
  • Same browser support as Ant Design 5.x

Framework Coexistence

  • Umi.js and Next.js run on different ports
  • Shared TypeScript configuration
  • Independent build processes
  • No conflicts between routing systems

๐Ÿ“ˆ Migration Path

Gradual Adoption

  1. Phase 1: Use Next.js for new AI-powered features
  2. Phase 2: Migrate critical pages to Next.js as needed
  3. Phase 3: Full migration if desired (optional)

Component Reuse

  • Existing Ant Design components work in both frameworks
  • Shared utilities and services can be used across frameworks
  • CSS-in-JS styles remain compatible

๐Ÿ”ฎ Future Enhancements

  • Advanced AI actions and workflows
  • Integration with popular AI services (OpenAI, Claude, etc.)
  • Automated testing with AI assistance
  • Code generation capabilities
  • Advanced Tailwind + Ant Design component library

๐Ÿ†˜ Troubleshooting

Common Issues

  1. Port Conflicts: Ensure ports 8000 and 3001 are available
  2. Style Conflicts: Tailwind's important setting prevents most conflicts
  3. TypeScript Errors: Both frameworks share the same TypeScript config

Support

  • Check the demo pages for working examples
  • Use the AI assistant for development questions
  • Refer to official documentation for each technology

Happy Coding! ๐ŸŽ‰

This integration brings the best of modern AI development to the robust Ant Design Pro ecosystem.