> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# useIsLoggedIn

<Card title="Recommended: JavaScript SDK with React Hooks" icon="react" color="#4779FE">
  For new React apps, we recommend the JavaScript SDK with React Hooks (`@dynamic-labs-sdk/react-hooks`) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the [React quickstart (JavaScript SDK)](/javascript/reference/react-quickstart) to get started.
</Card>

### Summary

This hook determines whether a user is logged in or not.
The hook needs to be initialized within a child of [DynamicContextProvider](/react/reference/providers/dynamiccontextprovider).

### Usage

```TypeScript theme={"system"}
import { useIsLoggedIn } from '@dynamic-labs/sdk-react-core';

const MyComponent = () => {
  const isLoggedIn = useIsLoggedIn();

  return (
    <div>
      {isLoggedIn ? (
        <p>You are logged in!</p>
      ) : (
        <p>Please log in to continue.</p>
      )}
    </div>
  );
};

export default MyComponent;
```

### Return Value

The hook returns a boolean value indicating whether the user is logged in or not.

### Details

The hook first checks if the user object exists or if the authMode is 'connect-only' and a primaryWallet exists. If either of these conditions is true, the user is considered logged in.

Next, it checks the user should have a primaryWallet due to embedded wallets being enabled. If the user should have a promaryWallet and it doesn't exist, the user is not considered logged in, otherwise, they are considered logged in.
