Skip to content

Commit d4db308

Browse files
authored
Create basic react-native integration guide (#770)
1 parent 1dcb9f3 commit d4db308

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

website/docs/cookbook/react-native.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
id: react-native
3+
title: react-native
4+
sidebar_label: react-native
5+
---
6+
7+
By default accounts-js use the `localStorage` api to store the tokens.
8+
9+
Since react-native does not have `localStorage`, we can use the [React Native Async Storage](https://github.com/react-native-community/async-storage).
10+
11+
To setup the client to use the AsyncStorage api you need to apply the following configuration:
12+
13+
```javascript
14+
import AsyncStorage from '@react-native-community/async-storage';
15+
import { AccountsClient } from '@accounts/client';
16+
17+
const accounts = new AccountsClient({
18+
// We tell the accounts-js client to use AsyncStorage to store the tokens
19+
tokenStorage: AsyncStorage,
20+
});
21+
```

website/sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = {
1717
'strategies/oauth',
1818
'strategies/twitter',
1919
],
20+
Cookbook: ['cookbook/react-native'],
2021
},
2122
api: {
2223
'Api Docs': [

0 commit comments

Comments
 (0)