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. handleVerifiedUser handler: You can access the user record in the handleVerifiedUser handler before authentication even completes.
  2. User Created Webook: 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.

handleVerifiedUser Handler

Dynamic has a concept of “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 handleVerifiedUser, 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.

The args returned by handleVerifiedUser is a UserProfile.
<DynamicContextProvider
  settings={{
    handlers: {
      handleVerifiedUser: async (args) => {
        console.log("handleBeforeAuth was called", args);

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

User Created Webhook

User Format

This user record follows a specific format, which you can read all about in the User 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.

What next?

Click here to learn more about Verified Credentials