In-App UI
JavaScript
SDK
Knock

Knock class

Complete reference for the Knock class in the Knock JavaScript SDK.

The top-level Knock class, used to interact with a client instance.

Parameters

#
apiKeystring*
The public API key for the Knock environment.
optionsKnockOptions
Additional options to pass through.

Example

#

Properties

#

userId

#

Returns the user ID of the authenticated user.

Returns: string

feeds

#

Returns a FeedClient instance that can be initialized to return a feed.

Optionally a feed can be initialized with a default set of FeedClientOptions which will be applied to all subsequent requests.

Returns: Feed instance

Example:

user

#

Returns a UserClient instance to interact with the users API for the current, authenticated user.

Returns: UserClient instance

Example:

preferences

#

Returns a Preferences instance to interact with the preferences API for the current, authenticated user.

Returns: Preferences instance

Example:

client

#

Returns an instance of an authenticated ApiClient that can be used to make HTTP and Websocket requests to Knock.

Returns: ApiClient instance

Methods

#

authenticate

#

Authenticates the current user and creates a new Knock session.

Parameters:

userUserIdentificationOptions
User identification data.
userTokenstring
JWT for the authenticated user. Not required in development environments.
optionsAuthenticateOptions
Additional options to authenticate your Knock user with.

Returns: void

Example:

teardown

#

Tears down a current session and disconnects any connected sockets.

Returns: void