Managing children
List a parent's children and let them manage permissions, preferences, screen time, purchases and activity in your app.
Once a child is approved, the parent can manage them from your app, as they would on the Family Portal.
Drop-in management
import { KidChildList, KidChildManagement, KidChildProvider } from '@k-id/family-react'
{kuid === null ? (
<KidChildList onSelect={setKuid} onAddChild={openSetup} />
) : (
<KidChildProvider kuid={kuid}>
<KidChildManagement onAccessRemoved={() => setKuid(null)} onExit={() => setKuid(null)} />
</KidChildProvider>
)}KidChildListlists the parent's children who use your product.onSelectgets the picked child'skuid. WithonAddChild, it shows the add-child tile.KidChildManagementis the Family Portal's management view. Its tabs appear only when your product offers them. For akuidthe signed-in parent doesn't manage, it shows a not-found screen, with a Back button that callsonExitwhen you pass one.- Removing access. The ⋯ menu offers Revoke access or Unlink account, whichever applies to that child. After either, the child drops out of your list and
onAccessRemovedfires.
Tabs
| Tab | Widget | Hook | The parent can |
|---|---|---|---|
| Permissions | KidManagePermissions | useKidManagePermissions | Turn the permissions they're allowed to decide on or off. |
| Preferences | KidManagePreferences | useKidManagePreferences | Set or remove your product's preferences (numbers and choices). |
| Screen time | KidManageScreentimeControls | useKidManageScreentimeControls | Set daily limits, quiet hours and break reminders, and grant or deny the child's requests for extra time. See Screen time. |
| Purchases | KidManageTransactionControls | useKidManageTransactionControls | Approve or deny pending purchases and see past ones. See Transactions. |
| Activity | KidManageActivity | useKidManageActivity | See weekly activity and screen-time totals, and choose how often they get the activity email. See Activity ingestion. |
To place the tabs yourself, put any of these widgets, plus KidRevokeAccess and KidUnlinkAccount, inside a <KidChildProvider kuid={kuid}>.
Hooks for your own management UI
Each area hook has available (false while loading, and when your product doesn't offer that area), isLoaded, error and refresh(), plus its own data and actions:
| Hook | Data | Actions |
|---|---|---|
useKidManageChildren() | children (each with kuid, name, avatarIndex, features and access), atChildLimit | refresh() |
useKidChildManagement() | child, productName | saveSettings({ permissions, preferences }), revokeAccess(), unlinkAccount() |
useKidManagePermissions() | permissions | Save through saveSettings |
useKidManagePreferences() | preferences, allowances (what each preference is and the values it takes) | Save through saveSettings |
useKidManageScreentimeControls() | schedule, pendingOverrides | saveSchedule(schedule), grantOverride(requestId, minutes), denyOverride(requestId) |
useKidManageTransactionControls() | pending, ledger | approve(requestId), deny(requestId) |
useKidManageActivity() | digestCadence | summary(range), screentime(range), saveDigestCadence('weekly' | 'never') |
child.features lists the areas your product offers for that child. A hook's error is for a failed load. Every action reports its own failure in the result it returns, { ok: true } or { ok: false, error }, so check each one (see Results and errors).
import { useState } from 'react'
import { useKidManageTransactionControls, useKidStrings } from '@k-id/family-react'
import { formatAmount } from '@k-id/family-react/rules'
function PendingPurchases() {
const { available, pending, approve, deny } = useKidManageTransactionControls()
const strings = useKidStrings()
const [message, setMessage] = useState<string | null>(null)
if (!available) return null
const decide = async (action: typeof approve, requestId: string) => {
const result = await action(requestId)
setMessage(result.ok ? null : strings.errors[result.error.code])
}
return (
<>
{message && <p role="alert">{message}</p>}
{pending.map((purchase) => (
<div key={purchase.requestId}>
{purchase.title} {formatAmount(purchase.amount, purchase.currency)}
<button onClick={() => decide(approve, purchase.requestId)}>Approve</button>
<button onClick={() => decide(deny, purchase.requestId)}>Deny</button>
</div>
))}
</>
)
}