reactjslaravelinertiajs

How to access auth user in inertial react


I want to access the auth user to my navigation page, How to do this in inertia react?

this code works for Vue but doesn't work in react js

$page.props.auth.user

thanks


Solution

  • I got by using inertia usePage

    import { usePage } from "@inertiajs/react";
    
    const user = usePage();
    

    now i can access the auth user {user.name}