Add Configurable API Fetch Controls to Asgardeo SDK for Improved Performance#416
Merged
brionmario merged 6 commits intoasgardeo:mainfrom Mar 23, 2026
Conversation
Introduce a UserPreferences interface with fetchOrganizations and fetchUserProfile flags to control automatic fetching of a user's organizations and SCIM2 profile after sign-in (both default to true). Wire the new UserPreferences into the existing Preferences type as the optional user property. These options improve performance by allowing callers to disable automatic API calls and instead fetch organization/profile data manually when needed.
Introduce config flags to control server-side fetching of user/profile and organizations (config.preferences.user.fetchUserProfile and fetchOrganizations, defaulting to true). Split the previous monolithic try/catch into separate guarded flows so each fetch can fail independently and logs use logger.warn (replacing console.warn). Organizations fetching now skips myOrganizations when no sessionId and logs accordingly. This allows disabling expensive server calls and improves error isolation and logging.
Add checks for preferences.user.fetchUserProfile and preferences.user.fetchOrganizations (default: true) to conditionally fetch user, user profile, current organization, and my organizations. Related API calls are now wrapped in these conditionals while preserving existing try/catch error handling TODOs to avoid unnecessary network requests when disabled.
Add explanatory comments in samples/teamspace-react/src/main.tsx for the preferences prop passed to the Asgardeo provider. Comments document theme settings (including disabling automatic branding fetch), user settings (controlling automatic user profile and organization fetching), and note where to add i18n locale files. These are non-functional comment changes to improve developer guidance when customizing the client.
Create a changeset that bumps @asgardeo/javascript, @asgardeo/nextjs, and @asgardeo/react as minor releases. Introduces user preferences to control automatic API calls for fetching user profile and organizations, allowing clients to opt out of those automatic requests.
Added temporary note regarding user preferences configuration.
brionmario
approved these changes
Mar 23, 2026
🦋 Changeset detectedThe changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
This PR introduces granular configuration options to control automatic API calls made by the Asgardeo JavaScript SDK during the authentication flow, addressing performance concerns and providing developers with fine-grained control over network requests.
Problem:
Currently, the SDK automatically makes multiple API calls after successful sign-in:
GET /scim2/Me- Fetches detailed user profileGET /scim2/Schemas- Fetches user attribute schemasGET /api/users/v1/me/organizations- Fetches user's associated organizationsThese calls happen automatically even when applications don't need this data, impacting performance and increasing unnecessary network traffic.
Usage Example:
Related Issues
Related PRs
Verification
Tested using the samples/teamspace-react app. Here is the screen recording.
Screen.Recording.2026-03-20.at.01.31.29.mov
Checklist
Security checks