Skip to content

Commit 23b2abb

Browse files
committed
feat(docs): ✨ add introduction and components overview for react package
1 parent c952619 commit 23b2abb

File tree

2 files changed

+117
-0
lines changed

2 files changed

+117
-0
lines changed

docs/src/react/components.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!--
2+
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
3+
*
4+
* WSO2 LLC. licenses this file to you under the Apache License,
5+
* Version 2.0 (the "License"); you may not use this file except
6+
* in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
* KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations
16+
* under the License.
17+
-->
18+
19+
# Components Overview
20+
21+
## UI Components
22+
23+
- [SignIn](./components/sign-in): A component that provides sign-in forms as configured in the login flow of asgardeo.
24+
25+
- [SignOutButton](./components/sign-out-button): A component that provides a sign-out button. When clicked, it initiates the sign-out process.
26+
27+
## Control Components
28+
29+
- [SignedIn](./components/signed-in): A component that renders its children only when the user is signed in.
30+
31+
- [SignedOut](./components/signed-out.md): A component that renders its children only when the user is not signed in.
32+
33+
## Provider Component
34+
35+
- [AsgardeoProvider](./components/asgardeo-provider): A context provider component that provides an Asgardeo context to all its children. It takes a `UIAuthConfig` object as a prop, which includes the configuration for the Asgardeo context.

docs/src/react/introduction.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<!--
2+
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
3+
*
4+
* WSO2 LLC. licenses this file to you under the Apache License,
5+
* Version 2.0 (the "License"); you may not use this file except
6+
* in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
* KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations
16+
* under the License.
17+
-->
18+
19+
# Asgardeo React SDK
20+
21+
The Asgardeo React SDK enables to integrate login natively in a react application.
22+
23+
This SDK assists you in creating custom login flows directly within the applications themselves, without relying on browser redirects, thereby prioritizing user experience.
24+
25+
## Getting Started
26+
27+
### Prerequisites
28+
29+
- [Register to Asgardeo and create an organization if you don't already have one](https://wso2.com/asgardeo/docs/get-started/create-asgardeo-account/). The organization name you choose will be referred to as `<org_name>` throughout this document.
30+
- [Register a standard based application in Asgardeo to integrate your application with Asgardeo](https://wso2.com/asgardeo/docs/guides/applications/register-mobile-app/). You will obtain a `client_id` from Asgardeo for your application which will need to be embedded later for the SDK integration. Also note the redirect URI that you used to create the application, this is also required for the SDK integration.
31+
- In the created application, go to the **Advanced** tab and [enable the application native authentication for your application](https://is.docs.wso2.com/en/latest/guides/authentication/add-application-native-login/#enable-app-native-authentication).
32+
- Navigate to the **Protocol** tab in the newly created application and enable the `code` option in the [Allowed Grant Types](https://is.docs.wso2.com/en/latest/references/app-settings/oidc-settings-for-app/#allowed-grant-types) section.
33+
- Upon enabling, additional fields for `Authorized Redirect URLs` and `Allowed Origins` will appear. Enter your web application's URL in both of these fields.
34+
- In the same same **Protocol** tab, scroll down to the **Client Authentication** section. There, you will find a checkbox for `Public Client`. Enable this checkbox.
35+
36+
### Installation
37+
38+
To install the Asgardeo React SDK, navigate to your project directory in your terminal and run the following command:
39+
40+
with pnpm:
41+
42+
```bash
43+
pnpm install @asgardeo/react
44+
```
45+
46+
With npm:
47+
48+
```bash
49+
npm install @asgardeo/react
50+
```
51+
52+
With yarn:
53+
54+
```bash
55+
yarn add @asgardeo/react
56+
```
57+
58+
### Wrapping the Application with AsgardeoProvider
59+
60+
After installing the Asgardeo React SDK, you need to wrap your application with the AsgardeoProvider component, which is exposed from the installed package. This component provides the Asgardeo context to all the components in your application.
61+
62+
First, import the AsgardeoProvider from the Asgardeo React SDK:
63+
64+
```ts
65+
import { AsgardeoProvider } from "@asgardeo/react";
66+
```
67+
68+
Then, wrap your application with the `AsgardeoProvider` and pass the basic configuration to it:
69+
70+
```ts
71+
<AsgardeoProvider
72+
config={{
73+
baseUrl: "https://api.asgardeo.io/t/org_name",
74+
clientID: "gqtroUbA1Qsulqr*****",
75+
scope: ["openid", "internal_login", "profile"],
76+
signInRedirectURL: "https://domain_name:8080",
77+
}}>
78+
<App />
79+
</AsgardeoProvider>
80+
```
81+
82+
For more details about `AsgardeoProvider` and its properties, you can refer to the [Asgardeo Provider](/react/components/asgardeo-provider).

0 commit comments

Comments
 (0)