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: docs/mobile/index.md
+10-22Lines changed: 10 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,39 +25,27 @@ When using this library don't import `@nostr-dev-kit/ndk` directly, instead impo
25
25
26
26
Initialize NDK using the init function, probably when your app loads.
27
27
28
-
```tsx
29
-
function App() {
30
-
const { ndk, init: initializeNDK } =useNDK();
31
-
32
-
useEffect(() => {
33
-
initializeNDK({
34
-
/* Any parameter you'd want to pass to NDK */
35
-
explicitRelayUrls: [...],
36
-
// ...
37
-
}
38
-
}, []);
39
-
}
40
-
```
41
-
42
-
### Settings
43
-
44
28
Throughout the use of a normal app, you will probably want to store some settings, such us, the user that is logged in. `ndk-mobile` can take care of this for you automatically if you pass a `settingsStore` to the initialization. For example, using `expo-secure-store` you can:
45
29
46
30
```tsx
47
31
import*asSecureStorefrom'expo-secure-store';
48
32
33
+
const ndk =newNDK({
34
+
/* Any parameter you'd want to pass to NDK */
35
+
explicitRelayUrls: [...],
36
+
// ...
37
+
})
38
+
49
39
const settingsStore = {
50
40
get: SecureStore.getItemAsync,
51
41
set: SecureStore.setItemAsync,
52
42
delete: SecureStore.deleteItemAsync,
53
43
getSync: SecureStore.getItem,
54
44
};
55
45
56
-
// and then, when you initialiaze NDK:
57
-
initializeNDK({
58
-
......,
59
-
settingsStore
60
-
})
46
+
function App() {
47
+
useNDKInit(ndk, settingsStore);
48
+
}
61
49
```
62
50
63
51
Now, once your user logs in, their login information will be stored locally so when your app restarts, the user will be logged in automatically.
@@ -81,4 +69,4 @@ function LoginScreen() {
81
69
82
70
## Example
83
71
84
-
For a real application using this look at [Olas](https://github.com/pablof7z/snapstr).
72
+
For a real application using this look at [Olas](https://github.com/pablof7z/olas).
0 commit comments