Parent verification
How the parent verifies their age during the setup, and how to narrow, reorder or frame the verification methods yourself.
When the consent requires it, the parent verifies their age inside a k-ID page that the SDK frames. The list of methods comes from k-ID and depends on your product's settings, the jurisdiction and the parent's device. You can narrow and reorder it, but never add to it:
import { KidVerifyAge } from '@k-id/family-react'
import { VerificationMethodTypes } from '@k-id/family-react/rules'
<KidVerifyAge methods={[VerificationMethodTypes.CreditCard, VerificationMethodTypes.AgeKey]} />VerificationMethodTypes lists every method k-ID has, for example CreditCard, IDDocument, AgeEstimation, AgeKey and EmailConfirmation. See Verification methods for what each one is.
- A method k-ID doesn't offer the parent is never shown, whatever you pass. If none of yours match, the step shows no methods.
<KidChildSetup>has nomethodsprop. To narrow the list, lay the steps out yourself and pick fromuseKidChildSetup().verification.methods.KidVerifyAgerenders nothing when the setup doesn't need verification, or once the parent has passed it.
Framing the verification yourself
To show the verification in your own frame, call useKidChildSetup().verification.start(method) for its URL, show it in an iframe with allow={VERIFY_IFRAME_ALLOW} (from @k-id/family-react/rules), and hand each message event from that iframe to verification.handleMessage(event), after checking it came from your iframe.
verification.methods lists the methods k-ID offers this parent on this device, in order, once verification.methodsLoaded is true. When verification.outcome isn't 'methods', there's no list to choose from: call start() with no method. If the methods couldn't be read, methodsError is set; call refreshMethods() to retry, and again after a method fails, so attempts and fallback methods update.
import { useEffect, useRef, useState } from 'react'
import { useKidChildSetup, useKidStrings } from '@k-id/family-react'
import { VERIFY_IFRAME_ALLOW } from '@k-id/family-react/rules'
function VerifyFrame({ method }: { method?: string }) {
const { status, verification } = useKidChildSetup()
const frame = useRef<HTMLIFrameElement>(null)
const strings = useKidStrings()
const [url, setUrl] = useState<string | null>(null)
const [message, setMessage] = useState<string | null>(null)
const [attempt, setAttempt] = useState(0)
const started = useRef<{ key: string; result: ReturnType<typeof verification.start> } | null>(null)
useEffect(() => {
if (status !== 'consent_required') return
let current = true
setUrl(null)
setMessage(null)
const key = `${method ?? ''}:${attempt}`
if (started.current?.key !== key) {
started.current = { key, result: verification.start(method) }
}
void started.current.result.then((result) => {
if (!current) return
if (result.ok) setUrl(result.url)
else setMessage(strings.errors[result.error.code])
})
return () => {
current = false
}
}, [status, method, attempt])
useEffect(() => {
const onMessage = (event: MessageEvent) => {
if (event.source !== frame.current?.contentWindow) return
verification.handleMessage(event)
if (event.data?.eventType === 'Verification.Error') void verification.refreshMethods()
}
window.addEventListener('message', onMessage)
return () => window.removeEventListener('message', onMessage)
}, [verification])
if (message) {
return (
<div role="alert">
<p>{message}</p>
<button onClick={() => setAttempt((count) => count + 1)}>Try again</button>
</div>
)
}
return url && <iframe ref={frame} src={url} allow={VERIFY_IFRAME_ALLOW} title="Verify your age" />
}<KidChildProvider> keeps its children mounted when its kuid or token changes, so give the frame a key from them, for example <VerifyFrame key={kuid ?? token} method={method} />. Otherwise it keeps the previous child's URL.
The frame needs your baseUrl origin in your Content-Security-Policy's frame-src. The appearance settings don't apply inside the k-ID verification page itself.