Walkthrough
Authentication
Core guide to Auth.js v5 integration in StarterKitPro.
StarterKitPro uses Auth.js v5 for user authentication.
Configuration
- Main Setup: Configure providers and core settings in
auth.config.ts
orauth.ts
. - Redirects: Set post-login/logout URLs in
config/app-config.ts
(e.g.,auth.afterLogin
).
Authentication Methods
StarterKitPro includes these by default, presented via components/forms/user-auth-form.tsx
:
- Magic Link: Passwordless email login. See Magic Link Setup (link to be created/updated).
- Google OAuth: Sign in with Google. See Google Auth Setup (link to be created/updated).
Adding other providers like Twitter, GitHub, etc., is straightforward by updating the Auth.js configuration. See Adding Providers (link to be created/updated).
Accessing the Session
Client-Side (React Components)
Use the useSession
hook:
Server-Side (Server Components, API Routes, Server Actions)
Use the auth()
helper function:
Auth.js handles session tokens automatically. You don't need to pass them manually between frontend and backend within the app.