Skip to main content

Recommended: JavaScript SDK with React Hooks

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) to get started.

Summary

This hook determines whether a user is logged in or not. The hook needs to be initialized within a child of DynamicContextProvider.

Usage

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.
Last modified on June 25, 2026