@supertokens/rownd-react-native 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +554 -0
  3. package/android/build.gradle +153 -0
  4. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  5. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/gradlew +234 -0
  8. package/android/gradlew.bat +89 -0
  9. package/android/src/main/AndroidManifest.xml +4 -0
  10. package/android/src/main/java/com/reactnativerowndplugin/RowndPluginModule.kt +235 -0
  11. package/android/src/main/java/com/reactnativerowndplugin/RowndPluginPackage.kt +25 -0
  12. package/app.plugin.js +3 -0
  13. package/expo/plugin.js +61 -0
  14. package/ios/Rownd.xcodeproj/project.pbxproj +283 -0
  15. package/ios/RowndHelper.swift +62 -0
  16. package/ios/RowndPlugin-Bridging-Header.h +3 -0
  17. package/ios/RowndPlugin.m +31 -0
  18. package/ios/RowndPlugin.swift +233 -0
  19. package/ios/RowndPluginEventEmitter.m +12 -0
  20. package/ios/RowndPluginEventEmitter.swift +19 -0
  21. package/lib/commonjs/components/GlobalContext.js +72 -0
  22. package/lib/commonjs/components/GlobalContext.js.map +1 -0
  23. package/lib/commonjs/components/GlobalContext.types.js +6 -0
  24. package/lib/commonjs/components/GlobalContext.types.js.map +1 -0
  25. package/lib/commonjs/components/GlobalContext.web.js +21 -0
  26. package/lib/commonjs/components/GlobalContext.web.js.map +1 -0
  27. package/lib/commonjs/components/RequireSignIn.js +37 -0
  28. package/lib/commonjs/components/RequireSignIn.js.map +1 -0
  29. package/lib/commonjs/components/SignedIn.js +22 -0
  30. package/lib/commonjs/components/SignedIn.js.map +1 -0
  31. package/lib/commonjs/components/SignedOut.js +22 -0
  32. package/lib/commonjs/components/SignedOut.js.map +1 -0
  33. package/lib/commonjs/constants/action.js +11 -0
  34. package/lib/commonjs/constants/action.js.map +1 -0
  35. package/lib/commonjs/hooks/rownd.js +30 -0
  36. package/lib/commonjs/hooks/rownd.js.map +1 -0
  37. package/lib/commonjs/hooks/rownd.web.js +56 -0
  38. package/lib/commonjs/hooks/rownd.web.js.map +1 -0
  39. package/lib/commonjs/index.js +42 -0
  40. package/lib/commonjs/index.js.map +1 -0
  41. package/lib/commonjs/reducer/rowndReducer.js +67 -0
  42. package/lib/commonjs/reducer/rowndReducer.js.map +1 -0
  43. package/lib/commonjs/types.js +2 -0
  44. package/lib/commonjs/types.js.map +1 -0
  45. package/lib/commonjs/utils/config.js +6 -0
  46. package/lib/commonjs/utils/config.js.map +1 -0
  47. package/lib/commonjs/utils/nativeModule.js +70 -0
  48. package/lib/commonjs/utils/nativeModule.js.map +1 -0
  49. package/lib/module/components/GlobalContext.js +64 -0
  50. package/lib/module/components/GlobalContext.js.map +1 -0
  51. package/lib/module/components/GlobalContext.types.js +2 -0
  52. package/lib/module/components/GlobalContext.types.js.map +1 -0
  53. package/lib/module/components/GlobalContext.web.js +14 -0
  54. package/lib/module/components/GlobalContext.web.js.map +1 -0
  55. package/lib/module/components/RequireSignIn.js +30 -0
  56. package/lib/module/components/RequireSignIn.js.map +1 -0
  57. package/lib/module/components/SignedIn.js +15 -0
  58. package/lib/module/components/SignedIn.js.map +1 -0
  59. package/lib/module/components/SignedOut.js +15 -0
  60. package/lib/module/components/SignedOut.js.map +1 -0
  61. package/lib/module/constants/action.js +5 -0
  62. package/lib/module/constants/action.js.map +1 -0
  63. package/lib/module/hooks/rownd.js +24 -0
  64. package/lib/module/hooks/rownd.js.map +1 -0
  65. package/lib/module/hooks/rownd.web.js +50 -0
  66. package/lib/module/hooks/rownd.web.js.map +1 -0
  67. package/lib/module/index.js +7 -0
  68. package/lib/module/index.js.map +1 -0
  69. package/lib/module/reducer/rowndReducer.js +60 -0
  70. package/lib/module/reducer/rowndReducer.js.map +1 -0
  71. package/lib/module/types.js +2 -0
  72. package/lib/module/types.js.map +1 -0
  73. package/lib/module/utils/config.js +2 -0
  74. package/lib/module/utils/config.js.map +1 -0
  75. package/lib/module/utils/nativeModule.js +55 -0
  76. package/lib/module/utils/nativeModule.js.map +1 -0
  77. package/lib/typescript/components/GlobalContext.d.ts +13 -0
  78. package/lib/typescript/components/GlobalContext.types.d.ts +90 -0
  79. package/lib/typescript/components/GlobalContext.web.d.ts +4 -0
  80. package/lib/typescript/components/RequireSignIn.d.ts +9 -0
  81. package/lib/typescript/components/SignedIn.d.ts +6 -0
  82. package/lib/typescript/components/SignedOut.d.ts +6 -0
  83. package/lib/typescript/constants/action.d.ts +7 -0
  84. package/lib/typescript/hooks/rownd.d.ts +31 -0
  85. package/lib/typescript/hooks/rownd.web.d.ts +2 -0
  86. package/lib/typescript/index.d.ts +6 -0
  87. package/lib/typescript/reducer/rowndReducer.d.ts +4 -0
  88. package/lib/typescript/types.d.ts +21 -0
  89. package/lib/typescript/utils/config.d.ts +7 -0
  90. package/lib/typescript/utils/nativeModule.d.ts +14 -0
  91. package/package.json +167 -0
  92. package/rownd-react-native.podspec +38 -0
  93. package/src/components/GlobalContext.tsx +93 -0
  94. package/src/components/GlobalContext.types.ts +109 -0
  95. package/src/components/GlobalContext.web.tsx +17 -0
  96. package/src/components/RequireSignIn.tsx +35 -0
  97. package/src/components/SignedIn.tsx +17 -0
  98. package/src/components/SignedOut.tsx +17 -0
  99. package/src/constants/action.ts +8 -0
  100. package/src/hooks/rownd.ts +68 -0
  101. package/src/hooks/rownd.web.ts +56 -0
  102. package/src/index.tsx +7 -0
  103. package/src/reducer/rowndReducer.ts +63 -0
  104. package/src/types.ts +32 -0
  105. package/src/utils/config.ts +9 -0
  106. package/src/utils/nativeModule.ts +83 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 rownd
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,554 @@
1
+ # @supertokens/rownd-react-native
2
+
3
+ Rownd bindings for React Native
4
+
5
+ ## Prerequisites
6
+
7
+ You must be using React Native v0.61 or higher.
8
+
9
+ ## Installation
10
+
11
+ First, install the Rownd SDK for React Native.
12
+
13
+ ```sh
14
+ npm install @supertokens/rownd-react-native
15
+ ```
16
+
17
+ ### Expo development
18
+
19
+ 1. Add `@supertokens/rownd-react-native` as a plugin to your `app.json` file.
20
+
21
+ ```json
22
+ {
23
+ "expo": {
24
+ "plugins": ["@supertokens/rownd-react-native"]
25
+ }
26
+ }
27
+ ```
28
+
29
+ 2. Install [Expo BuildProperties](https://docs.expo.dev/versions/latest/sdk/build-properties/) to set iOS/Android versions
30
+
31
+ ```sh
32
+ npx expo install expo-build-properties
33
+ ```
34
+
35
+ 3. Add `expo-build-properties` as a plugin to your `app.json` file. Ensure the Sdk versions match or are above provided iOS/Android versions.
36
+
37
+ ```json
38
+ {
39
+ "expo": {
40
+ "plugins": [
41
+ "@supertokens/rownd-react-native",
42
+ [
43
+ "expo-build-properties",
44
+ {
45
+ "android": {
46
+ "minSdkVersion": 26
47
+ },
48
+ "ios": {
49
+ "deploymentTarget": "14.0"
50
+ }
51
+ }
52
+ ]
53
+ ]
54
+ }
55
+ }
56
+ ```
57
+
58
+ 4. (optional) Enable Apple sign-in for iOS in your `app.json` file.
59
+
60
+ ```json
61
+ {
62
+ "expo": {
63
+ "ios": {
64
+ "usesAppleSignIn": true
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ 5. (optional) Enable Google sign-in for iOS. Add your Google IOS Client ID client as a URL Scheme in your `app.json` file.
71
+
72
+ ```json
73
+ {
74
+ "expo": {
75
+ "ios": {
76
+ "infoPlist": {
77
+ "CFBundleURLTypes": [
78
+ {
79
+ "CFBundleURLSchemes": [
80
+ "com.googleusercontent.apps.xxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxx"
81
+ ]
82
+ }
83
+ ]
84
+ }
85
+ }
86
+ }
87
+ }
88
+ ```
89
+
90
+ ### Android
91
+
92
+ 1. Ensure the Sdk versions match or are above provided versions. File: _android/build.gradle_
93
+
94
+ ```
95
+ ext {
96
+ ...
97
+ minSdkVersion = 26
98
+ compileSdkVersion = 33
99
+ targetSdkVersion = 31
100
+ ...
101
+ }
102
+ ```
103
+
104
+ 2. Install the Rownd library and dependencies.
105
+
106
+ ```sh
107
+ cd android && ./gradlew build
108
+ ```
109
+
110
+ 3. Check and update your ProGuard config using [the rules from our Android SDK](https://github.com/rownd/android/blob/main/README.md#proguard-config).
111
+
112
+ 4. Only required for Google Sign-in: Add a Rownd plugin initializer to your MainActivity file. File: \*android/app/src/main/java/.../MainActivity.java
113
+
114
+ ```
115
+ import android.os.Bundle;
116
+ import com.reactnativerowndplugin.RowndPluginPackage;
117
+
118
+ public class MainActivity extends ReactActivity {
119
+ @Override
120
+ protected void onCreate(Bundle savedInstanceState) {
121
+ super.onCreate(savedInstanceState);
122
+ RowndPluginPackage.preInit(this);
123
+ }
124
+ }
125
+ ```
126
+
127
+ ### iOS
128
+
129
+ 1. Ensure iOS version is at least 14. File: _ios/Podfile_
130
+
131
+ ```
132
+ platform :ios, '14.0'
133
+ ```
134
+
135
+ 2. Install the SuperTokens Rownd iOS SDK pod.
136
+
137
+ This package depends on `RowndSupertokens` `0.1.1`, which exposes the Swift module as `Rownd`. CocoaPods installs it automatically through `rownd-react-native.podspec`. If you want to pin it explicitly in your app, add this before `use_native_modules!`:
138
+
139
+ ```ruby
140
+ target '<YourApp>' do
141
+ pod 'RowndSupertokens', '~> 0.1.1'
142
+
143
+ config = use_native_modules!
144
+ # ...
145
+ end
146
+ ```
147
+
148
+ If CocoaPods trunk shows `RowndSupertokens` `0.1.1` but CDN name resolution has not propagated yet, temporarily source it from the release tag instead:
149
+
150
+ ```ruby
151
+ target '<YourApp>' do
152
+ pod 'RowndSupertokens',
153
+ :git => 'https://github.com/supertokens/supertokens-rownd-ios.git',
154
+ :tag => 'v0.1.1'
155
+
156
+ config = use_native_modules!
157
+ # ...
158
+ end
159
+ ```
160
+
161
+ 3. Install the Rownd pod and its dependencies.
162
+
163
+ ```sh
164
+ cd ios && pod install
165
+ ```
166
+
167
+ ## Setup
168
+
169
+ ### Enable deep linking
170
+
171
+ Rownd supports automatically signing-in users when they initially install your
172
+ app or when they click a sign-in link when the app is already installed.
173
+
174
+ Magic-link sign-in uses the native deep-link mechanism on both platforms. The
175
+ scheme configured in `RowndProvider` must match the scheme registered by your
176
+ host app.
177
+
178
+ ```tsx
179
+ <RowndProvider
180
+ config={{
181
+ appKey: '<your app key>',
182
+ supertokens: {
183
+ appInfo: {
184
+ appName: 'My App',
185
+ apiDomain: 'https://api.example.com',
186
+ apiBasePath: '/auth',
187
+ },
188
+ },
189
+ deepLinkScheme: 'rowndsupertokens',
190
+ }}
191
+ >
192
+ <App />
193
+ </RowndProvider>
194
+ ```
195
+
196
+ #### iOS
197
+
198
+ Register the scheme in `ios/<AppName>/Info.plist`.
199
+
200
+ ```xml
201
+ <key>CFBundleURLTypes</key>
202
+ <array>
203
+ <dict>
204
+ <key>CFBundleURLSchemes</key>
205
+ <array>
206
+ <string>rowndsupertokens</string>
207
+ </array>
208
+ </dict>
209
+ </array>
210
+ ```
211
+
212
+ Forward URL opens to React Native `Linking` from your app delegate. The Rownd
213
+ provider listens for those events and passes the link to the native SDK.
214
+
215
+ Objective-C:
216
+
217
+ ```objc
218
+ #import <React/RCTLinkingManager.h>
219
+
220
+ - (BOOL)application:(UIApplication *)application
221
+ openURL:(NSURL *)url
222
+ options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
223
+ {
224
+ return [RCTLinkingManager application:application openURL:url options:options];
225
+ }
226
+ ```
227
+
228
+ Swift:
229
+
230
+ ```swift
231
+ import React
232
+
233
+ override func application(
234
+ _ app: UIApplication,
235
+ open url: URL,
236
+ options: [UIApplication.OpenURLOptionsKey: Any] = [:]
237
+ ) -> Bool {
238
+ return RCTLinkingManager.application(app, open: url, options: options)
239
+ }
240
+ ```
241
+
242
+ #### Android
243
+
244
+ Register the scheme on the activity that hosts React Native. The activity should
245
+ use `singleTask` so links opened while the app is running are delivered to the
246
+ existing activity.
247
+
248
+ ```xml
249
+ <activity
250
+ android:name=".MainActivity"
251
+ android:exported="true"
252
+ android:launchMode="singleTask">
253
+ <intent-filter>
254
+ <action android:name="android.intent.action.VIEW" />
255
+ <category android:name="android.intent.category.DEFAULT" />
256
+ <category android:name="android.intent.category.BROWSABLE" />
257
+ <data android:scheme="rowndsupertokens" />
258
+ </intent-filter>
259
+ </activity>
260
+ ```
261
+
262
+ #### Expo
263
+
264
+ For Expo apps, set the same scheme in app config and use a development build or
265
+ prebuild so native URL scheme configuration is generated.
266
+
267
+ ```json
268
+ {
269
+ "expo": {
270
+ "scheme": "rowndsupertokens"
271
+ }
272
+ }
273
+ ```
274
+
275
+ If you customize native iOS or Android files after prebuild, keep the generated
276
+ scheme aligned with `config.deepLinkScheme`.
277
+
278
+ ## Usage
279
+
280
+ The Rownd SDK includes a context provider that will enable any component of your app to access authentication state and user data.
281
+
282
+ Before you can use the SDK, you'll need to obtain an App Key from the [Rownd Dashboard](https://app.rownd.io).
283
+
284
+ ```tsx
285
+ import { RowndProvider } from '@supertokens/rownd-react-native';
286
+
287
+ // ...
288
+
289
+ export default function Root() {
290
+ return (
291
+ <RowndProvider
292
+ config={{
293
+ appKey: '<your app key>',
294
+ supertokens: {
295
+ appInfo: {
296
+ appName: 'My App',
297
+ apiDomain: 'https://api.example.com',
298
+ apiBasePath: '/auth',
299
+ },
300
+ },
301
+ deepLinkScheme: 'rowndsupertokens',
302
+ }}
303
+ >
304
+ <App />
305
+ </RowndProvider>
306
+ );
307
+ }
308
+ ```
309
+
310
+ Later on within your app's components, you can use the Rownd hook to access the Rownd browser API:
311
+
312
+ ```tsx
313
+ import { View, Text, Pressable } from 'react-native';
314
+ import { useRownd } from '@supertokens/rownd-react-native';
315
+
316
+ export default function MyProtectedComponent(props) {
317
+ const { is_authenticated, user, requestSignIn, getAccessToken } = useRownd();
318
+
319
+ // You can also request a sign in without a user pressing a button
320
+ // by calling requestSignIn() from a useEffect callback.
321
+ // useEffect(() => {
322
+ // if (!is_authenticated) {
323
+ // requestSignIn();
324
+ // }
325
+ // }, [is_authenticated]);
326
+
327
+ return (
328
+ <View>
329
+ {is_authenticated ? (
330
+ <>
331
+ <Text>Welcome {user.data.first_name}</Text>
332
+ <Pressable onClick={() => getAccessToken()}>
333
+ <Text>Get access token</Text>
334
+ </Pressable>
335
+ </>
336
+ ) : (
337
+ <>
338
+ <Text>Please sign in to continue</Text>
339
+ <Pressable onPress={() => requestSignIn()}>
340
+ <Text>Sign in</Text>
341
+ </Pressable>
342
+ </>
343
+ )}
344
+ </View>
345
+ );
346
+ }
347
+ ```
348
+
349
+ ### Customizing the UI
350
+
351
+ Customizing the UI
352
+ While most customizations are handled via the [Rownd dashboard](https://app.rownd.io), there are a few things that have to be customized directly in the SDK.
353
+
354
+ The `customization` prop for `RowndProvider` allows specific customizations to be set:
355
+
356
+ - `sheetBackgroundHexColor: string` (Hex color) Allows changing the background color underlaying the bottom sheet that appears when signing in, managing the user account, transferring encryption keys, etc.
357
+ - `loadingAnimation: string` (JSON animation) Replace Rownd's use of the system default loading spinner with a custom animation. Any animation compatible with [Lottie](https://airbnb.design/lottie/) should work, but will be scaled to fit a 1:1 aspect ratio.
358
+ - `sheetCornerBorderRadius: string` (Number) Modifies the curvature radius of the bottom sheet corners.
359
+
360
+ ```tsx
361
+ const loadingAnimation = require('../assets/loading.json');
362
+
363
+ export default function App() {
364
+ return (
365
+ <View style={styles.container}>
366
+ <RowndProvider
367
+ config={{
368
+ appKey: '######-####-####-####-#########',
369
+ supertokens: {
370
+ appInfo: {
371
+ appName: 'My App',
372
+ apiDomain: 'https://api.example.com',
373
+ apiBasePath: '/auth',
374
+ },
375
+ },
376
+ deepLinkScheme: 'rowndsupertokens',
377
+ }}
378
+ customizations={{
379
+ sheetBackgroundHexColor: '#ffffff',
380
+ sheetCornerBorderRadius: '20',
381
+ loadingAnimation: JSON.stringify(loadingAnimation),
382
+ }}
383
+ >
384
+ <Main />
385
+ </RowndProvider>
386
+ </View>
387
+ );
388
+ }
389
+ ```
390
+
391
+ ## Running the examples
392
+
393
+ The plain React Native and Expo examples use `example-server/`, a local
394
+ `supertokens-node` backend configured with `@supertokens-plugins/rownd-nodejs`.
395
+ The examples default to the production Hub at `https://rownd-hub.supertokens.com`.
396
+
397
+ Create the backend env file and fill in your Rownd/SuperTokens credentials:
398
+
399
+ ```sh
400
+ cp example-server/.env.example example-server/.env
401
+ ```
402
+
403
+ Run the backend from this repo root:
404
+
405
+ ```sh
406
+ npm run example:server
407
+ ```
408
+
409
+ The apps use `http://10.0.2.2:3137` on Android emulator and
410
+ `http://127.0.0.1:3137` on iOS simulator. See `example/README.md` and
411
+ `example_expo/README.md` for app-specific commands.
412
+
413
+ ## Integration testing
414
+
415
+ The React Native example can run Android instrumentation tests against the same
416
+ SuperTokens/Rownd harness used by the Android SDK. This gives the RN bridge a
417
+ real backend, hub URL, app key, and deep-link configuration without adding a
418
+ separate test server.
419
+
420
+ Start the harness manually when debugging:
421
+
422
+ ```sh
423
+ npm run test:integration:harness
424
+ ```
425
+
426
+ Build the Android instrumentation APK without requiring a running emulator:
427
+
428
+ ```sh
429
+ npm run test:integration:android:build
430
+ ```
431
+
432
+ Run the Android integration tests on a connected emulator or device:
433
+
434
+ ```sh
435
+ npm run test:integration:android
436
+ ```
437
+
438
+ The harness runner passes these values to the Android test process:
439
+
440
+ - `ANDROID_HARNESS_URL`: harness URL reachable from the emulator
441
+ - `ANDROID_API_URL`: SuperTokens API domain for native SDK configuration
442
+ - `ANDROID_HUB_URL`: Hub URL for native sign-in UI
443
+ - `ANDROID_APP_KEY`: test Rownd app key
444
+
445
+ Current Android instrumentation coverage verifies that the harness is reachable
446
+ and that `rowndsupertokens://` magic links resolve to the React Native host
447
+ activity. Extend this suite for runtime auth flows such as anonymous sign-in,
448
+ magic-link completion, access-token retrieval, and sign-out.
449
+
450
+ ## API reference
451
+
452
+ Most API methods are made available via the Rownd Provider and its associated `useRownd` React hook. Unless otherwise noted, we're assuming that you're using hooks.
453
+
454
+ #### requestSignIn()
455
+
456
+ Trigger the Rownd sign in dialog
457
+
458
+ ```javascript
459
+ const { requestSignIn } = useRownd();
460
+
461
+ requestSignIn();
462
+ ```
463
+
464
+ #### signOut()
465
+
466
+ Sign out the user and clear their profile, returning them to a completely unauthenticated state.
467
+
468
+ ```javascript
469
+ const { signOut } = useRownd();
470
+ signOut();
471
+ ```
472
+
473
+ #### **getAccessToken()**
474
+
475
+ Retrieves the active, valid access token for the current user.&#x20;
476
+
477
+ ```javascript
478
+ const { getAccessToken } = useRownd();
479
+
480
+ let accessToken = await getAccessToken();
481
+ ```
482
+
483
+ #### is_authenticated
484
+
485
+ Indicates whether the current user is signed in or not.
486
+
487
+ ```javascript
488
+ const { is_authenticated } = useRownd();
489
+
490
+ return (
491
+ <>
492
+ {is_authenticated && <ProtectedRoute />}
493
+ {!is_authenticated && <PublicRoute />}
494
+ </>
495
+ );
496
+ ```
497
+
498
+ #### access_token
499
+
500
+ Represents the current access token for the user.
501
+
502
+ ```javascript
503
+ const { access_token } = useRownd();
504
+
505
+ useEffect(() => {
506
+ axios({
507
+ method: 'post',
508
+ url: '/api/sessions'
509
+ headers: {
510
+ authorization: `Bearer ${access_token}`
511
+ }
512
+ }).then(console.log);
513
+ }, [access_token]);
514
+ ```
515
+
516
+ #### user
517
+
518
+ Represents information about the current user, specifically their profile information. In the example below, we use the existing data to display the current value of `first_name` in a form field, update a local copy of that data as the user changes it, and then save the changes to Rownd once the user submits the form.
519
+
520
+ ```javascript
521
+ const { user } = useRownd();
522
+
523
+ return (
524
+ <form onSubmit={() => user.set(profile)}>
525
+ <Text>First name</Text>
526
+ <TextInput
527
+ value={user?.data?.first_name}
528
+ onChangeText={}
529
+ />
530
+ <Pressable onPress={}>Save</button>
531
+ </form>
532
+ );
533
+ ```
534
+
535
+ **Merge data into the user profile**
536
+
537
+ ```javascript
538
+ const { user } = useRownd();
539
+ user.set({
540
+ first_name: 'Alice',
541
+ last_name: 'Ranier',
542
+ });
543
+ ```
544
+
545
+ Set a specific field in the user profile
546
+
547
+ ```javascript
548
+ const { user } = useRownd();
549
+ user.setValue('first_name', 'Alice');
550
+ ```
551
+
552
+ ## License
553
+
554
+ Apache 2.0