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.
| Element | What it is |
|---|---|
prufy-connect | A button, and the modal it opens. This is the whole flow. |
prufy-dns-record | One DNS record, laid out the way a provider's form asks for it, with copy buttons. |
prufy-status | A 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.
No request leaves this page. It doesn't call Prufy or look anything up in DNS.
Waiting for the verified event
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>import { PrufyConnect } from "@prufy/connect/react"
export function Domains() {
return (
<PrufyConnect
appName="Acme"
endpoint="/api/connect"
theme={{ accent: "#4f46e5", radius: 8 }}
onVerified={({ domain }) => saveDomain(domain)}
/>
)
}<script setup>
import "@prufy/connect"
</script>
<template>
<prufy-connect
app-name="Acme"
endpoint="/api/connect"
@verified="saveDomain($event.detail.domain)"
/>
</template><script>
import "@prufy/connect"
</script>
<prufy-connect
app-name="Acme"
endpoint="/api/connect"
onverified={(event) => saveDomain(event.detail.domain)}
></prufy-connect>// app/api/connect/[action]/route.ts
import { createConnectHandler } from "@prufy/connect/server"
import { backend } from "@/lib/connect-backend"
const handler = createConnectHandler(backend)
export { handler as GET, handler as POST }
// app/settings/domains/page.tsx, a server component
import { PrufyConnect } from "@prufy/connect/react"
export default function Domains() {
return <PrufyConnect appName="Acme" endpoint="/api/connect" />
}| Framework | What it needs |
|---|---|
| Plain HTML, Svelte | Nothing. Use the tag. |
| Vue | One compiler option, isCustomElement, so Vue doesn't look for a Vue component with that name. |
| React, Next.js | The 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.
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.
| Request | What it does |
|---|---|
GET…/providers | The provider marks shown on the first step. |
POST…/detect | Finds who manages the domain's DNS, and issues the record. |
POST…/check | Looks the record up in DNS. |
POST…/consentNot available | The provider's signed address, for one click. No provider offers it yet. |
POST…/guideExperimental | The address of Prufy's guide page, for guided setup. Only when your backend offers it. |
GET…/return | The 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.
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",
}}
/>prufy-connect {
color-scheme: dark;
}document.querySelector("prufy-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.
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.
| Token | Styles | Left out, it is |
|---|---|---|
--prufy-accent | Fill of the main button. | The text colour |
--prufy-accent-foreground | Text on the accent. | Black or white, whichever reads better on your accent |
--prufy-background | The modal's background. | White, or near black in dark |
--prufy-foreground | Text. | Near black, or near white in dark |
--prufy-muted | Secondary text. | Mixed from text and background |
--prufy-border | Lines and outlines. | Mixed from text and background |
--prufy-surface | Fill of the field, the tiles and quiet hover states. | Mixed from text and background |
--prufy-focus | The focus ring. | Your accent, moved far enough from the page to be seen |
--prufy-success | Verified. | Green |
--prufy-warning | Waiting. | Amber |
--prufy-danger | Needs a fix. | Red |
--prufy-radius | Corners of buttons and the field. Boxes with several lines stop at 16px. | 12px |
--prufy-font | The body font. | The system's sans-serif |
--prufy-font-heading | The font of headings. | The body font |
--prufy-font-mono | The font of record values. | The system's monospace |
--prufy-overlay | The scrim behind the modal. | A dark wash |
--prufy-shadow | The 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.
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.
prufy-connect::part(primary) {
text-transform: uppercase;
letter-spacing: 0.04em;
}
prufy-connect::part(modal) {
box-shadow: 6px 6px 0 0 currentColor;
}| Part | What it is |
|---|---|
trigger | The button that opens the modal. |
overlay | The layer the modal sits in. |
backdrop | The scrim behind the modal. |
modal | The modal's box. |
header | The row with the progress marks and the close button. |
close | The close button. |
hero | Your logo and the provider's, with the link between them. |
title | Each step's heading. |
text | Each step's paragraphs. |
input | The domain field. |
button | Every button in a step. |
primary | The main button of a step. It is also a button. |
quiet | The secondary buttons. Each is also a button. |
status | The status label above a heading. |
record | The record's box. |
record-row | One row of the record. |
copy-button | A 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.
<prufy-connect app-name="Acme" endpoint="/api/connect">
<button slot="trigger" class="your-own-button">Add a domain</button>
</prufy-connect>| Slot | What goes in it |
|---|---|
trigger | Your own button, in place of ours. Any element, with your own classes. |
logo | Your own logo, for one that changes between light and dark. |
footer | A 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: 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.
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.
| Attribute | Type | What it does |
|---|---|---|
app-name | text | Your app's name, used in the modal's own sentences. |
logo | URL | A square logo. Without one, your app's initial is shown. |
mode | light | dark | Picks the default colours. Left out, the element follows the page's color-scheme. |
provider-logos | color | mono | DNS provider marks in their own colours, or in the text colour for a quieter look. |
domain | text | Fills in the domain field to start with. |
endpoint | URL | Where your server mounts the handler. |
open | boolean | Whether the modal is open. The element keeps it current. |
contained | boolean | Opens inside the nearest positioned ancestor, not over the page. For previews. |
theme | JSON | The theme as an object. Wins over the CSS variables. |
copy | JSON | Your own words for the trigger, the first heading and line, the last heading and its button. |
| Event | Detail | When |
|---|---|---|
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. |
| Method | What 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.
| Attribute | Type | What it does |
|---|---|---|
host | text | What to type in the provider's name field. |
value | text | What to type in its value field. |
type | text | The record type. TXT unless you say otherwise. |
host-label | text | What the provider calls the name field. Name by default. |
value-label | text | What the provider calls the value field. Value by default. |
highlight | host | value | Marks the field a fix is about. |
theme | JSON | The theme as an object. |
| Part | What it is |
|---|---|
record | The record's box. |
row | One row. |
copy-button | A copy button. |
prufy-status
The label is the element's own content, so status is never colour alone.
| Attribute | Type | What it does |
|---|---|---|
tone | success | warning | danger | neutral | Picks the icon and colour. The words are yours. |
live | boolean | Announces a change to a screen reader. For a status that updates, not a list drawn once. |
theme | JSON | The theme as an object. |
| Part | What it is |
|---|---|
badge | The 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/connect0.1.0 is published asUNLICENSEDuntil 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.