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

Export NextAuthRequest type from next-auth root #12207

Merged
merged 3 commits into from
Feb 6, 2025

Conversation

mahady-manana
Copy link
Contributor

☕️ Reasoning

Hello,
the NextAuthRequest type is not exported from next-auth, but it is very useful to be able to import it in your code when working with next api route.

There are many reason for it to be useful, but the most common, I think, is when you forward the req params of auth(req => {...}) in api route.

export const POST = auth((req) => {
  try {
    const searchParams = req.nextUrl.searchParams;
    const query = searchParams.get("q");
    switch (query) {
      case "create-x":
        return createSomeStuff(req); // if you want this function typed
      case "create-y":
        return createSomeStuffss(req); // if you want this function typed;
      case "create-z":
        return createSomeStuffssxx(req); // if you want this function typed;
      default:
        break;
    }
  } catch (error) {
    // catch
  }
});

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

📌 Resources

Copy link

vercel bot commented Nov 9, 2024

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

Name Status Preview Comments Updated (UTC)
auth-docs 🛑 Canceled (Inspect) Feb 6, 2025 7:09pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Feb 6, 2025 7:09pm

Copy link

vercel bot commented Nov 9, 2024

@mahady-manana is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

stale bot commented Jan 21, 2025

It looks like this issue did not receive any activity for 60 days. It will be closed in 7 days if no further activity occurs. If you think your issue is still relevant, commenting will keep it open. Thanks!

@stale stale bot added the stale Did not receive any activity for 60 days label Jan 21, 2025
Copy link

stale bot commented Feb 1, 2025

To keep things tidy, we are closing this issue for now. If you think your issue is still relevant, leave a comment and we might reopen it. Thanks!

@balazsorban44 balazsorban44 merged commit 85815a6 into nextauthjs:main Feb 6, 2025
4 of 6 checks passed
@vercel vercel bot temporarily deployed to Preview – auth-docs February 6, 2025 19:09 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next-auth stale Did not receive any activity for 60 days
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants