# Guided setup

For someone who has never touched DNS. They share the tab with their DNS provider, and a small window says where to click, one step at a time, until DNS shows the record.

> **Experimental: it can change in any release**
>
> Guided setup runs on prufy.dev's own claim page, as an experiment. Everything about it can change or go in any release: the element, its handler, its model loop and its screenshot hints. Prufy doesn't yet host a guide page for other products' connect modals to open, so the modal can't offer it in your product today.

## Where this standsExperimental

The guide is a second element, `prufy-guide`, in its own entry, `@prufy/connect/guide`, so a page with only the modal never carries it. The [connect modal](https://www.prufy.dev/docs/components/connect-modal.md) offers it after the manual steps as Guide me through it, opens Prufy's guide page in its own window, and checks DNS itself when the page says it's done.

| Piece | Where it is | How settled |
| --- | --- | --- |
| `prufy-guide` | `@prufy/connect/guide` | Experimental |
| `PrufyGuide`, `useGuide` | `@prufy/connect/guide/react` | Experimental |
| `createGuideHandler` | `@prufy/connect/server` | Experimental |
| `createAiGuide` | `@prufy/connect/guide/ai` | Experimental |
| Screenshot hints | `visual-hints` | Experimental |
| `createFixtureGuide`, `createSimulatedScreen` | `@prufy/connect/simulation` | Demo only |

## What it can do

- Watch the tab the person shares. One screenshot a turn, scaled to 1280 pixels wide, and only after they say they're signed in. The first thing it shows is what it will see and that an AI reads it.
- Say where to click, in the provider's own words. One short step at a time, using the labels on the screen: `Add record`, `Name`, `Save`.
- Hand over the values with copy buttons. A step can point at the name or the value. The button copies it from the record, in the form the provider's field wants.
- Wait for the person. Progression is manual by default: Next, a confirmation like Name pasted, or Not sure, which opens a question field. It can follow the tab on its own instead, with `auto-advance`.
- Check DNS for real. When the record should be there, it runs Prufy's DNS check, the same one as everywhere else, and shows the same checking and verified animation as the modal.
- Float above the provider's tab. In Chrome and Edge it opens in a Picture-in-Picture window that stays on top. Elsewhere, or with `dock`, it docks beside the page.
- Wear your theme. It takes the same tokens as the modal, as CSS custom properties or a `theme` object.

## What it can't do

- It can't click, type or change anything. It only looks and talks. The person does every step.
- It never writes a value. The model can name a field to copy. It can't put the record's host or value in its own words, so it can't get them wrong.
- It can't say verified. The model can ask for a DNS check. Only the check's answer moves the guide to verified, and only that fires `verified`.
- It can't send links or markup. Its words are plain text. The only link is the provider's settings page, from the record.
- It doesn't run in your page. The guide runs on Prufy's origin, so the browser names Prufy as the site sharing the screen, and the screenshots never pass through your server.
- It can't run on a phone. Sharing a tab needs `getDisplayMedia`. The modal only offers the guide where the browser can share one.
- It doesn't run forever. A session ends after 120 screenshots or 15 minutes, by default.
- It keeps sessions in one server's memory. `createAiGuide` holds each session in the process that started it, so every request of a session has to reach the same server.

## Make it yours

The guide below is the real element, docked inside the stage and running on the package's simulation: nothing is shared and nothing is sent. Pick a theme, switch between light and dark, or edit the accent, corners and font. The code under it is exactly what the preview is wearing.

The tokens are the modal's: `--prufy-accent`, `--prufy-radius`, `--prufy-font` and the rest. The full list, with what each one falls back to, is on [the connect modal's page](https://www.prufy.dev/docs/components/connect-modal.md). A theme set on the element follows it into the floating window.

## Use it

The guide page lives on Prufy's origin. It needs the element, the domain, and the handler's address. Pass the `ticket` from the modal's detection, so the guide shows the same record.

The guide page, from a CDN

```
<script type="module" src="https://unpkg.com/@prufy/connect@0.1/cdn/prufy-guide.js"></script>

<prufy-guide endpoint="/api/guide" domain="acme.com"></prufy-guide>
```

The CDN file, `https://unpkg.com/@prufy/connect@0.1/cdn/prufy-guide.js`, carries Lit and everything else it needs. With a bundler, `import "@prufy/connect/guide"` registers the element instead.

In React

```javascript
import { PrufyGuide } from "@prufy/connect/guide/react"

export function GuidePage({ domain, ticket }: { domain: string; ticket?: string }) {
  return (
    <PrufyGuide
      endpoint="/api/guide"
      domain={domain}
      ticket={ticket}
      onVerified={({ domain }) => markVerified(domain)}
    />
  )
}
```

The handler answers three requests. The last part of the path picks one, so it works wherever you mount it.

Its handler

```javascript
// app/api/guide/[action]/route.ts, on Prufy's own origin
import { createGuideHandler } from "@prufy/connect/server"
import { createAiGuide } from "@prufy/connect/guide/ai" // experimental
import { source } from "@/lib/guide-source" // looks the domain up, runs the DNS check

const handler = createGuideHandler(createAiGuide({ source }))
export { handler as POST }
```

| Request | What it does |
| --- | --- |
| POST `…/start` | Opens a session: the provider, the record and the caps. |
| POST `…/turn` | The newest screenshot or a reply in, steps out, streamed one JSON line each. |
| POST `…/check` | Prufy's real DNS check, without the model. |

## Host it in your app

The guide shares a screen, opens a window of its own and calls a model, so the page around it has more to get right than a page around the modal. Each of these cost a real integration time to find.

### On the page

- Mount it where re-renders can't remove it. Taking the element out of the page stops the share and ends the session. If the part of your page around it swaps on polling or a state change, mount `PrufyGuide` above it.
- Open it from the click. The floating window and the share prompt need the click that asked for them. Call `show()` in the click handler, or put your button in the `trigger` slot. Opened from an effect, after an `await`, or by setting `open` from state, the guide docks instead, without saying why.
- Allow screen sharing. A `Permissions-Policy` that leaves out `display-capture` makes the share fail with no hint that a header is why. Allow it on the page that hosts the guide:

Response header

```
Permissions-Policy: display-capture=(self)
```

- Hide it where a tab can't be shared. Phones can't share one. `browserScreen().supported`, from `@prufy/connect/guide`, says so. It reads `navigator`, so in React read it in a way that renders the same on the server:

use-can-share-screen.ts

```javascript
import { browserScreen } from "@prufy/connect/guide"
import { useSyncExternalStore } from "react"

const subscribe = () => () => {}

/** True where a tab can be shared, false where it can't, null on the server. */
export const useCanShareScreen = () =>
  useSyncExternalStore(subscribe, () => browserScreen().supported, () => null)
```

- Treat verified as a hint. `verified` fires after Prufy's DNS check, from the element's own state. On it, re-read your server's state. Never mark a domain verified because the event fired.

### Content Security Policy

- Server-rendered, it writes a style tag. `PrufyGuide` renders its trigger on a server with a `<style>` inside. Allow it by a hash computed from `guideShadowHtml()`, plus one for a `theme`, or mount the element only in the browser, where it adopts its styles and there's nothing to allow.
- The floating window keeps your policy. The Picture-in-Picture window inherits the page's CSP. In 0.1.0, the panel's styles and copied fonts are plain `<style>` tags there, so a policy that allows styles only by nonce or hash blocks them and the panel floats unstyled. Only a production CSP shows it. Set `dock` until the next release, which carries the page's nonce into the window.
- Screenshot hints need data: images. With `visual-hints`, the screenshot is shown as a `data:image/jpeg` URL, so the page's policy needs `img-src data:`. Without it the image is blocked and the step shows only its text. In 0.1.0 the only sign is a CSP report in the floating window's console. From the next release the panel says the screenshot couldn't be shown, and `previewchange` reports `blocked`.

### On the server

- Install ai. It's an optional peer, needed only for `@prufy/connect/guide/ai`.
- Give it AI Gateway credentials. `AI_GATEWAY_API_KEY`, or the project's OIDC token on Vercel. Zero data retention is on by default and needs a paid AI Gateway plan or credits. Without one, turns fail.
- Allow big, slow turns. A turn's body carries one screenshot, up to 3 MB, and its answer streams. Give the route a longer time limit than a JSON route: Prufy uses 60 seconds.
- Check who's asking before a session starts. `source.start` sees only the domain and ticket the page sent, and anyone can send any. Check that the signed-in user owns the domain in your route, before the handler. Later turns carry a random session id.
- Share sessions across instances. By default `createAiGuide` keeps sessions in its own memory, so on serverless a turn can reach an instance that never saw the session. In 0.1.0, keep a session on one instance. From the next release, pass a shared `store`.
- Answer errors in the guide's shape. Anything your route refuses before the handler should answer `{ error: { kind, message } }`, where `kind` is `domain`, `rate_limited`, `unreachable` or `server`. Anything else reads as `server`.

The route, put together

```javascript
// app/api/guide/[action]/route.ts
import { createAiGuide } from "@prufy/connect/guide/ai"
import { createGuideHandler } from "@prufy/connect/server"

// Once per process: sessions live in this object's memory.
const handler = createGuideHandler(createAiGuide({ source }))

export const maxDuration = 60 // a turn streams the model's answer

export async function POST(request: Request) {
  // domain and ticket come from the page, so anyone can send any. Check them
  // before the handler starts a session. Later turns carry a random session id.
  if (new URL(request.url).pathname.endsWith("/start")) {
    const { domain } = await request.clone().json()
    if (!(await ownsDomain(request, domain))) {
      return Response.json(
        { error: { kind: "domain", message: "We can't find that domain." } },
        { status: 404 },
      )
    }
  }
  return handler(request)
}
```

### Testing it

Most automated and embedded browsers can't float a window or share a tab: they offer both, then fail, so the guide docks and the share reads as cancelled. Test in Chrome. Headless Chrome can answer the share prompt itself, and the floating window shows up as a second `about:blank` page:

Terminal

```shell
# Chrome answers the share prompt itself, by the tab's title.
chrome --headless=new \
  --auto-select-tab-capture-source-by-title="Namecheap" \
  --remote-debugging-port=9222
```

### New in the next release

These came out of that integration and are in the package's source, not in 0.1.0 on npm yet.

- Open it from your own button. `PrufyGuide` takes a `ref` to the element, for `show()`, `close()` and `reset()`, and `noTrigger` (`no-trigger` in HTML) draws no button of its own:

Your own button

```javascript
import { PrufyGuide, type PrufyGuideElement } from "@prufy/connect/guide/react"
import { useRef } from "react"

export function Walkthrough({ domain }: { domain: string }) {
  const guide = useRef<PrufyGuideElement>(null)
  return (
    <>
      {/* show() runs inside the click, so the guide can float. */}
      <button type="button" onClick={() => guide.current?.show()}>
        Start walkthrough
      </button>
      <PrufyGuide ref={guide} noTrigger endpoint="/api/guide" domain={domain} />
    </>
  )
}
```

- Tell someone to wait. When your own check is cooling down or already running, `waitingOutcome` is the answer for `source.check`:

A check that has to wait

```javascript
import { waitingOutcome } from "@prufy/connect/server"

const source = {
  start,
  check: async (session) =>
    (await onCooldown(session))
      ? waitingOutcome({
          label: "Waiting on Prufy",
          headline: "We checked a moment ago",
          why: "Give it 10 seconds, then check again.",
        })
      : runTheCheck(session),
}
```

- An ended session says why. When your backend ends a session with a `rate_limited` error, the panel shows your message. Before, it always said the session ran out of screenshots.
- The simulation's sessions don't collide. `createFixtureGuide` gives every session a unique id, across instances. Its checks are still scripted, so it stays for demos and tests.

## Configure it

Every attribute is also a property, in camelCase. The ones you're most likely to set:

Attributes

```
<prufy-guide
  endpoint="/api/guide"
  domain="acme.com"
  auto-advance
  dock
></prufy-guide>
```

- auto-advance follows the shared tab: when it changes and settles, the guide looks again. Left out, each step waits for a reply. The options menu can switch it too, and fires `progressionchange` so your own control can follow.
- dock never floats. Use it when the page has room beside it, or for a preview.
- contained docks inside the nearest positioned ancestor instead of the window, the way the gallery above does.
- ticket is the record's token from the modal, so both show the same record. Left out, the backend issues a new one.

The full list is in the [reference](https://www.prufy.dev/docs/components/guide.md).

## The model loopExperimental

`createAiGuide`, from `@prufy/connect/guide/ai`, is the guide's backend on the AI SDK. It runs on a server only: no browser entry imports it, so `ai` never reaches a page. It needs a Vercel AI Gateway model and `ai` 7 or newer.

The model has two tools. `show_step` draws a step, and its schema can't carry a record value, a link or a delete. `check_dns` runs `source.check`, Prufy's real check. A turn ends as soon as a step is shown.

| Option | Type | Left out, it is | What it does |
| --- | --- | --- | --- |
| `source` | `GuideSource` | Required | Where sessions come from. start looks the domain up and phrases the record; check runs Prufy's real DNS check. |
| `model` | `LanguageModel \| string` | "google/gemini-3.8-flash" | A model, or an AI Gateway model string. |
| `fallbackModels` | `string[]` | "anthropic/claude-haiku-5.5", "openai/gpt-5.6-luna" | Tried in order when the model can't answer. |
| `zeroDataRetention` | `boolean` | true | Routes only to providers that keep nothing, because frames show someone's DNS account. Needs a paid AI Gateway plan or credits. |
| `limits` | `{ frames, minutes }` | 120 frames, 15 minutes | What one session may use before it ends. |
| `now` | `() => number` | Date.now | A clock, for the time limit. |
| `store` Experimental | `GuideSessionStore` | This process's memory | Where sessions live between requests. Pass a shared store on a host with several instances, such as serverless. From the release after 0.1.0. |
| `onServed` Experimental | `(served) => void` | None | Called once a turn with the model that actually answered, which can be a fallback. For logs; nothing from the screen is in it. |
| `trustTargets` Experimental | `(served) => boolean` | trustsGeminiTargets | Whether to keep a screenshot box from the model that answered. A dropped box keeps its written step. |
| `onTurn` Experimental | `(report) => void` | None | Called once a turn, when it ends or fails: the model that answered, whether a screenshot went with it, what became of its box, how long it took. For logs; nothing from the screen or the conversation is in it. From the release after 0.1.0. |
| `thinking` Experimental | `"low" \| "medium" \| "high"` | The model's own | How much the model reasons before it answers, where it supports the setting (Gemini 3 and later). Lower is faster. From the release after 0.1.0. |

## Screenshot hintsExperimental

Off by default. With `visual-hints`, a step can come with a close-up of the control it means, cut from the screenshot already taken for that turn. Show full tab zooms back out. The picture stays in the guide's window: it never goes into the conversation, an event or your server.

Turning it on

```
<!-- Experimental: off by default -->
<prufy-guide endpoint="/api/guide" domain="acme.com" visual-hints></prufy-guide>
```

- Only from a model the handler trusts. The model returns Gemini's native `box_2d`, and the server converts it. The default `trustTargets` keeps boxes from Gemini only. If AI Gateway falls back to another model, its box is dropped and its written step kept.
- Checked on made-up screens only. Gemini 3.8 Flash placed 8 of 8 boxes on synthetic provider forms. Real provider pages haven't been tried.
- Unsure means no picture. A missing or malformed box leaves the written step on its own.
- Allow data: images. Add `data:` to `img-src` on the page that hosts the guide. See [Content Security Policy](https://www.prufy.dev/docs/components/guide.md).

## Without the element

To draw the guide with your own components, use the same flow without its markup. `useGuide` runs the machine, the controller and the safety rules, and gives you the derived view. `createGuideController`, from `@prufy/connect/guide`, does the same outside React.

Your own markup

```javascript
import { createGuideHttpClient } from "@prufy/connect/guide"
import { useGuide } from "@prufy/connect/guide/react"

const client = createGuideHttpClient({ endpoint: "/api/guide" })

export function MyGuide() {
  const { view, controller } = useGuide(client, { target: { domain: "acme.com" } })
  // view: the status, the current stage and its replies. Draw them your way.
  // controller: open(), share() from a click, signedIn(), say(text), check(), close().
  return <YourPanel view={view} onShare={() => controller.share()} />
}
```

A floating window and a screen share can only start from a click, so call `controller.open()` and `controller.share()` from one.

## Reference

### prufy-guide

From `@prufy/connect/guide`. `client` and `screen` are properties only: a backend object in place of `endpoint`, and a screen to share in place of the browser's, for demos.

| Attribute | Type | What it does |
| --- | --- | --- |
| `visual-hints` Experimental | boolean | Opt into a local screenshot preview when the current step has a valid target. Off by default; only the current captured frame is shown. |
| `auto-advance` | boolean | Follow changes in the shared tab automatically. Left out, each step waits for Next or I did it. |
| `endpoint` | URL | Where the guide's handler is mounted. |
| `domain` | text | The domain being proved. |
| `ticket` | text | The record's token from the modal, so the guide shows the same record. Left out, a new one is issued. |
| `label` | text | The trigger's words. Guide me through it by default. |
| `no-trigger` | boolean | Draws no trigger. Open the guide from your own button with show(). From the release after 0.1.0. |
| `open` | boolean | Whether the guide is open. The element keeps it current. |
| `dock` | boolean | Never float: always dock beside the page, even where a floating window could open. |
| `contained` | boolean | Docks inside the nearest positioned ancestor, not the window. For previews. |
| `mode` | light \| dark | Picks the default colours. Left out, the element follows the page's color-scheme. |
| `theme` | JSON | The theme as an object. The same tokens as the modal. |

| Event | Detail | When |
| --- | --- | --- |
| `progressionchange` | `{ autoAdvance }` | Automatic progression changed. Keep the host's progression control in sync. |
| `verified` | `{ domain, provider, method: "guided" }` | Prufy's DNS check found the record. Never sent on the model's word. |
| `openchange` | `{ open }` | The guide opened or closed. |
| `phasechange` | `{ phase, state }` | The guide moved on: consent, sharing, signing in, watching, verified. |
| `declined` | `{}` | The person chose the steps instead. Show yours. |
| `copied` | `{ field, value }` | Someone copied the name or the value. |
| `previewchange` | `{ step, status }` | What became of a step's screenshot: highlighted, shown, blocked (the page's img-src doesn't allow data:), no_screen, not_pictured or off. For your logs. Experimental, with screenshot hints. From the release after 0.1.0. |

| Method | What it does |
| --- | --- |
| `show()` | Opens the guide. Call it from a click, so it can float. |
| `close()` | Closes it and stops sharing. The conversation stays. |
| `reset()` | Starts over with a new session. |

| Part | What it is |
| --- | --- |
| `trigger` | The button that opens the guide. |
| `panel` | The guide's box, floating or docked. |
| `header` | The title, domain and options button. |
| `title` | The guide's heading. |
| `hero` | The shared provider bridge for checking DNS and verified ownership. |
| `status` | The visible footer badge naming what the guide is doing. |
| `options` | The ellipsis button for the guide's secondary controls. |
| `close` | Close the guide, in its options menu. |
| `record` | The full DNS record, shown on request from the options menu. |
| `copy-button` | A copy button, inside its instruction or the record sheet. |
| `step` | One step from the guide. |
| `preview` Experimental | The current step's transient screenshot preview. |
| `preview-target` Experimental | The outline around the suggested control in the screenshot. |
| `preview-toggle` Experimental | Switches between the focused target and the full shared tab. |
| `latest` | The button back to the newest step. |
| `replies` | The row of quick replies. |
| `reply` | One quick reply. |
| `input` | The question field, revealed by Not sure. |
| `button` | Every button on a card. |
| `primary` | The main button of a card. It is also a button. |
| `quiet` | The secondary buttons. Each is also a button. |

| Slot | What goes in it |
| --- | --- |
| `trigger` | Your own button, in place of ours. |

## What isn't here yet

- A hosted guide page. Prufy doesn't serve one yet, so the modal's `…/guide` has nothing to point at in production.
- Screenshot hints on real pages. They were checked on made-up screens only.
- Safari and Firefox. It has only been checked in Chrome.
- Other languages. The guide's own words are English.

---

Every page of these docs, as a list: https://www.prufy.dev/llms.txt
