Skip to Content

User Hooks

Hooks for reading and updating user identity fields.

useUser()

Read and update built-in user fields. Only re-renders when a user.* variable changes.

const { email, setEmail, identify, marketingConsent, setMarketingConsent } = useUser() // Update email field setEmail('user@example.com') // Identify the user (fires user.registered event) identify(email) // Track marketing consent setMarketingConsent(true)
PropertyTypeDescription
emailstringUser email address
namestringUser display name
dateOfBirthstringDate of birth in YYYY-MM-DD format
marketingConsentbooleanWhether the user has opted in to marketing emails
stripeCustomerIdstringStripe customer ID (set after payment)
paddleCustomerIdstringPaddle customer ID (set after payment)
setEmail(email: string) => voidUpdate email
setName(name: string) => voidUpdate name
setDateOfBirth(dob: string) => voidUpdate date of birth (auto-converts to ISO)
setMarketingConsent(consent: boolean) => voidSet marketing email consent
identify(email: string) => voidAssociate the session with an email (fires user.registered event)

useUserProperty(field)

Read/write a custom user property. Auto-prefixed with user. — no config declaration needed.

const [gender, setGender] = useUserProperty('gender')
ReturnTypeDescription
[0]stringCurrent property value
[1](value: string) => voidSetter function

useDateOfBirth(format?)

Format-aware date of birth input. Always stores the value as ISO YYYY-MM-DD regardless of input format.

const [dob, setDob] = useDateOfBirth() // defaults to MM/DD/YYYY const [dob, setDob] = useDateOfBirth('DD/MM/YYYY') // EU format setDob('03/15/1990') // stored as "1990-03-15" setDob('03151990') // stored as "1990-03-15"

Supported formats: 'MM/DD/YYYY' (default), 'DD/MM/YYYY', 'YYYY-MM-DD'

ReturnTypeDescription
[0]stringCurrent DOB in YYYY-MM-DD format
[1](value: string) => voidSetter — parses input using the specified format
Last updated on