Guide
Get Details
Fetch User

Now that the user is authenticated and has an Okto wallet, you can fetch the user details from Okto and display them in the app.

Fetch User Details

First, let's create a new screen with the name user-profile.tsx. Fetch the user details using getUserDetails from Okto and store them in a state.

screens/user-profile.tsx
import { useOkto, type OktoContextType, type User} from 'okto-sdk-react-native';
import React, { useState } from 'react';
import { View, Text } from "react-native";
 
const UserProfileScreen = () => {
    const { getUserDetails } = useOkto() as OktoContextType;
    const [userDetails, setUserDetails] = useState<User | null>(null);
 
    React.useEffect(() => {
        getUserDetails()
              .then((result) => {
                setUserDetails(result);
              })
              .catch((error) => {
                console.error(`error:`, error);
              });
    }, []);
 
    return (
        <View style={{ flex: 1, backgroundColor: '#fff' }}>
            <Text>User Details</Text>
            {userDetails && <View>
                <Text>{userDetails.user_id}</Text>
                <Text>{userDetails.email}</Text>
            </View>}
        </View>
    );
};
 
export default UserProfileScreen;

Now that the user details are displayed, in the next step, we will fetch the user's wallet details and display them in the app.