Docs
/
In-App UI
React
Hooks
useAuthenticatedKnockClient

useAuthenticatedKnockClient

The useAuthenticatedKnockClient hook is used to create and manage an authenticated Knock client instance for making API calls on behalf of a specific user.

Parameters

#

This hook accepts positional parameters:

apiKeystringRequired

The public API key for the environment.

userIdOrUserWithPropertiesUserIdOrUserWithPropertiesRequired

User identification data. Can be a string user ID or an object with id and optional properties.

userTokenstring

Optional user token for the authenticated user.

optionsAuthenticatedKnockClientOptions

Optional configuration for the authenticated Knock client.

Returns

#

Returns a Knock client instance directly (not wrapped in an object).

Example

#

Basic usage

#

The following example demonstrates how to use the useAuthenticatedKnockClient hook to create an authenticated Knock client.

With options

#

You can pass additional options for the Knock client:

Using string user ID (deprecated)

#

While you can pass a string user ID directly, it's recommended to use an object: