# Connect first source

The onboarding step that connects one source and answers from it before reading has finished.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: Connect first source. Pick a source: it signs in, starts reading, and answers the first question before reading has finished. Preview: https://chatcn.dev/preview/connect-first-source-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/connect-first-source
```

## Usage

```tsx
import { ConnectFirstSource } from "@/components/ui/chatcn/pro/connect-first-source"

<ConnectFirstSource
  providers={[{ id: "notion", name: "Notion", description: "Docs and wikis", icon: <NotionMark /> }, …]}
  status={status}            // "pick" | "connecting" | "reading" | "answering" | "ready" | "error"
  source={source}
  progress={{ read: 86, total: 412, current: "Hiring plan 2027" }}
  suggestions={firstQuestions}
  question={question}
  answer={answer}
  citations={[{ title: "Q4 roadmap", meta: "Edited 2 days ago", href: "…" }]}
  onPick={startOAuth}
  onAsk={ask}
  onContinue={finishOnboarding}
/>
```

Your app drives `status` and the step shows each stage. Pick lists the sources with what each one reads; connecting waits on the provider's sign in window and can be cancelled; once connected, a strip at the top keeps the reading count, a bar and the title being read in view for the rest of the step. First questions arrive while it reads (write them from the first documents read, so they are about this workspace), and the reader can ask their own. The first answer streams in with the documents it came from. Continue unlocks once there is an answer, and reading carries on after the step closes. chatcn ships no third party logos: pass your own marks, or the first letter stands in.

## Examples

### States

Example: States. Waiting on sign in, reading with first questions on the way, the first answer, and a failed connect. Preview: https://chatcn.dev/preview/connect-first-source-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `providers` | `FirstSourceProvider[]` | `{ id, name, description?, icon? }` |
| `status` | `ConnectFirstSourceStatus` | The stage, driven by your app |
| `source` | `string` | The provider picked |
| `progress` | `{ read, total?, current? }` | Without `total` the bar is left out |
| `suggestions` | `string[]` | First questions; a placeholder shows until they arrive |
| `question`, `answer`, `citations` |  | The first exchange; `answer` grows as it streams |
| `error` | `ReactNode` | Why connecting failed, and what to do |
| `onPick`, `onUpload`, `onCancel`, `onAsk`, `onRetry`, `onContinue`, `onSkip` |  |  |
| `labels` | `Partial<ConnectFirstSourceLabels>` | Every string, for translation |

## Accessibility

- Waiting and the question placeholder are status regions; a failed connect is an alert.
- Reading progress is a progressbar named by the source; the ticking title is hidden from screen readers.
- The finished answer is announced once, not token by token.

## Motion

Each stage rises in over 240 ms. The title being read changes in place, the bar moves with transform only, and first questions arrive 50 ms apart. No movement on first paint or under reduced motion.

Source: https://chatcn.dev/docs/components/connect-first-source