Skip to content

Conversation

@supmo668
Copy link

Summary

This PR adds phone number support to the ClerkUser state class, enabling applications to access and manage user phone numbers through the Clerk API.

Changes

  • Added phone_number and phone_number_id properties to ClerkUser state
  • Added update_phone_number method to ClerkUser for updating user phone numbers
  • Added update_user_phone_number helper function for use in custom event handlers
  • Load phone number data in the load_user event handler

Usage Example

import reflex_clerk_api as clerk

class MyState(rx.State):
    @rx.event
    async def update_my_phone(self) -> EventType:
        # Using the helper function
        new_phone = await clerk.update_user_phone_number(self, '+12025551234')
        return rx.toast.success(f'Phone updated: {new_phone.phone_number}')

Notes

  • Phone numbers are stored in E.164 format (e.g., +12025551234)
  • The phone_number_id is needed for updating/deleting phone numbers via Clerk API
  • When a new phone number is set, the old one is automatically deleted

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds phone number support to the ClerkUser state so apps can read and update a user’s phone number via the Clerk backend API.

Changes:

  • Adds phone_number and phone_number_id to ClerkUser and loads them in load_user.
  • Introduces ClerkUser.update_phone_number plus a standalone update_user_phone_number helper.
  • Adds a GitHub Actions workflow intended to sync a fork with upstream.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.

File Description
custom_components/reflex_clerk_api/clerk_provider.py Adds phone number fields, loading, and update APIs for Clerk users.
.github/workflows/sync-upstream.yml Adds an automated upstream sync workflow (not related to phone number support).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

supmo668 added a commit to supmo668/reflex-clerk-api that referenced this pull request Jan 27, 2026
- Remove unrelated sync-upstream.yml workflow (should be in separate PR)
- Fix primary phone number selection to use primary_phone_number_id
- Refactor ClerkUser.update_phone_number to use helper (DRY principle)
- Add verified parameter (default False) for security-conscious phone updates
- Fix PII logging: use DEBUG level, redact sensitive identifiers
- Fix docstring: remove incorrect 'unchanged' return case
- Export update_user_phone_number in __init__.py

Addresses Copilot code review comments on PR TimChild#19
- Add phone_number and phone_number_id properties to ClerkUser
- Add update_phone_number method with verified parameter (default: False)
- Add update_user_phone_number helper function for custom handlers
- Load primary phone number in load_user event handler
- Export update_user_phone_number in package __init__.py
@supmo668
Copy link
Author

supmo668 commented Feb 2, 2026

Hey Tim! 👋

Thanks for maintaining this excellent library - we've been using it extensively in our Longevity Clinic project.

I've reviewed the phone number support feature and here's a summary with suggestions:

✅ What's Good

  • Clean API design with both ClerkUser.update_phone_number method and standalone update_user_phone_number helper
  • Proper E.164 format documentation
  • Handles phone creation, update, and deletion flows nicely
  • Exports are properly added to __init__.py

📝 Suggestions Based on Copilot Review

I agree with several of Copilot's points:

  1. Primary phone selection - The code now correctly looks up the primary phone via primary_phone_number_id before falling back to first in list - this matches the docstring 👍

  2. Logging - Consider changing INFO→DEBUG for phone operations to avoid PII in logs, or at least mask the phone number

  3. Sync workflow - The .github/workflows/sync-upstream.yml seems unrelated to the phone number feature - might be worth splitting into a separate PR to keep this one focused

📚 Documentation Needs

The docs/features.md should be updated to mention the new phone number properties on ClerkUser:

- **ClerkUser**: Provides access to additional user information like `image_url`, `email_address`, `phone_number`, and `phone_number_id`.

And perhaps a brief example:

# Accessing phone number
clerk_user = await self.get_state(clerk.ClerkUser)
print(clerk_user.phone_number)  # E.164 format: +12025551234

# Updating phone number (from any event handler)
await clerk.update_user_phone_number(self, '+12025551234')

🚀 Overall

This is a solid addition that we're already using in production. Happy to help with any follow-up changes!

  • Mo (supmo668)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant