Skip to main content
Docs

<APIKeys /> component

The <APIKeys /> component is used to manage API keys for your application. It allows you to create, edit, and revoke API keys for your application.

The component manages API keys based on the user's current context. When the user has an active organization selected, all operations are scoped to that organization. Otherwise, operations are user-scoped.

To utilize the <APIKeys /> component, you must first enable API keys in the Clerk Dashboard.

Properties

All props are optional.

  • Name
    perPage?
    Type
    number
    Description

    The number of API keys to show per page. Defaults to 10.

  • Name
    showDescription?
    Type
    boolean
    Description

    Whether to show the description field in the API key creation form. Defaults to false.

  • Name
    appearance?
    Type
    Appearance | undefined
    Description

    Optional object to style your components. Will only affect Clerk components and not Account Portal pages.

  • Name
    fallback?
    Type
    ReactNode
    Description

    An optional element to be rendered while the component is mounting.

Usage with frameworks

The following example includes a basic implementation of the <APIKeys /> component. You can use this as a starting point for your own implementation.

app/api-keys/page.tsx
import { APIKeys } from '@clerk/nextjs'

export default function Page() {
  return <APIKeys />
}
src/api-keys.tsx
import { APIKeys } from '@clerk/clerk-react'

export default function Page() {
  return <APIKeys />
}
app/routes/api-keys.tsx
import { APIKeys } from '@clerk/react-router'

export default function Page() {
  return <APIKeys />
}
src/routes/api-keys.tsx
import { APIKeys } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/api-keys')({
  component: Page,
})

function Page() {
  return <APIKeys />
}
api-keys.vue
<script setup lang="ts">
import { APIKeys } from '@clerk/vue'
</script>

<template>
  <APIKeys />
</template>

Usage with JavaScript

The following methods available on an instance of the ClerkJavaScript Icon class are used to render and control the <APIKeys /> component:

The following examples assume that you followed the quickstartJavaScript Icon to add Clerk to your JavaScript app.

mountAPIKeys()

function mountAPIKeys(node: HTMLDivElement, props?: APIKeysProps): void
  • Name
    node
    Type
    HTMLDivElement
    Description

    The container <div> element used to render in the <APIKeys /> component

  • Name
    props?
    Type
    APIKeysProps
    Description

    The properties to pass to the <APIKeys /> component

main.js
import { Clerk } from '@clerk/clerk-js'

// Initialize Clerk with your Clerk Publishable Key
const clerkPubKey = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY

const clerk = new Clerk(clerkPubKey)
await clerk.load()

document.getElementById('app').innerHTML = `
  <div id="api-keys"></div>
`

const apiKeysDiv = document.getElementById('api-keys')

clerk.mountAPIKeys(apiKeysDiv, {
  perPage: 10,
  showDescription: true,
})
function unmountAPIKeys(node: HTMLDivElement): void
  • Name
    node
    Type
    HTMLDivElement
    Description

    The container <div> element with a rendered <APIKeys /> component instance

main.js
import { Clerk } from '@clerk/clerk-js'

// Initialize Clerk with your Clerk Publishable Key
const clerkPubKey = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY

const clerk = new Clerk(clerkPubKey)
await clerk.load()

document.getElementById('app').innerHTML = `
  <div id="api-keys"></div>
`

const apiKeysDiv = document.getElementById('api-keys')

clerk.mountAPIKeys(apiKeysDiv)

// ...

clerk.unmountAPIKeys(apiKeysDiv)

Customization

To learn about how to customize Clerk components, see the customization documentation.

Feedback

What did you think of this content?

Last updated on