|
| 1 | +--- |
| 2 | +title: Getting started with authentication |
| 3 | +description: Setting up your React application to use Account Kit authentication |
| 4 | +--- |
| 5 | + |
| 6 | +import Snippet from "../../shared/get-api-key.mdx"; |
| 7 | +import AuthenticationMethods from "./shared/authentication-methods.mdx"; |
| 8 | + |
| 9 | +# Getting started with authentication |
| 10 | + |
| 11 | +Account Kit makes it really easy to authenticate your users using a number of different authentication methods. If you followed the [quickstart](/react/quickstart), then your app is already setup to authenticate users and you can skip this guide! |
| 12 | + |
| 13 | +## Implementation Options |
| 14 | + |
| 15 | +For each authentication method, you have two implementation options: |
| 16 | + |
| 17 | +1. [**Pre-built UI Components**](/react/ui-components) - Ready-to-use components that handle the entire authentication flow with minimal code and customizable styling. |
| 18 | + |
| 19 | +2. [**Custom UI with React Hooks**](/react/react-hooks) - Build your own UI components using our React hooks for complete control over the user experience. |
| 20 | + |
| 21 | +## Authentication Methods |
| 22 | + |
| 23 | +Account Kit supports several authentication methods: |
| 24 | + |
| 25 | +<AuthenticationMethods /> |
| 26 | + |
| 27 | +# Setup |
| 28 | + |
| 29 | +If you haven't followed the [quickstart guide](/react/quickstart), make sure to set up the following first: |
| 30 | + |
| 31 | +<Snippet /> |
| 32 | + |
| 33 | +...and paste the API key into your app's `config.ts` |
| 34 | + |
| 35 | +```ts twoslash [config.ts] |
| 36 | +import { AlchemyAccountsUIConfig, createConfig } from "@account-kit/react"; |
| 37 | +import { sepolia, alchemy } from "@account-kit/infra"; |
| 38 | + |
| 39 | +// Define UI configuration for authentication components |
| 40 | +// See individual login method pages for detailed configuration options |
| 41 | +const uiConfig: AlchemyAccountsUIConfig = { |
| 42 | + auth: { |
| 43 | + sections: [ |
| 44 | + [ |
| 45 | + // Example: Email OTP authentication |
| 46 | + { |
| 47 | + type: "email", |
| 48 | + emailMode: "otp", |
| 49 | + }, |
| 50 | + // You can add more authentication methods here |
| 51 | + // See login method pages for available options |
| 52 | + ], |
| 53 | + ], |
| 54 | + }, |
| 55 | +}; |
| 56 | + |
| 57 | +export const config = createConfig( |
| 58 | + { |
| 59 | + transport: alchemy({ apiKey: "ALCHEMY_API_KEY" }), // TODO: add your Alchemy API key - https://dashboard.alchemy.com/accounts |
| 60 | + chain: sepolia, |
| 61 | + ssr: true, // more about ssr: https://accountkit.alchemy.com/react/ssr |
| 62 | + enablePopupOauth: true, // must be set to "true" if you plan on using popup rather than redirect in the social login flow |
| 63 | + // For more about persisting state with cookies, see: https://accountkit.alchemy.com/react/ssr#persisting-the-account-state |
| 64 | + // storage: cookieStorage, |
| 65 | + }, |
| 66 | + uiConfig |
| 67 | +); |
| 68 | +``` |
| 69 | + |
| 70 | +# What's next? |
| 71 | + |
| 72 | +Now you can choose which authentication methods you want to implement and how you want to implement them: |
| 73 | + |
| 74 | +1. [Using our Pre-built UI components](/react/ui-components) to handle the entire authentication flow with minimal code. |
| 75 | +2. [Using our React hooks](/react/react-hooks) to build your own custom UI for complete control. |
| 76 | + |
| 77 | +Each authentication method has dedicated documentation for both implementation approaches. |
| 78 | + |
| 79 | +## Enhancing Security with Multi-Factor Authentication |
| 80 | + |
| 81 | +After implementing your chosen authentication methods, you can add an extra layer of security by enabling multi-factor authentication (MFA): |
| 82 | + |
| 83 | +You can enable [multi-factor authentication (MFA)](/react/mfa/setup-mfa) via authenticator apps (TOTP). These generate time-based one-time passcodes in an app like Google Authenticator or Authy. When users log in via Email OTP, Magic Link, or Social Login, they'll be prompted for their 6-digit TOTP code if MFA is enabled. |
| 84 | + |
| 85 | +Multi-factor authentication significantly improves account security by requiring users to verify their identity using both their primary authentication method and a time-based code from an authenticator app. |
0 commit comments