How onlook-dev/onlook works
Onlook is an open-source visual-first editor for Next.js and Tailwind projects. A user starts or imports a project, edits it visually or through AI, and sees the running app in a preview; code changes are synchronized with the sandbox. The README documents this workflow, while sampled source confirms the editor engine, branch/sandbox setup, file synchronization, chat endpoint, and publishing manager. Several capabilities are documented but their implementation was not sampled, so those links are identified as README-supported rather than inferred from module names.
Main entry points: engine.ts Editor engine · route.ts Chat endpoint · session.ts Sandbox session · manager.ts Create or import
Components 20
Project setup
- Create or import
apps/web/client/src/components/store/create/manager.ts - Project data
packages/db/src/client.ts
Visual editing
- Project workspace
apps/web/client/src/app/project/[id]/_components/main.tsx - Editor engine
apps/web/client/src/components/store/editor/engine.ts - Canvas and controls
apps/web/client/src/app/project/[id]/_components/canvas/index.tsx - Design panels
apps/web/client/src/app/project/[id]/_components/left-panel/design-panel/index.tsx - Branch management
apps/web/client/src/components/store/editor/branch/manager.ts
Code and preview
- Code editor
apps/web/client/src/app/project/[id]/_components/left-panel/code-panel/code-tab/file-content/code-editor.tsx - Code requests
apps/web/client/src/components/store/editor/code/requests.ts - Sandbox session
apps/web/client/src/components/store/editor/sandbox/session.ts - File synchronization
apps/web/client/src/services/sync-engine/sync-engine.ts - Code provider
packages/code-provider/src/index.ts - App preview
apps/web/client/src/app/project/[id]/_components/canvas/frame/view.tsx
AI and services
- Chat context
apps/web/client/src/components/store/editor/chat/context.ts - Chat conversations
apps/web/client/src/components/store/editor/chat/conversation.ts - Chat endpoint
apps/web/client/src/app/api/chat/route.ts - AI agent and tools
packages/ai/src/apply/client.ts
Publishing
- Publish manager
apps/web/client/src/server/api/routers/publish/manager.ts - Hosting service
Other components
- Designer
Connections 22
- Designer → Create or import: starts project
- Create or import → Project data: stores project
- Designer → Project workspace: opens editor
- Project workspace → Editor engine: uses engine
- Editor engine → Branch management: initializes branches
apps/web/client/src/components/store/editor/engine.ts - Editor engine → Canvas and controls: coordinates editing
- Designer → Canvas and controls: edits visually
- Designer → Design panels: manages design
- Designer → Code editor: edits code
- Code editor → Code requests: submits changes
- Designer → Chat endpoint: sends prompt
- Chat endpoint → AI agent and tools: creates agent stream
apps/web/client/src/app/api/chat/route.ts - Chat endpoint → Chat context: uses context
- Chat endpoint → Chat conversations: stores messages
- Editor engine → Sandbox session: manages sandbox
- Sandbox session → File synchronization: initializes sync
- File synchronization → Code provider: syncs files
apps/web/client/src/services/sync-engine/sync-engine.ts - Sandbox session → App preview: serves app
- Designer → App preview: views running app
- Editor engine → Code requests: coordinates code edits
- Designer → Publish manager: deploys app
- Publish manager → Hosting service: publishes build