prufy
Skip to the page

ComponentsConnect modal

Components

Connect modal

A button and a modal that walk someone through proving a domain, inside your own product. It is a web component, so plain HTML, React, Vue, Svelte and Next.js all use the same tag.

On this page

Where this stands

The modal has two ways to add the record. By hand shows the record in your DNS provider's own words and checks DNS when it's added. That path is complete. One click lets the provider add the record for you, through Domain Connect. Each provider has to switch that on for Prufy first, and none has, so one click is not available: the modal offers it only when your backend says a provider can, and no real backend can say so yet.

ElementWhat it is
prufy-connectA button, and the modal it opens. This is the whole flow.
prufy-dns-recordOne DNS record, laid out the way a provider's form asks for it, with copy buttons.
prufy-statusA status badge. The label is the element's own text, so it reads with no CSS at all.

Try it

This is the real component with a stand-in for its backend. Type any domain: nothing is sent anywhere, and the record it shows is a sample. Change the look or where the DNS is, and the modal follows.

Simulated

No request leaves this page. It doesn't call Prufy or look anything up in DNS.

Waiting for the verified event

Accent
Corners
Page
DNS is at
First check
What the look above comes to
prufy-connect {
  color-scheme: dark;
  --prufy-radius: 12px;
}

Use it

One tag, the same in every framework. It needs two things from you: your app's name, and where its backend is.

If you haven't installed @prufy/connect yet, start with Installation.

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

<prufy-connect app-name="Acme" endpoint="/api/connect"></prufy-connect>

<script type="module">
  document.querySelector("prufy-connect").addEventListener("verified", (event) => {
    saveDomain(event.detail.domain)
  })
</script>
FrameworkWhat it needs
Plain HTML, SvelteNothing. Use the tag.
VueOne compiler option, isCustomElement, so Vue doesn't look for a Vue component with that name.
React, Next.jsThe components in @prufy/connect/react. They pass props as properties, turn events into callbacks and render on a server.

When DNS shows the record, the element fires verified with the domain. That is the moment to save it. Treat it as a hint and confirm on your server before you rely on it: a browser event can be made up.

Give it a backend

The modal can't call Prufy from your user's browser. Prufy's session cookie is kept away from other sites (see Authentication), so your server makes the calls and the modal talks to your server. The handler takes a Request and returns a Response, so it mounts in Next.js, SvelteKit, Hono, Bun or a Worker.

app/api/connect/[action]/route.ts
import { createConnectHandler } from "@prufy/connect/server"

// Two functions. Each one calls Prufy from your server, with your user's session.
// One click would add a third, consent, but no DNS provider offers it yet.
const handler = createConnectHandler({
  detect: (domain) => findProviderAndRecord(domain),
  check: ({ domain, ticket }) => lookUpTheRecord(domain, ticket),
})

export { handler as GET, handler as POST }

The last part of the path picks the action, so the handler works wherever you mount it. Point the element at that address with endpoint.

RequestWhat it does
GET…/providersThe provider marks shown on the first step.
POST…/detectFinds who manages the domain's DNS, and issues the record.
POST…/checkLooks the record up in DNS.
POST…/consentNot availableThe provider's signed address, for one click. No provider offers it yet.
POST…/guideExperimentalThe address of Prufy's guide page, for guided setup. Only when your backend offers it.
GET…/returnThe page a provider sends the person back to.

detect answers with the provider, the record phrased for that provider's form, and a ticket the modal sends back with every later call. check answers verified, or one finding: a headline, why, and at most one fix. The modal shows your words as they are, so a failure reads the same here as in the rest of Prufy. What each failure means has the full list.

Make it yours

Pick a theme to see the modal wear it, switch between light and dark, or edit the accent, corners and font. The code under it is exactly what the preview is wearing. The guide takes the same tokens: its page has the same gallery.

Simulated

Example themes

Styled after well-known brands. Not made or endorsed by them.

Default, dark: No theme at all. The tokens' own fallbacks.

import { PrufyConnect } from "@prufy/connect/react"

<PrufyConnect
  appName="Acme"
  endpoint="/api/connect"
  theme={{
    mode: "dark",
  }}
/>

The theme is CSS custom properties. Set them in your own stylesheet, on the element or anything above it, with any value CSS accepts, including your own variables.

Your stylesheet
prufy-connect {
  --prufy-accent: var(--brand);
  --prufy-radius: 8px;
  --prufy-font: var(--font-sans);
}

You only have to pick what you care about. The rest is worked out from it: the text on your accent is black or white, whichever reads better, and the focus ring is your accent moved far enough from the page to be seen. Light or dark follows the page's color-scheme, or the mode attribute.

TokenStylesLeft out, it is
--prufy-accentFill of the main button.The text colour
--prufy-accent-foregroundText on the accent.Black or white, whichever reads better on your accent
--prufy-backgroundThe modal's background.White, or near black in dark
--prufy-foregroundText.Near black, or near white in dark
--prufy-mutedSecondary text.Mixed from text and background
--prufy-borderLines and outlines.Mixed from text and background
--prufy-surfaceFill of the field, the tiles and quiet hover states.Mixed from text and background
--prufy-focusThe focus ring.Your accent, moved far enough from the page to be seen
--prufy-successVerified.Green
--prufy-warningWaiting.Amber
--prufy-dangerNeeds a fix.Red
--prufy-radiusCorners of buttons and the field. Boxes with several lines stop at 16px.12px
--prufy-fontThe body font.The system's sans-serif
--prufy-font-headingThe font of headings.The body font
--prufy-font-monoThe font of record values.The system's monospace
--prufy-overlayThe scrim behind the modal.A dark wash
--prufy-shadowThe modal's shadow.A soft drop shadow

As an object

The same tokens can be passed as one object, for an app that keeps its brand in JavaScript. The keys are the token names in camelCase, and radius can be a number of pixels. When both are set, the object wins.

The theme property
document.querySelector("prufy-connect").theme = {
  mode: "dark",
  accent: "#4f46e5",
  radius: 8,
}

Parts and slots

The modal draws inside a shadow root, so your page's CSS can't reach into it by accident, and its CSS can't leak out. That is also why there are no class names to override. For what a token can't say, style a named part.

Your stylesheet
prufy-connect::part(primary) {
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

prufy-connect::part(modal) {
  box-shadow: 6px 6px 0 0 currentColor;
}
PartWhat it is
triggerThe button that opens the modal.
overlayThe layer the modal sits in.
backdropThe scrim behind the modal.
modalThe modal's box.
headerThe row with the progress marks and the close button.
closeThe close button.
heroYour logo and the provider's, with the link between them.
titleEach step's heading.
textEach step's paragraphs.
inputThe domain field.
buttonEvery button in a step.
primaryThe main button of a step. It is also a button.
quietThe secondary buttons. Each is also a button.
statusThe status label above a heading.
recordThe record's box.
record-rowOne row of the record.
copy-buttonA copy button in the record.

To use your own button, put it in the trigger slot. It stays in your page, so it keeps your classes and your design system's styles.

Your own trigger
<prufy-connect app-name="Acme" endpoint="/api/connect">
  <button slot="trigger" class="your-own-button">Add a domain</button>
</prufy-connect>
SlotWhat goes in it
triggerYour own button, in place of ours. Any element, with your own classes.
logoYour own logo, for one that changes between light and dark.
footerA line under the first step, such as a link to your terms.

With Tailwind and shadcn/ui

Utility classes can't cross into the modal either. Two things do the job: an arbitrary variant to reach a part, and pointing the tokens at the variables you already have.

Tailwind and shadcn/ui
<!-- Tailwind: an arbitrary variant reaches a part -->
<prufy-connect class="[&::part(primary)]:uppercase"></prufy-connect>

<!-- shadcn/ui: point the tokens at yours -->
<style>
  prufy-connect {
    --prufy-accent: var(--primary);
    --prufy-accent-foreground: var(--primary-foreground);
    --prufy-background: var(--background);
    --prufy-foreground: var(--foreground);
    --prufy-border: var(--border);
    --prufy-radius: var(--radius);
  }
</style>

One clickNot available

No DNS provider has switched Prufy on yet, so no real backend can offer this. The modal shows it only when your backend's detect answers oneClick: true and your handler has consent. Leave both out and the modal goes straight to adding the record by hand. What follows is built and tested against a stand-in provider.

Where a provider has switched Prufy on, the modal offers to let it add the record. The provider's page opens in a window of its own. Your app never sees it, can't restyle it, and never sees a password.

  • If the browser blocks the window, the modal shows a link to the same page instead.

  • If the window closes without an answer, the modal doesn't guess. It offers a DNS check, in case the record was approved.

  • If the person approves, that only starts a check. Coming back from a provider proves nothing. DNS decides, the same as for a record added by hand.

Your handler answers the provider's return at …/return. It needs no code from you.

Guided setupExperimental

For someone who has never touched DNS, the modal can offer a guide after the steps, never before them: Guide me through it. Prufy's guide opens in its own window, the person shares the tab with their DNS provider, and an AI says where to click, one step at a time. When it's done, the modal checks DNS itself.

The guide runs on Prufy's own site, not in your page, so your backend only answers …/guide with the guide page's address. The modal offers it only where the browser can share a tab, and only when detect said guided: true. Prufy doesn't host the guide page yet, so no production backend can say that today.

The guide has its own page: Guided setup, with what it can and can't do, how to configure it, its experimental parts and its themes.

Render it on a server

The React components render on a server as they are, in a server component or a client one. For anything else, three functions return each element as HTML with its shadow root already inside, so the button is drawn and styled before any JavaScript loads.

Any server
import { renderConnect, renderDnsRecord, renderStatus } from "@prufy/connect/server"

const html = `
  ${renderConnect({ appName: "Acme", endpoint: "/api/connect", theme: { accent: "#4f46e5" } })}
  ${renderStatus({ tone: "success", label: "Verified" })}
  ${renderDnsRecord({ host: "_prufy-challenge", value: "prufy-domain-verification=…" })}
`

Only what is on screen before a click is rendered: the trigger, a record, a badge. The modal itself only exists in the browser.

Reference

prufy-connect

Every attribute is also a property, in camelCase. client is a property only: an object with detect and check, to use in place of endpoint.

AttributeTypeWhat it does
app-nametextYour app's name, used in the modal's own sentences.
logoURLA square logo. Without one, your app's initial is shown.
modelight | darkPicks the default colours. Left out, the element follows the page's color-scheme.
provider-logoscolor | monoDNS provider marks in their own colours, or in the text colour for a quieter look.
domaintextFills in the domain field to start with.
endpointURLWhere your server mounts the handler.
openbooleanWhether the modal is open. The element keeps it current.
containedbooleanOpens inside the nearest positioned ancestor, not over the page. For previews.
themeJSONThe theme as an object. Wins over the CSS variables.
copyJSONYour own words for the trigger, the first heading and line, the last heading and its button.
EventDetailWhen
verified{ domain, provider, method }DNS shows the record. This is the one to save the domain on.
openchange{ open }The modal opened or closed.
stepchange{ step, state }The flow moved to another step.
MethodWhat it does
show()Opens the modal.
close()Closes it. The flow stays where it was.
reset()Goes back to the first step.

prufy-dns-record

Fires copied with { field, value } when someone copies a field.

AttributeTypeWhat it does
hosttextWhat to type in the provider's name field.
valuetextWhat to type in its value field.
typetextThe record type. TXT unless you say otherwise.
host-labeltextWhat the provider calls the name field. Name by default.
value-labeltextWhat the provider calls the value field. Value by default.
highlighthost | valueMarks the field a fix is about.
themeJSONThe theme as an object.
PartWhat it is
recordThe record's box.
rowOne row.
copy-buttonA copy button.

prufy-status

The label is the element's own content, so status is never colour alone.

AttributeTypeWhat it does
tonesuccess | warning | danger | neutralPicks the icon and colour. The words are yours.
livebooleanAnnounces a change to a screen reader. For a status that updates, not a list drawn once.
themeJSONThe theme as an object.
PartWhat it is
badgeThe badge.

prufy-guide has its own reference, on Guided setup.

What isn't here yet

  • A finished page. These docs are under development and will change with the component.

  • A licence. @prufy/connect 0.1.0 is published as UNLICENSED until one is chosen.

  • A ready-made backend. The handler is built. The three functions that call Prufy for you aren't, so today you write them against the API.

  • One click, for real. No DNS provider has switched Prufy on. The window, the blocked case and the way back are built and tested against a stand-in provider.

  • Guided setup on prufy.dev. The guide, its handler and the modal's side are built and tested on a simulation. The experiment it grew from ran a full session in Chrome. Prufy doesn't host the guide page yet, so no backend can offer it.

  • Screenshot hints on real pages. They were checked on made-up provider screens only.

  • Other languages. Five lines of the modal can be reworded with copy. The rest is English.

  • Safari and Firefox. It has only been checked in Chrome.