Use an async database url #1810
Answered
by
balazsorban44
italodeandra
asked this question in
Help
-
I need to do something like this: export default NextAuth({
providers: [
Providers.GitHub({
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET
}),
],
database: await getDatabaseConnection(),
}) Is it by any means, possible with NextAuth? |
Beta Was this translation helpful? Give feedback.
Answered by
balazsorban44
Apr 22, 2021
Replies: 1 comment 3 replies
-
Yes, totally! export default async function nextAuthHandler(req, res) {
return NextAuth(req, res, {
providers: [
Providers.GitHub({
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET
}),
],
database: await getDatabaseConnection(),
})
} At the end of the day, The currently advertised way was introduced in #868 but you probably have seen many tutorials/people still doing: export default (req, res) => NextAuth(req, res, options) The new way is just easier on the eye in my opinion, so I try to use it whenever possible. |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
balazsorban44
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, totally!
At the end of the day,
NextAuth
is just a nice wrapper for a Next.js API route handler 🙂The currently advertised way was introduced in #868
but you probably have seen many tutorials/people still doing:
The new way is just easier on the eye in my opinion, so I try to use it whenever possible.