Adding Authentication Providers
Auth Rush comes pre-configured with three authentication providers: Credentials (email and password), Google, and GitHub. These providers are defined in the @/auth.config.ts
file:
// imports...
export default {
providers: [
Google({
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
}),
Github({
clientId: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
}),
Credentials({
// ...
}),
],
} satisfies NextAuthConfig;
Adding a New Provider
To add a new authentication provider, you can follow the same pattern as the existing providers. First, import the provider from the next-auth/providers
package, then add it to the providers
array in the auth.config.ts
file.
For example, to add LinkedIn authentication, you can do the following:
- Import the LinkedIn provider:
import LinkedIn from "next-auth/providers/linkedin";
- Add the LinkedIn provider to the
providers
array with the required configuration:
export default {
providers: [
// ... existing providers
LinkedIn({
clientId: process.env.LINKEDIN_CLIENT_ID,
clientSecret: process.env.LINKEDIN_CLIENT_SECRET,
}),
],
} satisfies NextAuthConfig;
- Add the corresponding environment variables (
LINKEDIN_CLIENT_ID
andLINKEDIN_CLIENT_SECRET
) to your.env
file.
💡
You can find the list of available providers and their configuration options in the NextAuth.js documentation (opens in a new tab).