2. Authenticate
Autheticate your logged in users with the SDK.
Import the useIdentify Hook
Import the useIdentify
hook.
Fetch relevant user info
Create a Velt User
object.
To enable @mention
in the comments, you need to pass the user’s contacts. Learn more about how it works here.
Pass the User object to the SDK
Call the useIdentify()
hook and pass in the Velt User
object.
useIdentify()
method is asynchronous.useIdentify
within a child component of the VeltProvider
, or else it will not work.(Optional) - Add JWT Tokens for additional security
The second parameter of the useIdentify()
method is an optional configuration object that has a JWT Token
as a field.
This can be used to add an additional layer of security to prevent user impersonation.
See JWT Tokens for more information on how to generate a JWT Token
with the Velt SDK.
(Optional) - Force re-login user on identify call
Default: false
By default when you identify a User, we maintain the user auth in the browser unless you explicitly sign out the logged in user.
If you are changing a User’s access or any metadata and want those changes to be reflected immediately,
then you should re-call the identify
method with forceReset
option set to true
.
Import the useIdentify Hook
Import the useIdentify
hook.
Fetch relevant user info
Create a Velt User
object.
To enable @mention
in the comments, you need to pass the user’s contacts. Learn more about how it works here.
Pass the User object to the SDK
Call the useIdentify()
hook and pass in the Velt User
object.
useIdentify()
method is asynchronous.useIdentify
within a child component of the VeltProvider
, or else it will not work.(Optional) - Add JWT Tokens for additional security
The second parameter of the useIdentify()
method is an optional configuration object that has a JWT Token
as a field.
This can be used to add an additional layer of security to prevent user impersonation.
See JWT Tokens for more information on how to generate a JWT Token
with the Velt SDK.
(Optional) - Force re-login user on identify call
Default: false
By default when you identify a User, we maintain the user auth in the browser unless you explicitly sign out the logged in user.
If you are changing a User’s access or any metadata and want those changes to be reflected immediately,
then you should re-call the identify
method with forceReset
option set to true
.
React / Next.js with Hooks
for a cleaner experience.Get the Velt client
Import the useVeltClient
React hook. You can use this hook within your
component to fetch the Velt client.
Create a useEffect hook
The code in the following steps will go inside this useEffect
hook.
Fetch relevant user info
Create a Velt User
object by taking the relevant fields from yourAuthenticatedUser
.
To enable @mention
in the comments, you need to pass the user’s contacts. Learn more about how it works here.
Pass the User object to the SDK
Call the identify()
method and pass in the Velt User
object.
client.identify()
method is asynchronous.client.identify
within a child component of the VeltProvider
, or else it will not work.(Optional) - Add JWT Tokens for additional security
The second parameter of the client.identify()
method is an optional configuration object that has a JWT Token
as a field.
This can be used to add an additional layer of security to prevent user impersonation.
email
address and organizationId
passed in the identify call to validate the user later to prevent unauthorized access. See JWT Tokens for more information on how to generate a JWT Token
with the Velt SDK.
(Optional) - Force re-login user on identify call
Default: false
By default when you identify a User, we maintain the user auth in the browser unless you explicitly sign out the logged in user.
If you are changing a User’s access or any metadata and want those changes to be reflected immediately,
then you should re-call the identify
method with forceReset
option set to true
.
Fetch relevant user info
Create a Velt User
object.
To enable @mention
in the comments, you need to pass the user’s contacts. Learn more about how it works here.
Identify the Logged In User
Call this function in the component where you authenticate your Users
once your Velt client and your User
object is available.
If your .js
files are all in one file, you will need to include the .js
file on every html page you want the features to be enabled on.
Make sure you pass the User
with the fields defined in the User
object or refer to the example below.
Velt.identify()
method is asynchronousclient.identify
within a child component of the VeltProvider
, or else it will not work.(Optional) - Add JWT Tokens for additional security
The second parameter of the client.identify()
method is an optional configuration object that has a JWT Token
as a field.
This can be used to add an additional layer of security to prevent user impersonation.
See JWT Tokens for more information on how to generate a JWT Token
with the Velt SDK.
(Optional) - Force re-login user on identify call
Default: false
By default when you identify a User, we maintain the user auth in the browser unless you explicitly sign out the logged in user.
If you are changing a User’s access or any metadata and want those changes to be reflected immediately,
then you should re-call the identify
method with forceReset
option set to true
.
Get User Info
Create a Velt User object.
Identify your user
this.client.identify()
method is asynchronous.(Optional) - Add JWT Tokens for additional security
The second parameter of the useIdentify()
method is an optional configuration object that has a JWT Token
as a field.
This can be used to add an additional layer of security to prevent user impersonation.
See JWT Tokens for more information on how to generate a JWT Token
with the Velt SDK.
(Optional) - Force re-login user on identify call
Default: false
By default when you identify a User, we maintain the user auth in the browser unless you explicitly sign out the logged in user.
If you are changing a User’s access or any metadata and want those changes to be reflected immediately,
then you should re-call the identify
method with forceReset
option set to true
.
Get User Info
Create a Velt User object.
Identify your user
client.identify()
method is asynchronous.client.identify()
within a child component of the VeltProvider
, or else it will not work.(Optional) - Add JWT Tokens for additional security
The second parameter of the useIdentify()
method is an optional configuration object that has a JWT Token
as a field.
This can be used to add an additional layer of security to prevent user impersonation.
See JWT Tokens for more information on how to generate a JWT Token
with the Velt SDK.
(Optional) - Force re-login user on identify call
Default: false
By default when you identify a User, we maintain the user auth in the browser unless you explicitly sign out the logged in user.
If you are changing a User’s access or any metadata and want those changes to be reflected immediately,
then you should re-call the identify
method with forceReset
option set to true
.
Was this page helpful?