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: support advanced initialization in v5 #9638

Merged
merged 8 commits into from Jan 16, 2024
Merged

Conversation

ThangHuuVu
Copy link
Member

☕️ Reasoning

Add support for advanced initialization for v5.

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

Fixes: #9455

📌 Resources

Copy link

vercel bot commented Jan 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 16, 2024 8:16pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Jan 16, 2024 8:16pm

apps/dev/nextjs/middleware.ts Show resolved Hide resolved
packages/next-auth/src/index.tsx Outdated Show resolved Hide resolved
packages/next-auth/src/index.tsx Outdated Show resolved Hide resolved
packages/next-auth/src/index.tsx Outdated Show resolved Hide resolved
ThangHuuVu and others added 2 commits January 17, 2024 03:12
Co-authored-by: Balázs Orbán <info@balazsorban.com>
@chrisivo
Copy link

Is there any way lazy initialisation can be executed asynchronously? I need to make async calls to obtain the Id's and secrets for the providers. I could do this using v4, but seems like there's no support in v5 beta (so far)?

@ndom91
Copy link
Member

ndom91 commented May 16, 2024

@chrisivo what do you mean exactly? The first argument to NextAuth() can be an async function. So yuo can do this (as is shown in most examples):

export const { auth, signIn, signOut } = NextAuth({
  providers: [ ... ],
  debug: true
})

But yuo can also do this:

export const { auth, signIn, signOut } = NextAuth(async (req) => {
  return {
    providers: [ ... ],
    debug: true
  }
))

EDIT: Sorry, just double checked and this seems to only be the case for the SvelteKit client. next-auth only seems to take synchronous functions as an alternative 🙏

@chrisivo
Copy link

chrisivo commented May 19, 2024

Thanks for the response @ndom91.

Is there any roadmap at all for introducing asynchronous functions when initialising in next-auth ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Advanced initialization with Auth.Js 5
4 participants