Skip to content

fix: recreate Auth0Client when configuration props change#904

Closed
gyaneshgouraw-okta wants to merge 3 commits intomainfrom
fix/auth0-provider-client-recreation
Closed

fix: recreate Auth0Client when configuration props change#904
gyaneshgouraw-okta wants to merge 3 commits intomainfrom
fix/auth0-provider-client-recreation

Conversation

@gyaneshgouraw-okta
Copy link
Copy Markdown
Contributor

Summary

This PR improves how the Auth0Client is created in the Auth0Provider component. It replaces useState with useMemo to ensure the client is properly recreated when key props (domain, clientId, audience, scope, etc.) change. This makes the component behavior more predictable and correct when props are updated.

Fixes: #830


Changes

  • Refactored Auth0Provider to use useMemo for Auth0Client instantiation.
  • Removed unused useState import from src/auth0-provider.tsx.

Tests

  • Added a test suite in __tests__/auth-provider.test.tsx to verify that the Auth0Client is correctly recreated when clientId, audience, or scope props change.

@gyaneshgouraw-okta gyaneshgouraw-okta marked this pull request as draft September 29, 2025 10:26
@gyaneshgouraw-okta
Copy link
Copy Markdown
Contributor Author

After thorough review, we've decided not to proceed with the fix as it would create multiple Auth0Client instances.

Prevent authentication state corruption
Avoid security vulnerabilities from dynamic reconfiguration
Ensure predictable token caching behavior
Maintain session consistency

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.

getAccessTokenSilently doesn't get current values passed to Auth0Provider after URL truncation and redirect by the SDK

1 participant