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

# Accessing Users

## Four ways to access a user

### Overview

When a new user signs up, Dynamic creates a new user record in the database including their general information, and verified credentials.

There are four main ways you can programmatically access this new user record as soon as it's been created:

1. **handleAuthenticatedUser** handler: You can access the user record in the `handleAuthenticatedUser` handler before authentication even completes.
2. **User Created Webhook**: You can listen for the `user.created` event and access the user record from the event payload.
3. **User Created Callback**: You can use the onAuthSuccess callback and access the user record from the returned values.
4. **useDynamicContext hook** (React only): You can access the user record from the `user` object in the context.

### handleAuthenticatedUser Handler

Dynamic has a concept of ["handlers"](/react-sdk/overview#handlers), which is a particular kind of callback to allow custom code to run as part of a process (i.e. signup).

One such handler is called handleAuthenticatedUser, and it allows for custom code to receive the user object and do something with it, before the Dynamic SDK finishes the authentication flow and closes the UI.

<Tip>The args returned by handleAuthenticatedUser is a [UserProfile](/react-sdk/objects/userprofile).</Tip>

```jsx
<DynamicContextProvider
  settings={{
    handlers: {
      handleAuthenticatedUser: async (args) => {
        console.log("handleBeforeAuth was called", args);

        await customUserObjectProcess(args.user);
      },
    },
  }}
>
  {/* ... rest of your app ... */}
</DynamicContextProvider>
```

## User Created Webhook

One of the valid webhook events you can listen to is called `user.created` (learn more about event types [here](http://localhost:3001/developer-dashboard/eventTypes)).

All you will need to get started is a server that can receive events, and then you can plug in that URL in the dashboard. [Learn more about setting up the webhook step by step here](/developer-dashboard/webhooks#setting-up-webhooks).

## onAuthSuccess Event

The Dynamic SDK has a concept called [Events](/react-sdk/events/events-introduction) which allows you to hook into lifycycle events of the SDK. One such event is called \[]`onAuthSuccess`]\(/react-sdk/events/onauthsuccess), which is called when the user has successfully authenticated.

This event returns a user object that you can access and do something with.

```jsx
<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](/react-sdk/hooks/usedynamiccontext) will give you access to the `user` object.

```jsx
import { useDynamicContext } from '@dynamic/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](/react-sdk/objects/userprofile) 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 title="What next?" href="/users/verified-credential" icon="link" color="#4779FE">
  Click here to learn more about Verified Credentials
</Card>
