Docs
/
In-App UI
React
Hooks
useSlackAuth

useSlackAuth

The useSlackAuth hook is used to manage Slack authentication for connecting user accounts to Slack workspaces. This hook must be used within a KnockSlackProvider.

Parameters

#
slackClientIdstringRequired

The Slack OAuth client ID for your application.

redirectUrlstring

Optional URL to redirect to after authentication completes.

optionsUseSlackAuthOptions | string[]

Optional configuration for OAuth scopes. Can be an object with scopes/additionalScopes or an array of additional scopes.

Returns

#

Returns an object with the following properties:

buildSlackAuthUrl() => string

Function that builds the Slack OAuth authorization URL.

disconnectFromSlack() => Promise<void>

Function to revoke Slack access for the current user.

Example

#

Basic usage

#

The following example demonstrates how to use the useSlackAuth hook to manage Slack authentication.

With custom scopes

#

You can customize the OAuth scopes requested: