diff --git a/docs/src/pages/[platform]/connected-components/authenticator/headless/advanced/current-route.react-native.mdx b/docs/src/pages/[platform]/connected-components/authenticator/headless/advanced/current-route.react-native.mdx new file mode 100644 index 00000000000..9fd019f3f8b --- /dev/null +++ b/docs/src/pages/[platform]/connected-components/authenticator/headless/advanced/current-route.react-native.mdx @@ -0,0 +1,27 @@ +You can use `useAuthenticator` hook to access `route` string that represents the current `authState`. They can be one of: + +- `idle` +- `setup` +- `signIn` +- `signUp` +- `confirmSignIn` +- `confirmSignUp` +- `setupTOTP` +- `forceNewPassword` +- `resetPassword` +- `confirmResetPassword` +- `verifyUser` +- `confirmVerifyUser` +- `signOut` +- `authenticated` + +```jsx +import { useAuthenticator } from '@aws-amplify/ui-react-native'; + +const App = () => { + const { route } = useAuthenticator(context => [context.route]); + + // Use the value of route to decide which page to render + return route === 'authenticated' ? : ; +}; +``` diff --git a/docs/src/pages/[platform]/connected-components/authenticator/headless/advanced/current-user.react-native.mdx b/docs/src/pages/[platform]/connected-components/authenticator/headless/advanced/current-user.react-native.mdx new file mode 100644 index 00000000000..c3f34a96f21 --- /dev/null +++ b/docs/src/pages/[platform]/connected-components/authenticator/headless/advanced/current-user.react-native.mdx @@ -0,0 +1,17 @@ +You can use `useAuthenticator` hook to access current signed in `user`. If no user is authenticated, it'll return `undefined`. + +```jsx +import { View, Text, Button } from 'react-native'; +import { useAuthenticator } from '@aws-amplify/ui-react-native'; + +const Home = () => { + const { user, signOut } = useAuthenticator((context) => [context.user]); + + return ( + + {`Welcome, ${user.username}!`} +