ApiKeyInput

API-key rotation control. Renders a Rotate button that opens a confirmation dialog. On confirm, fires onRotate(record) if provided, or sets the source field to null so the server-side hook regenerates the key.

Installation

pnpm dlx shadcn@latest add @shadmin/api-key-input

Usage

import { ApiKeyInput } from '@/components/admin';
 
<ApiKeyInput source="apiKey" />
<ApiKeyInput
  source="apiKey"
  onRotate={async (record) => await regenKeyServerSide(record.id)}
/>

Props

PropRequiredTypeDefaultDescription
sourceRequiredstring-Record field
resourceOptionalstringContextOverride resource
onRotateOptional(record) => Promise<void> | void-Custom rotation hook
disabledOptionalbooleanfalseDisable button

Default rotation behavior

Without onRotate, the button calls useUpdate(resource, { id, data: { [source]: null }, previousData }). The server-side mutation is expected to regenerate the key and return the new value in the next read.