Chord OMS
...
Next.js
SDK Reference

useUser

7min

This page's documentation only applies to Chord's Next.js starter prior to the release of the React. 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 Guidefor 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

JS


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:

JS


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:

JS


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:

JS




Updated 03 Mar 2023
Did this page help you?