Chord OMS
...
Next.js
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 property description user an object representing the current user loaduser a function that loads information about the current order's associated user loaduseridentifier a function that loads the referral identifier information for the current order's associated user modifyuser a function to update the user's profile information loadusersubscriptions a function that loads the current user's subscriptions 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) argument type description email string the email address of the user 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) argument type description email? string (optional) the email address of the user billaddressattributes? object (optional) an object representing the billing address all fields need to be sent even if only a single field is updated shipaddressattributes ? object (optional) an object representing the shipping address all fields need to be sent even if only a single field is updated 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 }