Skip to content

Getting started with authentication

Account Kit makes it really easy to authenticate your users using a number of different authentication methods. If you followed the quickstart, then your app is already setup to authenticate users and you can skip this guide!

We'll show you two different ways to authenticate users:

  1. Using our UI components to handle the entire authentication flow.
  2. Using our React hooks to build your own custom UI.

Setup

If you haven't followed the quickstart guide, make sure to set up the following first:

  1. Get your API key by creating a new app in your Alchemy Dashboard

  2. Create a new account config in your Account Kit Dashboard

    1. Apply the config to your app from step 1

      apply your the config to the app from the first step
    2. Enable authentication methods you want to support.


      Email auth

      If you want to use email auth, toggle on email.

      • For testing, use http://localhost:3000 as the Redirect URL (Note http not https)
      • The user will be redirected to the Redirect URL when they click the magic link in the email
      • Optionally stylize ✨ the email with your brand color and logo!
      configure email auth
      Social auth

      If you want to enable social login, toggle which auth providers you want to support.

      • For testing, add http://localhost:3000 as a whitelisted origin

      • Add the link that your dapp will be running on to the whitelisted origin list

      • Optionally enter your own OAuth credentials or use our defaults

        configure social auth
  3. Create the config and copy the API Key

    how to copy the api key

...and paste the API key into your app's config.ts

config.ts
// ...other stuff in the file
export const config = createConfig(
  {
    transport: alchemy({ apiKey: "ALCHEMY_API_KEY" }), // TODO: add your Alchemy API key - https://dashboard.alchemy.com/accounts
    chain: sepolia,
    ssr: true, // more about ssr: https://accountkit.alchemy.com/react/ssr
    storage: cookieStorage, // more about persisting state with cookies: https://accountkit.alchemy.com/react/ssr#persisting-the-account-state
    enablePopupOauth: true, // must be set to "true" if you plan on using popup rather than redirect in the social login flow
  },
  uiConfig
);
// ...other stuff in the file

What's next?

Now you can setup your application's logic and UI to handle authentication! You'll be able to integrate authentication in one of two ways:

  1. With our UI components to handle the entire authentication flow.
  2. With our React hooks to build your own custom UI.