A minimal, modern React application for chatting with Dify AI Agents, supporting streaming responses and Markdown rendering.
- Streaming Responses: Real-time typing effect from Dify API.
- Markdown Support: Renders rich text, code blocks, and tables using
react-markdown. - Dual Deployment Modes:
- Proxy Mode: For local development and Vercel (Serverless Function).
- Direct Mode: For static hosting like GitHub Pages (Client-side API calls).
- Dynamic Configuration:
- Settings UI to configure API URL and Key at runtime.
- Supports multiple users connecting to different Dify instances.
- Environment variable fallbacks.
- Node.js 18+
- A Dify App (Chatflow or Agent) with an API Key.
- Clone the repository.
git clone https://github.com/NTLx/dify.chat.stream.git cd dify.chat.stream - Install dependencies:
npm install
- Create a
.envfile (optional, or use Settings UI):DIFY_API_URL=https://api.dify.ai/v1 DIFY_API_KEY=app-your-key
- Start the development server:
npm start
- Import the project into Vercel.
- Set Environment Variables in Vercel Project Settings:
DIFY_API_URLDIFY_API_KEY
- Deploy.
- Push to your GitHub repository.
- Go to Settings > Secrets and variables > Actions.
- Add
DIFY_API_KEYas a Repository Secret. - Add
DIFY_API_URLas a Repository Variable. - The included GitHub Actions workflow will automatically build and deploy to the
gh-pagesbranch. - Go to Settings > Pages and ensure the source is set to "GitHub Actions".
-
Run using Docker Compose (uses pre-built image by default):
docker compose up -d
-
The application will be available at
http://localhost:3000. -
To configure environment variables, modify
.envor pass them directly:DIFY_API_URL=https://api.dify.ai/v1 DIFY_API_KEY=your-key docker compose up -d
Note: To build from source, uncomment the
build: .line indocker-compose.ymland run with--build.
The application resolves API configuration in this order:
- User Settings: Manually entered in the UI (saved in Local Storage).
- Environment Variables:
DIFY_API_URLandDIFY_API_KEYinjected at build or runtime.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
Please see CONTRIBUTING.md for more details.
Distributed under the MIT License. See LICENSE for more information.