Skip to content

Commit 876567c

Browse files
committed
Add example in auth docs
1 parent c6e9161 commit 876567c

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

docs-devsite/auth.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,28 @@ export declare function getReactNativePersistence(storage: ReactNativeAsyncStora
250250

251251
[Persistence](./auth.persistence.md#persistence_interface)
252252

253+
### Example
254+
255+
256+
```javascript
257+
import { initializeAuth, getReactNativePersistence } from 'firebase/auth';
258+
259+
// For @react-native-async-storage/async-storage v3:
260+
import { createAsyncStorage } from '@react-native-async-storage/async-storage';
261+
const appStorage = createAsyncStorage('app');
262+
const persistence = getReactNativePersistence(appStorage);
263+
264+
// For @react-native-async-storage/async-storage v2:
265+
// import ReactNativeAsyncStorage from '@react-native-async-storage/async-storage';
266+
// const persistence = getReactNativePersistence(ReactNativeAsyncStorage);
267+
268+
// Then, initialize auth:
269+
const auth = initializeAuth(app, {
270+
persistence
271+
});
272+
273+
```
274+
253275
## function(auth, ...)
254276

255277
### applyActionCode(auth, oobCode) {:#applyactioncode_d2ae15a}

packages/auth/src/platform_react_native/persistence/react_native.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,25 @@ import {
3030
* `react-native` or `@react-native-async-storage/async-storage`, and can
3131
* be used in the persistence dependency field in {@link initializeAuth}.
3232
*
33+
* @example
34+
* ```javascript
35+
* import { initializeAuth, getReactNativePersistence } from 'firebase/auth';
36+
*
37+
* // For @react-native-async-storage/async-storage v3:
38+
* import { createAsyncStorage } from '@react-native-async-storage/async-storage';
39+
* const appStorage = createAsyncStorage('app');
40+
* const persistence = getReactNativePersistence(appStorage);
41+
*
42+
* // For @react-native-async-storage/async-storage v2:
43+
* // import ReactNativeAsyncStorage from '@react-native-async-storage/async-storage';
44+
* // const persistence = getReactNativePersistence(ReactNativeAsyncStorage);
45+
*
46+
* // Then, initialize auth:
47+
* const auth = initializeAuth(app, {
48+
* persistence
49+
* });
50+
* ```
51+
*
3352
* @public
3453
*/
3554
export function getReactNativePersistence(

0 commit comments

Comments
 (0)