Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: simplify NextAuth instantiation #867

Merged
merged 4 commits into from Dec 5, 2020

Conversation

balazsorban44
Copy link
Member

@balazsorban44 balazsorban44 commented Nov 20, 2020

import NextAuth from 'next-auth'

const options = {
  //...
}

- export default (req, res) => NextAuth(req, res, options)
+ export default NextAuth(options)

We could simplify the NextAuth instance even further, by checking the number of arguments. If there is only one argument, the default function in server/index.js could return a NextApiHandler. Otherwise preserve the current behaviour, for backwards compatibility.

Fixes #868

@vercel
Copy link

vercel bot commented Nov 20, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nextauthjs/next-auth/48kcjhjdf
✅ Preview: https://next-auth-git-patch-2.nextauthjs.vercel.app

@vercel vercel bot temporarily deployed to Preview November 20, 2020 12:29 Inactive
@vercel vercel bot temporarily deployed to Preview November 20, 2020 12:45 Inactive
@balazsorban44 balazsorban44 added the enhancement New feature or request label Dec 5, 2020
@vercel vercel bot temporarily deployed to Preview December 5, 2020 09:23 Inactive
@vercel vercel bot temporarily deployed to Preview December 5, 2020 09:31 Inactive
@balazsorban44 balazsorban44 added the documentation Relates to documentation label Dec 5, 2020
@balazsorban44 balazsorban44 changed the title Simplify NextAuth instantiation feat: simplify NextAuth instantiation Dec 5, 2020
@balazsorban44 balazsorban44 merged commit b86ffa5 into nextauthjs:main Dec 5, 2020
@balazsorban44 balazsorban44 deleted the patch-2 branch December 5, 2020 09:34
balazsorban44 added a commit that referenced this pull request Dec 5, 2020
@balazsorban44 balazsorban44 restored the patch-2 branch December 5, 2020 09:40
@balazsorban44 balazsorban44 deleted the patch-2 branch December 5, 2020 10:11
@kripod
Copy link
Contributor

kripod commented Dec 30, 2020

Great change!

Typings should be updated accordingly in the DefinitelyTyped project, so TypeScript users may also benefit from this change.

@github-actions
Copy link

github-actions bot commented Feb 1, 2021

🎉 This PR is included in version 3.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Relates to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simplify next-auth initialization
2 participants