Family SDK

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>
)}
  • KidChildList lists the parent's children who use your product. onSelect gets the picked child's kuid. With onAddChild, it shows the add-child tile.
  • KidChildManagement is the Family Portal's management view. Its tabs appear only when your product offers them. For a kuid the signed-in parent doesn't manage, it shows a not-found screen, with a Back button that calls onExit when 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 onAccessRemoved fires.

Tabs

TabWidgetHookThe parent can
PermissionsKidManagePermissionsuseKidManagePermissionsTurn the permissions they're allowed to decide on or off.
PreferencesKidManagePreferencesuseKidManagePreferencesSet or remove your product's preferences (numbers and choices).
Screen timeKidManageScreentimeControlsuseKidManageScreentimeControlsSet daily limits, quiet hours and break reminders, and grant or deny the child's requests for extra time. See Screen time.
PurchasesKidManageTransactionControlsuseKidManageTransactionControlsApprove or deny pending purchases and see past ones. See Transactions.
ActivityKidManageActivityuseKidManageActivitySee 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:

HookDataActions
useKidManageChildren()children (each with kuid, name, avatarIndex, features and access), atChildLimitrefresh()
useKidChildManagement()child, productNamesaveSettings({ permissions, preferences }), revokeAccess(), unlinkAccount()
useKidManagePermissions()permissionsSave through saveSettings
useKidManagePreferences()preferences, allowances (what each preference is and the values it takes)Save through saveSettings
useKidManageScreentimeControls()schedule, pendingOverridessaveSchedule(schedule), grantOverride(requestId, minutes), denyOverride(requestId)
useKidManageTransactionControls()pending, ledgerapprove(requestId), deny(requestId)
useKidManageActivity()digestCadencesummary(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>
      ))}
    </>
  )
}

On this page