Authentication Providers
Auth.js supports multiple authentication providers to give your users flexibility in how they sign in to your application. This page documents the providers configured for your portfolio application.
Available Providers
Adding a New Provider
To add a new authentication provider to your application, follow these steps:
- Install the provider package (if needed)
- Configure environment variables in
.env.local - Add the provider to your Auth.js configuration
Example: Adding a New Provider
Here's an example of how to add a new provider to your Auth.js configuration:
// In auth.ts
import NewProvider from "next-auth/providers/new-provider"
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [
// Existing providers...
NewProvider({
clientId: process.env.NEW_PROVIDER_ID,
clientSecret: process.env.NEW_PROVIDER_SECRET,
// Additional provider-specific options
}),
],
// Rest of your configuration
})
Provider Configuration
Each provider requires specific environment variables to be set in your .env.local file. Refer to the individual provider documentation for details on the required variables.
Provider Callbacks
Auth.js allows you to customize the behavior of providers through callbacks. These are defined in your Auth.js configuration:
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [
// Your providers...
],
callbacks: {
async signIn({ user, account, profile }) {
// Custom sign-in logic
return true
},
// Other callbacks...
},
})