Chord OMS
...
SDK Reference
useUser
7 min
this page's documentation only applies to chord's next js starter prior to the release of the react docid\ ewxkrz0jhh0zpphikkcri the next js starter now uses the react sdk and does not use the methods documented on this page check out the react sdk reference for complete documentation, and the react sdk migration guide docid\ qmilhjfpz9wbjyzbe50ku for details on how to upgrade the useuser hook returns the current user and functions for loading data about the user at the moment, the only user information chord supports is the user's referral identifier and personalized referral url example import { useuser } from ' /hooks/actions' // inside a function component const { user, loaduser } = useuser() returns the useuser hook returns an object with these properties 394,349 trueleft unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type functions loaduser the loaduser function loads information about the current order's associated user from the chord api arguments none returns promise\<void> a promise that resolves when the user object has been added to redux example import { useuser } from ' /hooks/actions' export default () => { const { cart } = usecart() const { user, loaduser } = useuser() useeffect(() => { loaduser() }, \[]) return \<p>welcome, {user data email}!\</p> } loaduserreferralidentifier the loaduserreferralidentifier function loads the referral identifier information for a user with the given email address from the chord api arguments loaduserreferralidentifier(email) trueleft unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type returns promise\<void> a promise that resolves when the referralidentifier object has been added to the user object in redux example import { useuser } from ' /hooks/actions' export default () => { const { user, loaduserreferralidentifier } = useuser() const referralpurl = user referralidentifier && user referralidentifier purl useeffect(() => { loaduserreferralidentifier() }, \[]) return ( \<p>refer your friends with your personal referral link {referralpurl}\</p> ) } modifyuser the modifyuser function is used to update the user's profile information arguments modifyuser(options) trueleft unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type returns promise\<void> a promise that resolves when the user object has been updated in redux example import { useuser } from ' /hooks/actions' export default () => { const { modifyuser } = useuser() const onsubmit = ({ email }) => { modifyuser({ email }) } // return profile edit form }