Skip to content

Commit

Permalink
Allow provider to receive client as param
Browse files Browse the repository at this point in the history
  • Loading branch information
cabralmartin committed Sep 30, 2024
1 parent 032ab14 commit 75fb24b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/auth0-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ export interface Auth0ProviderOptions extends Auth0ClientOptions {
* For a sample on using multiple Auth0Providers review the [React Account Linking Sample](https://github.com/auth0-samples/auth0-link-accounts-sample/tree/react-variant)
*/
context?: React.Context<Auth0ContextInterface>;

/**
* The Auth0Client instance to be used for authentication.
*/
configuredClient?: Auth0Client;
}

/**
Expand Down Expand Up @@ -138,10 +143,11 @@ const Auth0Provider = (opts: Auth0ProviderOptions): JSX.Element => {
skipRedirectCallback,
onRedirectCallback = defaultOnRedirectCallback,
context = Auth0Context,
configuredClient,
...clientOpts
} = opts;
const [client] = useState(
() => new Auth0Client(toAuth0ClientOptions(clientOpts))
() => configuredClient ?? new Auth0Client(toAuth0ClientOptions(clientOpts))
);
const [state, dispatch] = useReducer(reducer, initialAuthState);
const didInitialise = useRef(false);
Expand Down

0 comments on commit 75fb24b

Please sign in to comment.