Skip to content

Commit e8552cd

Browse files
feat: update examples and documentation for accessing Auth0 configuration
1 parent f34c829 commit e8552cd

File tree

2 files changed

+19
-27
lines changed

2 files changed

+19
-27
lines changed

EXAMPLES.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const Posts = () => {
9898
};
9999

100100
export default Posts;
101-
101+
```
102102
## Custom token exchange
103103

104104
Exchange an external subject token for Auth0 tokens using the token exchange flow (RFC 8693):
@@ -741,24 +741,23 @@ You can now [call the API](#calling-an-api) with your access token and the API c
741741
742742
## Access Auth0 Configuration
743743
744-
Access the Auth0 domain and client ID that were configured in the `Auth0Provider`. This is useful when building UI components that need access to the configuration without requiring it to be passed as props:
744+
Access the Auth0 domain and client ID that were configured in the `Auth0Provider`:
745745
746746
```jsx
747747
import React from 'react';
748748
import { useAuth0 } from '@auth0/auth0-react';
749749

750-
const ConfigDisplay = () => {
751-
const { getDomain, getClientId, isAuthenticated, user } = useAuth0();
750+
const MyComponent = () => {
751+
const { getDomain, getClientId } = useAuth0();
752752

753-
return (
754-
<div>
755-
<h3>Auth0 Configuration</h3>
756-
<p>Domain: {getDomain()}</p>
757-
<p>Client ID: {getClientId()}</p>
758-
{isAuthenticated && <p>Logged in as: {user.name}</p>}
759-
</div>
760-
);
753+
const domain = getDomain();
754+
const clientId = getClientId();
755+
756+
// Use domain and clientId as needed
757+
// ...
758+
759+
return <div>{/* Your component */}</div>;
761760
};
762761

763-
export default ConfigDisplay;
762+
export default MyComponent;
764763
```

src/auth0-context.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -243,24 +243,17 @@ export interface Auth0ContextInterface<TUser extends User = User>
243243
createFetcher: Auth0Client['createFetcher'];
244244

245245
/**
246-
* ```js
247-
* const domain = auth0.getDomain();
248-
* ```
249-
*
250-
* Returns the Auth0 domain that was configured in the Auth0Provider.
251-
* This is useful for UI components that need to access the domain without
252-
* requiring it to be passed as a prop.
253-
*/
246+
*
247+
* Returns the Auth0 domain configured in the Auth0Provider.
248+
* **Use Cases:**
249+
* - Advanced integrations requiring the tenant domain
250+
*
251+
* @returns The Auth0 domain (e.g., "tenant.auth0.com")
252+
*/
254253
getDomain: () => string;
255254

256255
/**
257-
* ```js
258-
* const clientId = auth0.getClientId();
259-
* ```
260-
*
261256
* Returns the Auth0 client ID that was configured in the Auth0Provider.
262-
* This is useful for UI components that need to access the client ID without
263-
* requiring it to be passed as a prop.
264257
*/
265258
getClientId: () => string;
266259
}

0 commit comments

Comments
 (0)