Family SDK

Quickstart

Configure your product, install the Family SDK, and approve your first child from your own app.

This guide takes you from an empty app to a parent approving a child, with the result confirmed on your backend. Steps 1 and 5 are the same on every platform; the code in steps 2 to 4 uses the React SDK, @k-id/family-react.

1. Configure your product in Compliance Studio

Check that the Family SDK is available to your organization. Please contact k-ID to have this capability enabled for your organization.

Open your product in Compliance Studio, then Developer.

SettingWhat it isRequired
Publishable KeysA browser-safe key: kgp_test_... for test mode, kgp_live_... for live.Yes
DomainsThe origins allowed to use your publishable keys, for example https://www.acme.com. Any other origin is refused. Test and live mode each have one list, shared by every key in that mode. Add http://localhost:<port> in test mode for local development.Yes
API keyYour secret key, for your backend only. It confirms a setup's result with k-ID (step 5). Never put it in the browser.Yes
Family SDK > Redirect URLThe page in your app that k-ID's parent emails link to. It must be on one of the domains for that mode. If it's unset, emails link to the k-ID Family Portal instead.Recommended

See Developer settings for creating and protecting your secret API key.

Live keys need your own subdomain

A live key only works through a host on your domain, for example family.acme.com, on the same registrable domain as the pages that use the SDK. If your app runs on more than one domain, each needs its own host on that domain. Ask k-ID for the CNAME target for that host, point the host at it, and k-ID registers it for your product. The parent's session is kept in a secure cookie on that host.

Test keys use k-ID's shared test host, https://family.test.k-id.com, and need no DNS.

2. Install the SDK

npm install @k-id/family-react

Peer dependencies: react and react-dom, version 18 or 19. The bundle is ESM.

Entry pointContents
@k-id/family-reactProviders, widgets, hooks and types
@k-id/family-react/localizationsen and 22 other locales, getKidLocalization, and the KidStrings type
@k-id/family-react/rulesConstants and helpers: verification method types, step and tab order, child input rules, avatar indices, screen-time and purchase formatting
@k-id/family-react/assetsThe Family Portal's avatars and icons, loaded on demand (see Customization)

Next.js

The main entry carries a 'use client' directive, so the widgets render from App Router server components. A widget you pass a callback prop (such as onComplete) must render from your own 'use client' component, as a server component can't pass functions. The types need @types/react-dom installed. @k-id/family-react/rules has no directive and imports no React, so server code can use it too.

3. Wrap your app

import type { ReactNode } from 'react'
import { KidFamilyProvider } from '@k-id/family-react'

export function App({ children }: { children: ReactNode }) {
  return (
    <KidFamilyProvider
      publishableKey="kgp_test_..."
      baseUrl="https://family.test.k-id.com" // live: the subdomain you CNAME to k-ID
    >
      {children}
    </KidFamilyProvider>
  )
}

Every other component and hook must be inside KidFamilyProvider.

PropNotes
publishableKeyFrom Compliance Studio. Safe to ship in the browser.
baseUrlThe k-ID address the SDK calls: https://family.test.k-id.com for a test key, your own subdomain from step 1 for a live key. The SDK refuses a live key whose baseUrl is on k-id.com.
jurisdictionDefault for every child setup. Omit it, or pass 'auto', to have k-ID detect where the parent is. Pass a code such as 'US-CA' to choose it yourself.
appearanceColors, font, radius and per-element styles. See Customization.
localizationA locale's strings, or your own overrides. See Customization.

If your site sends a Content-Security-Policy, add your baseUrl origin to connect-src and frame-src, so the SDK can reach k-ID and show the parent's verification, and allow the live-key bot check:

DirectiveSources
script-srchttps://www.google.com/recaptcha/ https://www.gstatic.com/recaptcha/
frame-srchttps://www.google.com/recaptcha/ https://recaptcha.google.com/recaptcha/
connect-srchttps://www.google.com/recaptcha/

Call your baseUrl directly, not through a proxy of your own: each call is signed for the exact address it is sent to.

Any script on a page that uses the SDK can act as the signed-in parent, so keep third-party scripts off those pages.

4. Sign the parent in and approve a child

import {
  KidChildProvider,
  KidChildSetup,
  KidSignedIn,
  KidSignedOut,
  KidTrustedAdultAuth,
} from '@k-id/family-react'

export function FamilyArea() {
  return (
    <>
      <KidSignedOut>
        <KidTrustedAdultAuth />
      </KidSignedOut>
      <KidSignedIn>
        <KidChildProvider>
          <KidChildSetup
            onComplete={(result) => {
              if (result.ok && result.claimToken) void sendToBackend(result.claimToken)
            }}
            onExit={() => {}}
            onDone={() => {}}
          />
        </KidChildProvider>
      </KidSignedIn>
    </>
  )
}

The parent signs in with an emailed one-time code (see Parent sign-in), then picks or adds a child, reviews your product's disclosures and permissions, verifies their age, and approves (see Approving a child).

5. Confirm the result on your backend

onComplete hands you a claimToken. Send it to your backend, and exchange it with k-ID for the child's sessionId by calling /client/claim with your secret API key. Read sessionId with the usual session APIs. See Confirming the result.

6. Handle k-ID's emails

Put <KidFamilyRouter> on the page you set as the Redirect URL in step 1, so a parent who opens a consent request or a management link from a k-ID email lands in your app. See Email links.

Next steps

On this page