How chatgptnextweb/nextchat works
NextChat is a browser-first AI assistant for chatting with multiple hosted or self-hosted model providers. Its main workflow is conversation UI → chat state and prompt preparation → provider-specific client → API route and provider handler → model service, with responses streamed back into the conversation. The README also documents prompt templates, plugins/MCP, realtime chat, artifacts, image generation, and local browser storage. Some feature paths and their wiring are unsampled; those branches are included where documented, without asserting unverified calls.
Main entry points: chat.ts Chat state · api.ts Client API · sync.ts Cloud sync · home.tsx Application home
Components 21
Chat experience
- Application home
app/components/home.tsx - Chat interface
app/components/chat.tsx
Conversation state
- Chat state
app/store/chat.ts - Prompt templates
app/store/mask.ts
Model access
- Client API
app/client/api.ts - Provider clients
app/client/platforms - Provider router
app/api/[provider]/[...path]/route.ts - Provider handlers
app/api
Assistant capabilities
- Plugin state
app/store/plugin.ts - MCP actions
app/mcp/actions.ts - Realtime chat
app/components/realtime-chat/realtime-chat.tsx - Artifacts
app/components/artifacts.tsx - Image generation
app/components/sd/sd.tsx
Persistence and config
- Model configuration
app/config/server.ts - Model catalog
app/utils/model.ts - Browser storage
app/utils/indexedDB-storage.ts - Cloud sync
app/store/sync.ts - Upstash endpoint
app/api/upstash/[action]/[...key]/route.ts - WebDAV endpoint
app/api/webdav/[...path]/route.ts
Other components
- User
- Model services
Connections 19
- User → Application home: opens
- Application home → Chat interface: shows
- Chat interface → Chat state: updates
- Chat state → Client API: requests
app/store/chat.ts - Client API → Provider clients: dispatches
app/client/api.ts - Provider clients → Provider router: calls
- Provider router → Provider handlers: dispatches
app/api/[provider]/[...path]/route.ts - Provider handlers → Model services: forwards
- Model configuration → Model catalog: configures
app/config/server.ts - Client API → Model configuration: reads
app/client/api.ts - Chat state → Browser storage: persists
app/store/chat.ts - Chat state → Prompt templates: uses
app/store/chat.ts - Chat state → MCP actions: invokes
app/store/chat.ts - User → Realtime chat: uses
- User → Artifacts: views
- User → Image generation: creates images
- Chat state → Plugin state: supports tools
- Cloud sync → Upstash endpoint: syncs
- Cloud sync → WebDAV endpoint: syncs