diff --git a/packages/sdk-react/CHANGES.md b/packages/sdk-react/CHANGES.md index 1b9ad2b..3ec3fc3 100644 --- a/packages/sdk-react/CHANGES.md +++ b/packages/sdk-react/CHANGES.md @@ -1,5 +1,21 @@ fusionauth-react-sdk Changes +Changes in 2.3.0 + +- `userInfo` can now be custom typed with an optional generic argument. This may be helpful for SDK users with a non-hosted backend. Below is an example of what it looks like. + + ```typescript + interface MyUserInfo { + specialProperty: string; + // ...etc + } + const { userInfo } = useFusionAuth(); + userInfo.specialProperty; + ``` + +- UI component inline documentation has been fleshed out and added for components that were missing it. +- `manageAccount` function and button added. [Self service account management](https://fusionauth.io/docs/lifecycle/manage-users/account-management/) is only available in FusionAuth paid plans. + Changes in 2.2.0 - SDK now supports NextJS. [See further documentation for configuration with nextjs](https://github.com/FusionAuth/fusionauth-javascript-sdk/tree/main/packages/sdk-react#configuration-with-nextjs). diff --git a/packages/sdk-react/README.md b/packages/sdk-react/README.md index dd8a2bb..98ccc39 100644 --- a/packages/sdk-react/README.md +++ b/packages/sdk-react/README.md @@ -176,13 +176,15 @@ const UserNameDisplay = () => { const { userInfo } = useFusionAuth(); return ( - -

User: {userInfo.given_name}

// Only displays if user is authenticated -
- - -

Please log in to view this page

-
+ <> + +

User: {userInfo.given_name}

// Only displays if user is authenticated +
+ + +

Please log in to view this page

+
+ ); }; diff --git a/packages/sdk-react/docs/README.md b/packages/sdk-react/docs/README.md index 86b0c23..01ccbfb 100644 --- a/packages/sdk-react/docs/README.md +++ b/packages/sdk-react/docs/README.md @@ -169,7 +169,7 @@ The `startLogin` and `startRegister` functions accept an optional string paramet ### Protecting Content -The `RequireAuth` component can be used to protect information from unauthorized users. It takes an optional prop `withRole` that can be used to ensure the user has a specific role. If an array of roles is passed, the user must have at least one of the roles to be authorized. +The `RequireAuth` component can be used to protect information from unauthorized users. It takes an optional prop `withRole` that can be used to ensure the user has a specific role. If an array of roles is passed, the user must have at least one of the roles to be authorized. The `Unauthenticated` component provides the inverse functionality. ```jsx import { RequireAuth, useFusionAuth } from '@fusionauth/react-sdk'; @@ -178,9 +178,15 @@ const UserNameDisplay = () => { const { userInfo } = useFusionAuth(); return ( - -

User: {userInfo.given_name}

// Only displays if user is authenticated -
+ <> + +

User: {userInfo.given_name}

// Only displays if user is authenticated +
+ + +

Please log in to view this page

+
+ ); }; diff --git a/packages/sdk-react/docs/interfaces/providers_FusionAuthProviderConfig.FusionAuthProviderConfig.md b/packages/sdk-react/docs/interfaces/providers_FusionAuthProviderConfig.FusionAuthProviderConfig.md index 31bf06b..1919944 100644 --- a/packages/sdk-react/docs/interfaces/providers_FusionAuthProviderConfig.FusionAuthProviderConfig.md +++ b/packages/sdk-react/docs/interfaces/providers_FusionAuthProviderConfig.FusionAuthProviderConfig.md @@ -39,7 +39,7 @@ Only set this if you are hosting server that uses a custom name for the 'app.at_ #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:93](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L93) +[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:93](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L93) --- @@ -51,7 +51,7 @@ The number of seconds before the access token expiry when the auto refresh funct #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:45](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L45) +[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:45](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L45) --- @@ -63,7 +63,7 @@ The client id of the application. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:15](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L15) +[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:15](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L15) --- @@ -75,7 +75,7 @@ The path to the login endpoint. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:60](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L60) +[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:60](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L60) --- @@ -87,7 +87,7 @@ The path to the logout endpoint. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:70](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L70) +[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:70](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L70) --- @@ -99,7 +99,7 @@ The path to the me endpoint. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:87](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L87) +[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:87](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L87) --- @@ -121,7 +121,7 @@ See docs for [configuration with nextjs](https://github.com/FusionAuth/fusionaut #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:82](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L82) +[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:82](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L82) --- @@ -147,7 +147,7 @@ Callback to be invoked if a request to refresh the access token fails during aut #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:55](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L55) +[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:55](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L55) --- @@ -173,7 +173,7 @@ Callback function to be invoked with the `state` value upon redirect from login #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:50](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L50) +[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:50](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L50) --- @@ -185,7 +185,7 @@ The redirect URI for post-logout. Defaults the provided `redirectUri`. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:30](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L30) +[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:30](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L30) --- @@ -197,7 +197,7 @@ The redirect URI of the application. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:20](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L20) +[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:20](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L20) --- @@ -209,7 +209,7 @@ The path to the register endpoint. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:65](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L65) +[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:65](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L65) --- @@ -221,7 +221,7 @@ The OAuth2 scope parameter passed to the `/oauth2/authorize` endpoint. If not sp #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:25](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L25) +[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:25](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L25) --- @@ -233,7 +233,7 @@ The URL of the server that performs the token exchange. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:10](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L10) +[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:10](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L10) --- @@ -245,7 +245,7 @@ Enables the SDK to automatically handle fetching user info when logged in. Defau #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:40](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L40) +[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:40](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L40) --- @@ -257,7 +257,7 @@ Enables automatic token refreshing. Defaults to false. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:35](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L35) +[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:35](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L35) --- @@ -269,4 +269,4 @@ The path to the token refresh endpoint. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:75](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L75) +[packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts:75](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderConfig.ts#L75) diff --git a/packages/sdk-react/docs/interfaces/providers_FusionAuthProviderContext.FusionAuthProviderContext.md b/packages/sdk-react/docs/interfaces/providers_FusionAuthProviderContext.FusionAuthProviderContext.md index 603d110..2fbc88d 100644 --- a/packages/sdk-react/docs/interfaces/providers_FusionAuthProviderContext.FusionAuthProviderContext.md +++ b/packages/sdk-react/docs/interfaces/providers_FusionAuthProviderContext.FusionAuthProviderContext.md @@ -1,11 +1,17 @@ [@fusionauth/react-sdk](../README.md) / [Modules](../modules.md) / [providers/FusionAuthProviderContext](../modules/providers_FusionAuthProviderContext.md) / FusionAuthProviderContext -# Interface: FusionAuthProviderContext +# Interface: FusionAuthProviderContext\ [providers/FusionAuthProviderContext](../modules/providers_FusionAuthProviderContext.md).FusionAuthProviderContext The context provided by FusionAuth React SDK +## Type parameters + +| Name | Type | +| :--- | :--------- | +| `T` | `UserInfo` | + ## Table of contents ### Properties @@ -15,6 +21,7 @@ The context provided by FusionAuth React SDK - [initAutoRefresh](providers_FusionAuthProviderContext.FusionAuthProviderContext.md#initautorefresh) - [isFetchingUserInfo](providers_FusionAuthProviderContext.FusionAuthProviderContext.md#isfetchinguserinfo) - [isLoggedIn](providers_FusionAuthProviderContext.FusionAuthProviderContext.md#isloggedin) +- [manageAccount](providers_FusionAuthProviderContext.FusionAuthProviderContext.md#manageaccount) - [refreshToken](providers_FusionAuthProviderContext.FusionAuthProviderContext.md#refreshtoken) - [startLogin](providers_FusionAuthProviderContext.FusionAuthProviderContext.md#startlogin) - [startLogout](providers_FusionAuthProviderContext.FusionAuthProviderContext.md#startlogout) @@ -31,28 +38,28 @@ Error occurred while fetching userInfo. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:30](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L30) +[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:29](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L29) --- ### fetchUserInfo -• **fetchUserInfo**: () => `Promise`\<`undefined` \| `UserInfo`\> +• **fetchUserInfo**: () => `Promise`\<`undefined` \| `T`\> Fetches user info from the 'me' endpoint. This is handled automatically if the SDK is configured with `shouldAutoFetchUserInfo`. #### Type declaration -▸ (): `Promise`\<`undefined` \| `UserInfo`\> +▸ (): `Promise`\<`undefined` \| `T`\> ##### Returns -`Promise`\<`undefined` \| `UserInfo`\> +`Promise`\<`undefined` \| `T`\> #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:20](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L20) +[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:19](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L19) --- @@ -73,7 +80,7 @@ This is handled automatically if the SDK is configured with `shouldAutoRefresh`. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:59](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L59) +[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:64](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L64) --- @@ -85,7 +92,7 @@ Indicates that the fetchUserInfo call is unresolved. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:25](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L25) +[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:24](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L24) --- @@ -97,7 +104,28 @@ Whether the user is logged in. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:8](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L8) +[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:8](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L8) + +--- + +### manageAccount + +• **manageAccount**: () => `void` + +Redirects to [self service account management](https://fusionauth.io/docs/lifecycle/manage-users/account-management/) +Self service account management is only available in FusionAuth paid plans. + +#### Type declaration + +▸ (): `void` + +##### Returns + +`void` + +#### Defined in + +[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:52](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L52) --- @@ -118,7 +146,7 @@ This is handled automatically if the SDK is configured with `shouldAutoRefresh`. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:53](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L53) +[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:58](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L58) --- @@ -144,7 +172,7 @@ Initiates login flow. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:36](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L36) +[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:35](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L35) --- @@ -164,7 +192,7 @@ Initiates logout flow. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:47](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L47) +[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:46](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L46) --- @@ -190,16 +218,16 @@ Initiates register flow. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:42](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L42) +[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:41](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L41) --- ### userInfo -• **userInfo**: `null` \| `UserInfo` +• **userInfo**: `null` \| `T` Data fetched from the configured 'me' endpoint. #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:13](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L13) +[packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts:13](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProviderContext.ts#L13) diff --git a/packages/sdk-react/docs/modules/providers_FusionAuthProvider.md b/packages/sdk-react/docs/modules/providers_FusionAuthProvider.md index 516ff0a..c57e343 100644 --- a/packages/sdk-react/docs/modules/providers_FusionAuthProvider.md +++ b/packages/sdk-react/docs/modules/providers_FusionAuthProvider.md @@ -13,35 +13,46 @@ ### FusionAuthProvider -▸ **FusionAuthProvider**(`props`, `context?`): `ReactNode` +▸ **FusionAuthProvider**\<`T`\>(`«destructured»`): `Element` + +#### Type parameters + +| Name | Type | +| :--- | :--------- | +| `T` | `UserInfo` | #### Parameters -| Name | Type | -| :--------- | :----------------------------------------------------------------------------------------------------------------------------------------- | -| `props` | [`FusionAuthProviderConfig`](../interfaces/providers_FusionAuthProviderConfig.FusionAuthProviderConfig.md) & \{ `children?`: `ReactNode` } | -| `context?` | `any` | +| Name | Type | +| :--------------- | :----------------------------------------------------------------------------------------------------------------------------------------- | +| `«destructured»` | \{ `children?`: `ReactNode` } & [`FusionAuthProviderConfig`](../interfaces/providers_FusionAuthProviderConfig.FusionAuthProviderConfig.md) | #### Returns -`ReactNode` +`Element` #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProvider.tsx:15](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProvider.tsx#L15) +[packages/sdk-react/src/components/providers/FusionAuthProvider.tsx:15](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProvider.tsx#L15) --- ### useFusionAuth -▸ **useFusionAuth**(): [`FusionAuthProviderContext`](../interfaces/providers_FusionAuthProviderContext.FusionAuthProviderContext.md) +▸ **useFusionAuth**\<`T`\>(): [`FusionAuthProviderContext`](../interfaces/providers_FusionAuthProviderContext.FusionAuthProviderContext.md)\<`T`\> A hook that returns `FusionAuthProviderContext` +#### Type parameters + +| Name | Type | +| :--- | :--------- | +| `T` | `UserInfo` | + #### Returns -[`FusionAuthProviderContext`](../interfaces/providers_FusionAuthProviderContext.FusionAuthProviderContext.md) +[`FusionAuthProviderContext`](../interfaces/providers_FusionAuthProviderContext.FusionAuthProviderContext.md)\<`T`\> #### Defined in -[packages/sdk-react/src/components/providers/FusionAuthProvider.tsx:73](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/providers/FusionAuthProvider.tsx#L73) +[packages/sdk-react/src/components/providers/FusionAuthProvider.tsx:68](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/providers/FusionAuthProvider.tsx#L68) diff --git a/packages/sdk-react/docs/modules/ui_FusionAuthLoginButton.md b/packages/sdk-react/docs/modules/ui_FusionAuthLoginButton.md index 9f4c0bd..9ca2fff 100644 --- a/packages/sdk-react/docs/modules/ui_FusionAuthLoginButton.md +++ b/packages/sdk-react/docs/modules/ui_FusionAuthLoginButton.md @@ -12,16 +12,16 @@ ### FusionAuthLoginButton -▸ **FusionAuthLoginButton**(`props`, `context?`): `ReactNode` +▸ **FusionAuthLoginButton**(`props`, `deprecatedLegacyContext?`): `ReactNode` -Calls the `startLogin` method from `useFusionAuth`. +Calls the `startLogin` method from `FusionAuthProviderContext`. #### Parameters -| Name | Type | -| :--------- | :------ | -| `props` | `Props` | -| `context?` | `any` | +| Name | Type | Description | +| :------------------------- | :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------ | +| `props` | `FusionAuthLoginButtonProps` | - | +| `deprecatedLegacyContext?` | `any` | **`Deprecated`** **`See`** [React Docs](https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods) | #### Returns @@ -29,4 +29,4 @@ Calls the `startLogin` method from `useFusionAuth`. #### Defined in -[packages/sdk-react/src/components/ui/FusionAuthLoginButton/index.tsx:14](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/ui/FusionAuthLoginButton/index.tsx#L14) +[packages/sdk-react/src/components/ui/FusionAuthLoginButton/index.tsx:16](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/ui/FusionAuthLoginButton/index.tsx#L16) diff --git a/packages/sdk-react/docs/modules/ui_FusionAuthLogoutButton.md b/packages/sdk-react/docs/modules/ui_FusionAuthLogoutButton.md index 35f78bb..de2bb6e 100644 --- a/packages/sdk-react/docs/modules/ui_FusionAuthLogoutButton.md +++ b/packages/sdk-react/docs/modules/ui_FusionAuthLogoutButton.md @@ -12,16 +12,16 @@ ### FusionAuthLogoutButton -▸ **FusionAuthLogoutButton**(`props`, `context?`): `ReactNode` +▸ **FusionAuthLogoutButton**(`props`, `deprecatedLegacyContext?`): `ReactNode` -Calls the `startLogout` method from `useFusionAuth`. +Calls the `startLogout` method from `FusionAuthProviderContext`. #### Parameters -| Name | Type | -| :--------- | :------ | -| `props` | `Props` | -| `context?` | `any` | +| Name | Type | Description | +| :------------------------- | :---------------------------- | :------------------------------------------------------------------------------------------------------------------------------------ | +| `props` | `FusionAuthLogoutButtonProps` | - | +| `deprecatedLegacyContext?` | `any` | **`Deprecated`** **`See`** [React Docs](https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods) | #### Returns @@ -29,4 +29,4 @@ Calls the `startLogout` method from `useFusionAuth`. #### Defined in -[packages/sdk-react/src/components/ui/FusionAuthLogoutButton/index.tsx:12](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/ui/FusionAuthLogoutButton/index.tsx#L12) +[packages/sdk-react/src/components/ui/FusionAuthLogoutButton/index.tsx:13](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/ui/FusionAuthLogoutButton/index.tsx#L13) diff --git a/packages/sdk-react/docs/modules/ui_FusionAuthRegisterButton.md b/packages/sdk-react/docs/modules/ui_FusionAuthRegisterButton.md index ce2d187..589cd81 100644 --- a/packages/sdk-react/docs/modules/ui_FusionAuthRegisterButton.md +++ b/packages/sdk-react/docs/modules/ui_FusionAuthRegisterButton.md @@ -12,16 +12,16 @@ ### FusionAuthRegisterButton -▸ **FusionAuthRegisterButton**(`props`, `context?`): `ReactNode` +▸ **FusionAuthRegisterButton**(`props`, `deprecatedLegacyContext?`): `ReactNode` -Calls the `startRegister` method from `useFusionAuth`. +Calls the `startRegister` method from `FusionAuthProviderContext`. #### Parameters -| Name | Type | -| :--------- | :------ | -| `props` | `Props` | -| `context?` | `any` | +| Name | Type | Description | +| :------------------------- | :------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------ | +| `props` | `FusionAuthRegisterButtonProps` | - | +| `deprecatedLegacyContext?` | `any` | **`Deprecated`** **`See`** [React Docs](https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods) | #### Returns @@ -29,4 +29,4 @@ Calls the `startRegister` method from `useFusionAuth`. #### Defined in -[packages/sdk-react/src/components/ui/FusionAuthRegisterButton/index.tsx:13](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/ui/FusionAuthRegisterButton/index.tsx#L13) +[packages/sdk-react/src/components/ui/FusionAuthRegisterButton/index.tsx:15](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/ui/FusionAuthRegisterButton/index.tsx#L15) diff --git a/packages/sdk-react/docs/modules/ui_RequireAuth.md b/packages/sdk-react/docs/modules/ui_RequireAuth.md index 256e114..6ef07da 100644 --- a/packages/sdk-react/docs/modules/ui_RequireAuth.md +++ b/packages/sdk-react/docs/modules/ui_RequireAuth.md @@ -12,14 +12,16 @@ ### RequireAuth -▸ **RequireAuth**(`props`, `context?`): `ReactNode` +▸ **RequireAuth**(`props`, `deprecatedLegacyContext?`): `ReactNode` + +Only renders children when user is authenticated. #### Parameters -| Name | Type | -| :--------- | :------ | -| `props` | `Props` | -| `context?` | `any` | +| Name | Type | Description | +| :------------------------- | :----------------- | :------------------------------------------------------------------------------------------------------------------------------------ | +| `props` | `RequireAuthProps` | - | +| `deprecatedLegacyContext?` | `any` | **`Deprecated`** **`See`** [React Docs](https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods) | #### Returns @@ -27,4 +29,4 @@ #### Defined in -[packages/sdk-react/src/components/ui/RequireAuth/index.tsx:8](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/ui/RequireAuth/index.tsx#L8) +[packages/sdk-react/src/components/ui/RequireAuth/index.tsx:10](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/ui/RequireAuth/index.tsx#L10) diff --git a/packages/sdk-react/docs/modules/ui_Unauthenticated.md b/packages/sdk-react/docs/modules/ui_Unauthenticated.md index e44fec6..b210098 100644 --- a/packages/sdk-react/docs/modules/ui_Unauthenticated.md +++ b/packages/sdk-react/docs/modules/ui_Unauthenticated.md @@ -12,15 +12,17 @@ ### Unauthenticated -▸ **Unauthenticated**(`props`, `context?`): `ReactNode` +▸ **Unauthenticated**(`props`, `deprecatedLegacyContext?`): `ReactNode` + +Only renders children when user is unauthenticated. #### Parameters -| Name | Type | -| :---------------- | :---------- | -| `props` | `Object` | -| `props.children?` | `ReactNode` | -| `context?` | `any` | +| Name | Type | Description | +| :------------------------- | :---------- | :------------------------------------------------------------------------------------------------------------------------------------ | +| `props` | `Object` | - | +| `props.children?` | `ReactNode` | - | +| `deprecatedLegacyContext?` | `any` | **`Deprecated`** **`See`** [React Docs](https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods) | #### Returns @@ -28,4 +30,4 @@ #### Defined in -[packages/sdk-react/src/components/ui/Unauthenticated/index.tsx:4](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/546896fe40aeab4bf379a067a721414ce99ca372/packages/sdk-react/src/components/ui/Unauthenticated/index.tsx#L4) +[packages/sdk-react/src/components/ui/Unauthenticated/index.tsx:5](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/6b00f96f26d9e2dbbacedeab842a037e53b50aa6/packages/sdk-react/src/components/ui/Unauthenticated/index.tsx#L5) diff --git a/packages/sdk-react/package.json b/packages/sdk-react/package.json index f806be6..a6612a8 100644 --- a/packages/sdk-react/package.json +++ b/packages/sdk-react/package.json @@ -1,6 +1,6 @@ { "name": "@fusionauth/react-sdk", - "version": "2.2.0", + "version": "2.3.0", "private": false, "description": "FusionAuth solves the problem of building essential security without adding risk or distracting from your primary application", "type": "module", diff --git a/packages/sdk-react/src/components/ui/FusionAuthAccountButton/index.tsx b/packages/sdk-react/src/components/ui/FusionAuthAccountButton/index.tsx index 54e06f3..1eaf394 100644 --- a/packages/sdk-react/src/components/ui/FusionAuthAccountButton/index.tsx +++ b/packages/sdk-react/src/components/ui/FusionAuthAccountButton/index.tsx @@ -10,7 +10,7 @@ type FusionAuthAccountButtonProps = { className?: string; }; -/** Calls the `manageAccount` method from `FusionAuthContext`. */ +/** Calls the `manageAccount` method from `FusionAuthProviderContext`. */ export const FusionAuthAccountButton: FC = ({ className, text, diff --git a/packages/sdk-react/src/components/ui/FusionAuthLoginButton/index.tsx b/packages/sdk-react/src/components/ui/FusionAuthLoginButton/index.tsx index fc506ca..aa61225 100644 --- a/packages/sdk-react/src/components/ui/FusionAuthLoginButton/index.tsx +++ b/packages/sdk-react/src/components/ui/FusionAuthLoginButton/index.tsx @@ -12,7 +12,7 @@ interface FusionAuthLoginButtonProps { className?: string; } -/** Calls the `startLogin` method from `FusionAuthContext`. */ +/** Calls the `startLogin` method from `FusionAuthProviderContext`. */ export const FusionAuthLoginButton: FC = ({ state, text, diff --git a/packages/sdk-react/src/components/ui/FusionAuthLogoutButton/index.tsx b/packages/sdk-react/src/components/ui/FusionAuthLogoutButton/index.tsx index 8f0d0c0..8f5ef4b 100644 --- a/packages/sdk-react/src/components/ui/FusionAuthLogoutButton/index.tsx +++ b/packages/sdk-react/src/components/ui/FusionAuthLogoutButton/index.tsx @@ -9,7 +9,7 @@ interface FusionAuthLogoutButtonProps { className?: string; } -/** Calls the `startLogout` method from `FusionAuthContext`. */ +/** Calls the `startLogout` method from `FusionAuthProviderContext`. */ export const FusionAuthLogoutButton: FC = ({ text, className, diff --git a/packages/sdk-react/src/components/ui/FusionAuthRegisterButton/index.tsx b/packages/sdk-react/src/components/ui/FusionAuthRegisterButton/index.tsx index 18a07b2..fadbb72 100644 --- a/packages/sdk-react/src/components/ui/FusionAuthRegisterButton/index.tsx +++ b/packages/sdk-react/src/components/ui/FusionAuthRegisterButton/index.tsx @@ -11,7 +11,7 @@ interface FusionAuthRegisterButtonProps { className?: string; } -/** Calls the `startRegister` method from `FusionAuthContext`. */ +/** Calls the `startRegister` method from `FusionAuthProviderContext`. */ export const FusionAuthRegisterButton: FC = ({ state, text,