Approving a child
Run the consent setup with KidChildSetup, track its status, confirm the result on your backend, and build your own setup screens.
The consent setup is how a parent approves a child for your product. It runs the Family Portal's steps inside your app and writes the consent to k-ID.
Opening a setup
Every child flow sits inside a <KidChildProvider>. How you open it decides the entry:
import { KidChildProvider, KidChildSetup } from '@k-id/family-react'
// A parent starting from your app: they pick one of their children or add a new one.
<KidChildProvider>
<KidChildSetup onComplete={(result) => {}} onExit={() => {}} onDone={() => {}} />
</KidChildProvider>
// A specific child the parent already manages (for example to finish an abandoned setup).
<KidChildProvider kuid={kuid}>...</KidChildProvider>
// The token from a k-ID email link (KidFamilyRouter does this for you).
<KidChildProvider token={token}>...</KidChildProvider>Pass at most one of kuid and token. jurisdiction on KidChildProvider overrides the provider's default; an email link carries its own. For email links, use KidFamilyRouter rather than reading the token yourself.
What the setup does
<KidChildSetup> runs the Family Portal's steps in order: overview, child, disclosures, permissions, preferences and screen time, the parent's verification, and the completion screen. The steps shown depend on your product's configuration and the child's jurisdiction.
A child who is already approved for your product finishes straight away, and onComplete still fires. If your product approves other products with it, the setup covers them all. See Multi-product approval.
| Callback | When |
|---|---|
onComplete(result) | The child is consented, by this setup or because they already were. result is { ok: true, kuid, claimToken? }. |
onExit() | The parent left without finishing, after the request is dismissed. |
onDone() | The completion screen's Done button. The button is shown only when you pass this. |
onManageChildren() | The completion screen's follow-up to your management view. |
Setup status
useKidChildSetup().status tells you where the setup is:
| Status | Meaning |
|---|---|
loading | The setup is starting. |
child_required | The parent picks one of their children or adds one. |
consent_required | The parent is reviewing and approving. |
consented | The child is approved. |
prohibited | The child is below your product's minimum age. |
already_completed | The email link's request was already answered. |
invite_cancelled | The invite in the email link was cancelled. |
expired | The email link expired or is not valid. No retry can open it. |
<KidChildSetup> shows the Family Portal's page for each of these.
When an email link opens the setup, already_completed, invite_cancelled and expired are statuses, not errors: error stays null.
useKidChildSetup().request.type says what an email link is for: 'consent', 'jurisdiction_update' or 'upgrade'. Declining an upgrade calls onExit and leaves the request pending.
Confirming the result on your backend
When the parent started the setup from your app, the result carries a claimToken. Your backend exchanges it with k-ID for the child's sessionId by calling /client/claim with your secret API key, rather than trusting the kuid the browser reports.
sessionId is a k-ID session like any other approval's. Read it with the usual session APIs.
- A claim token can be redeemed once. Treat it as opaque; its format can change.
- A setup opened from a k-ID email link has no
claimToken. It answers your product's own challenge, whose result you read through the challenge's status or theChallenge.StateChangewebhook.
Never trust the browser's kuid
Anyone can call your backend with a kuid of their choosing. Unlock features only for a session your backend got from /client/claim, a challenge result, or a webhook.
Building your own setup screens
Each step is also a widget you can place yourself, inside the same KidChildProvider, in your own layout:
| Step | Widget |
|---|---|
| Overview | KidSetupOverview |
| Child | KidSetChild |
| Disclosures | KidAcceptDisclosures |
| Permissions | KidSetPermissions |
| Preferences and screen time | KidSetAllowances, or KidSetPreferences and KidSetScreentimeControls separately |
| Parent's verification | KidVerifyAge (see Parent verification) |
| Completion | KidSetupComplete |
For a fully custom UI, useKidChildSetup() holds the same state the widgets use:
| Field | For |
|---|---|
status, isLoaded, entry, kuid, error | Where the setup is, how it was opened ('new', 'kuid' or 'token'), and the last failure. |
children, canAddChild, atChildLimit, prefill, addChild(input), selectChild(kuid) | The child step. Each child has selectable and, when it can't be picked, unselectableReason. |
steps, products, setProductRemoved(id, removed) | The steps this setup walks, and the products it approves. |
legalDocuments, dataNotices, acceptAll(), setDisclosureAccepted(id, accepted) | The disclosures step. |
permissions, decisions, setPermission(name, enabled) | The permissions step. |
offeredAllowances, allowances, setAllowances(update) | Preferences and screen time. |
verification | The parent's age check: required, verified, methods, start(method) and handleMessage(event). |
canSubmit, issues, submit(), submitting | Approving. issues says why canSubmit is false. |
import { useKidChildSetup } from '@k-id/family-react'
function ApproveButton() {
const setup = useKidChildSetup()
return (
<button disabled={!setup.canSubmit || setup.submitting} onClick={() => setup.submit()}>
Approve
</button>
)
}Preferences and screen time are seeded from your product's defaults and sent on approval even if you never show them. @k-id/family-react/rules exports the Family Portal's own checks, validateChildInput, validateAllowances and validateSchedule, for your own forms.