import { useVeltClient } from '@veltdev/react';
import { useEffect} from '/react';


function YourComponent() {

    const { client } = useVeltClient();

    useEffect(() => {
        if(client){
            //Reset Contact List
            client.identify(yourLoggedInUser, {
                replaceContacts: true
            }).then((res) => {
            // User auth successful with Velt
            }).catch((err) => {
            // Failed to authenticate user with Velt
            });
        }
    },[client]);

  return (
    <div>

    </div>
  )
}
  • React \ Next.js

  • HTML

Create Contact List

To create a user’s contact list for the first time, use the client.identify() method. Additional calls to the method will merge new users to the contact list.

client.identify(yourLoggedInUser).then((res) => {
  // User auth successful with Velt
}).catch((err) => {
  // Failed to authenticate user with Velt
});

Replace Contact List

To replace a user’s contact list, use the client.identify() method and pass in {replaceContacts: true} as the second parameter. This will completely replace the users contact list.

client.identify(yourLoggedInUser, {
    replaceContacts: true
}).then((res) => {
  // User auth successful with Velt
}).catch((err) => {
  // Failed to authenticate user with Velt
});

Was this page helpful?