jasny
jasny
TTCTheo's Typesafe Cult
Created by Gabriel on 8/28/2023 in #questions
Help in Nextauth EmailProvider
This seems to be a typing bug in the next-auth library and not an actual problem. I ended up just overwriting the type of the options property to satisfy the Provider type: as EmailConfig & { options: Record<string, unknown> }.
export const authOptions: NextAuthOptions = {
adapter: PrismaAdapter(prisma),
session: {
strategy: "jwt",
},
providers: [
GitHubProvider({
clientId: process.env.GITHUB_CLIENT_ID!,
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
}),
EmailProvider({
server: {
host: process.env.EMAIL_SERVER_HOST,
port: +(process.env.EMAIL_SERVER_PORT as string),
auth: {
user: process.env.EMAIL_SERVER_USER,
pass: process.env.EMAIL_SERVER_PASSWORD,
},
},
from: process.env.EMAIL_FROM,

sendVerificationRequest: verificationRequest,
}) as EmailConfig & { options: Record<string, unknown> },
],
export const authOptions: NextAuthOptions = {
adapter: PrismaAdapter(prisma),
session: {
strategy: "jwt",
},
providers: [
GitHubProvider({
clientId: process.env.GITHUB_CLIENT_ID!,
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
}),
EmailProvider({
server: {
host: process.env.EMAIL_SERVER_HOST,
port: +(process.env.EMAIL_SERVER_PORT as string),
auth: {
user: process.env.EMAIL_SERVER_USER,
pass: process.env.EMAIL_SERVER_PASSWORD,
},
},
from: process.env.EMAIL_FROM,

sendVerificationRequest: verificationRequest,
}) as EmailConfig & { options: Record<string, unknown> },
],
13 replies