Skip to main content
import { useStytchUser } from '@stytch/nextjs';

export const Home = () => {
  const { user, isInitialized } = useStytchUser();

  if (!isInitialized) {
    return <p>Loading...</p>;
  }

  return user ? <p>Welcome, {user.name.first_name}</p> : <p>Log in to continue!</p>;
};
{
  "user": { ... },
  "isInitialized": true,
  "fromCache": false
}
To get the currently signed in User, use the useStytchUser hook. If no User is signed in, the user object will be null. In non-React environments, use the user.getSync method to get the User.

Return Value

user
object | null
The current User.
fromCache
boolean
Whether the User data is from persistent storage.