> ## 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.

# Accessing Users

> [card] 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)](https://docs.dynamic.xyz/docs/javascript/reference/react-quickstart.md) to get started.

### Overview

When a new user signs up, Dynamic creates a new user record in the database including their general information, and verified credentials. You can access that user via a webhook, or using SDK specific methods.

## User Created Webhook

One of the valid webhook events you can listen to is called `user.created` (learn more about event types [here](https://docs.dynamic.xyz/docs/platform/console/webhooks/events.md)).

All you will need to get started is a server that can receive events, and then you can plug in that URL in the Dynamic Console. [Learn more about setting up the webhook step by step here](https://docs.dynamic.xyz/docs/platform/console/webhooks/setup.md).

## SDK Specific Methods

### handleAuthenticatedUser Handler

> [!TIP]
>
> The args returned by handleAuthenticatedUser is a [UserProfile](https://docs.dynamic.xyz/docs/react/reference/objects/userprofile.md).

```tsx React theme={"system"}
<DynamicContextProvider
  settings={{
    handlers: {
      handleAuthenticatedUser: async (args) => {
        console.log("handleBeforeAuth was called", args);
        await customUserObjectProcess(args.user);
      },
    },
  }}
>
  {/* ... rest of your app ... */}
</DynamicContextProvider>
```

## onAuthSuccess Event

The SDK exposes [Events](https://docs.dynamic.xyz/docs/react/reference/events/events-introduction.md) which allow you to hook into lifecycle events. One such event is [`onAuthSuccess`](https://docs.dynamic.xyz/docs/react/reference/events/onauthsuccess), which runs when the user has successfully authenticated.

```tsx React theme={"system"}
<DynamicContextProvider
  settings={{
    events: {
      onAuthSuccess: (args) => {
        console.log('user', args.user);
      }
    }
  }}
>
{/* ... rest of your app ... */}
</DynamicContextProvider>
```

## useDynamicContext

Once placed anywhere inside the component tree that is wrapped by the `DynamicContextProvider`, [the `useDynamicContext` hook](https://docs.dynamic.xyz/docs/react/reference/hooks/usedynamiccontext) will give you access to the `user` object.

```tsx React theme={"system"}
import { useDynamicContext } from '@dynamic-labs/sdk-react-core';

function MyComponent() {
  const { user } = useDynamicContext();
  console.log('user', user);
  return <div>My Component</div>;
}
```

## User Format

This user record follows a specific format, which you can read all about in the [User](https://docs.dynamic.xyz/docs/react/reference/objects/userprofile.md) reference.

One important array inside that user object will be called `verified_credentials`. This is where you'll find information about any and every associated "credential" for the user i.e. email, social, blockchain, passkey.

> [card] [What next?](https://docs.dynamic.xyz/docs/react/users/verified-credential.md)
>
> Click here to learn more about Verified Credentials


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.