-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
chore(docs): new guide for sending email via http api #6555
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
|
||
First, clone and setup a basic Auth.js project like the the one [provided in our example repo](https://github.com/nextauthjs/next-auth-example.git). I won't go into the details of setting up your project for Auth.js's [Email provider](https://next-auth.js.org/providers/email), but you will need to make at least the following modifications to the example repository, or any other project you're adding this support to, including: | ||
|
||
- Install `nodemailer` as a dependency. The email provider also requires the use of a database adapter for Auth.js. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Install `nodemailer` as a dependency. The email provider also requires the use of a database adapter for Auth.js. |
the point of this guide is to not need nodemailer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but you need it for the Email provider atm. It'll complain if you don't install it. I guess we can modify that in core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the text actually since its a default dependency in the example-repo as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll complain if you don't install it
Right, because we have the import at the top of the module... 🤦 Then I would not use EmailProvider
at all. The whole point of this tutorial is to get rid of nodemailer
, it feels weird to recommend installing it, and it's also quite big.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General feedback:
- Let's use NextAuth.js if we are referencing
next-auth
- Let's use "we" over "I"
- Let's copy the default text style
next-auth/packages/core/src/providers/email.ts
Lines 175 to 177 in 533320e
function text({ url, host }: { url: string; host: string }) { return `Sign in to ${host}\n${url}\n\n` } - Should we add the HTML version of the e-mail too?
function html(params: { url: string; host: string; theme: Theme }) {
Essentially, an HTTP-based E-mail provider should only need a single sendVerificationRequest
method, and no other config. I'll leave it up to you, but we might not even need the EmailProvider
import, just do:
...
{
type: "email",
id: "sendgrid",
async sendVerificationRequest() {
...
}
}
...
Should mention that to sign the user in, you could call signIn("sendgrid", { email: "user@example.com" })
in the client. (Or id is email
if you decide to keep the EmailProvider
wrapper)
Co-authored-by: Balázs Orbán <info@balazsorban.com>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
975d43f
to
30eac91
Compare
Yeah so first of all, good suggestions all the way through, committed almost all of them. Wasn't sure about the NextAuth.js / Auth.js thing since this is giong in the I'll go over it again with the text style updates and add the HTML email as well. I actually implemented this in that briefkasten app of mine while I wrote this yesterday to make sure it worked and since I was still sending emails via my own gmail account SMTP there previously haha. So I used our html wrapper, works just fine. Can copy that over to the guide too 👍 Regarding the |
Changed to we and mentioend our |
|
Okay great, will remove it then and do the custom provider route you mentioned to avoid nodemailer as well 👍 |
@balazsorban44 alright, should be more or less ready to go 👍 |
This was not addressed: #6555 (comment) |
You mean removing the nodemaiker point? That should definitely be gone and I changed it to a custom provider so it doesn't complain anymore |
☕️ Reasoning
/guides/providers/email-http
) for sending Emails (Magic Link verification) via HTTP email APIs, like those from cloud email service providers like SendGrid, Postmark, AWS SES, etc.v4
docs?🧢 Checklist
🎫 Affected issues
Please scout and link issues that might be solved by this PR.
Fixes: INSERT_ISSUE_LINK_HERE
📌 Resources