Queries
useGetApiKey
Get one API key by ID.
Requires the Better Auth API key plugin. This query calls the browser
authClient.apiKey.get endpoint and waits for the current session.
Usage
import { useGetApiKey } from "@better-auth-ui/solid/plugins/api-key"
const apiKey = useGetApiKey(authClient, () => ({
query: { id: apiKeyId(), configId: "service" }
}))Omit configId when you use the default API key configuration.
Options factory and loader helpers
import {
ensureGetApiKey,
fetchGetApiKey,
getApiKey,
getApiKeyOptions,
prefetchGetApiKey
} from "@better-auth-ui/core/plugins/api-key"
const options = { query: { id: apiKeyId, configId: "service" } }
getApiKeyOptions(authClient, userId, options)
await ensureGetApiKey(queryClient, authClient, userId, options)
await prefetchGetApiKey(queryClient, authClient, userId, options)
const apiKey = await fetchGetApiKey(
queryClient,
authClient,
userId,
options
)
const cachedApiKey = getApiKey(queryClient, authClient, userId, options)These helpers use authClient, so use them in client-side loaders. Do not call
them from a trusted server loader.
Params
Prop
Type
Last updated on