You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/react/README.web-component.md
+11-7Lines changed: 11 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,32 +3,35 @@
3
3
The SlashID form is available as a custom element: `<slashid-form>`.
4
4
5
5
There are two files which need to be included in your HTML document:
6
+
6
7
1.`main.js`
7
8
2.`style.css`
8
9
9
10
By nature of being a custom element, props follow the HTML specification so they must be strings.
10
11
11
12
To work around this limitation:
13
+
12
14
- Provide boolean and number props as string, they're later parsed to their respective type.
13
15
- Provide array and object props as stringified JSON, they will be parsed with `JSON.parse()` later.
14
16
- Provide function props by first defining the function on `globalThis`, then providing the function name to the prop as a string.
15
17
16
18
Props are reactive, but keep in mind that reference checks for array and object types are not possible since they are stringified. Function references are not reactive, redefine the function on `globalThis` and provide the new name to the prop to achieve reactivity.
| oid |`string`|| The organization ID you get when signing up with /id |
54
57
| initialToken? |`string`|| Given a valid initial token, SDK will initialize with a `User` based on that token |
55
58
| tokenStorage? |`"memory" \| "localStorage"`|`"memory"`| Where SlashID user tokens are stored. Set to `"localStorage"` to enable persistence. |
56
-
|baseApiUrl? |`string`|`"https://api.sandbox.slashid.com"`| The base SlashID API endpoint|
59
+
|environment? |`"production" \| "sandbox"`|`"production"`| The SlashID environment you wish to interact with to|
57
60
| sdkUrl? |`string`|`"https://cdn.sandbox.slashid.com/sdk.html"`| The location where your organization's custom SDK is served |
58
61
| analyticsEnabled? |`boolean`|`true`| Enable collection of client side analytics events |
59
62
| themeProps? |`{ theme?: Theme, className?: string}`|`{ theme: "auto" }`| Set the UI theme (`auto`, `light` or `dark`) and apply a CSS class name to the theme root |
@@ -62,17 +65,18 @@ Props are reactive, but keep in mind that reference checks for array and object
62
65
| factors? |[`FactorConfiguration[]`](https://developer.slashid.dev/docs/access/react-sdk/reference/components/react-sdk-reference-configurationprovider#type-factorconfiguration)|`[{ method: "webauthn" }, { method: "email_link" }]`| The [authentication methods](https://developer.slashid.dev/docs/access/sdk/interfaces/Types.Factor) to be used. |
63
66
| storeLastHandle? |`boolean`|`false`| Flag where `true` means the handle type and value used in a successful log in action will be persisted in `window.localStorage`. |
64
67
| defaultCountryCode? |`string`|`US`| Default country code to be used for the phone number input. Accepts an Alpha-2 ISO-3166 country code. |
65
-
| onSuccess? |`(user: User) => void`|| Callback function that gets called with a User object returned from core SDK upon successful log in action. Note: callback functions must be defined in `globalThis`, this prop accepts the function name as `string`. |
66
-
| onError? |`(error: Error, context: ErrorContext) => void`|| Callback function that gets called with a User object returned from core SDK upon log in action failure. Note: callback functions must be defined in `globalThis`, this prop accepts the function name as `string`. |
68
+
| onSuccess? |`(user: User) => void`|| Callback function that gets called with a User object returned from core SDK upon successful log in action. Note: callback functions must be defined in `globalThis`, this prop accepts the function name as `string`.|
69
+
| onError? |`(error: Error, context: ErrorContext) => void`|| Callback function that gets called with a User object returned from core SDK upon log in action failure. Note: callback functions must be defined in `globalThis`, this prop accepts the function name as `string`.|
67
70
| middleware? |[`LoginMiddleware`](https://developer.slashid.dev/docs/access/react-sdk/reference/middleware/react-sdk-reference-login-middleware)|| Effects to be run post-login but before `onSuccess` fires, and before the next render cycle. See [`LoginMiddleware`](https://developer.slashid.dev/docs/access/react-sdk/reference/middleware/react-sdk-reference-login-middleware) for more. |
68
71
69
72
## How does this work?
70
73
71
74
We are using [Web components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements) as an interopability interface only.
72
75
73
76
Internally, we mount a React app with three components from `@slashid/react`:
77
+
74
78
-`<SlashIDProvider>`
75
79
-`<ConfigurationProvider>`
76
80
-`<Form>`
77
81
78
-
The available props are a subset of those available in `@slashid/react`.
82
+
The available props are a subset of those available in `@slashid/react`.
0 commit comments