Send Emails Using React Email, Resend, & Server Actions in NextJs

Поділитися
Вставка
  • Опубліковано 20 сер 2024

КОМЕНТАРІ • 71

  • @iamparmjeetmishra
    @iamparmjeetmishra 7 місяців тому +2

    you are only one person who make this resend email api works for me. I watch so many tutorials and docs but nothing works . But you made it possible. Thanks

    • @hamedbahram
      @hamedbahram  7 місяців тому +1

      You're welcome. Glad I could help!

  • @anversadutt
    @anversadutt 11 місяців тому +1

    as usual gr8 bro, keep rocking, your hard work will keep this channel exploding

  • @John-eq5cd
    @John-eq5cd 8 місяців тому

    Very clear, well done.
    I appreciate the reminder about how/where server components can be used in client components

  • @Nikox102
    @Nikox102 8 місяців тому

    Thank you, I was struggling to make it work on my own, but by looking at your code I managed to get it working.

    • @hamedbahram
      @hamedbahram  8 місяців тому

      You're welcome! Glad to hear that!

  • @samnj4
    @samnj4 5 місяців тому +1

    Your tutorials has saved me a lot, thanks🤟.

  • @sole008
    @sole008 11 місяців тому +7

    Fantastic video, I have a request though : can you cover the topic of websockets in nextjs 13, with a use case like a chat module or a notification module

    • @hamedbahram
      @hamedbahram  11 місяців тому +4

      Absolutely! That's a great suggestion, thanks. I'll definitely cover that in future videos.

  • @devmab
    @devmab 11 місяців тому +1

    ❤ I really like the video, thank you so much. Hope to see more.

  • @AavaniVedanshi
    @AavaniVedanshi 11 місяців тому +1

    It’s a fantastic lesson to learn.

  • @agustinmolina1027
    @agustinmolina1027 11 місяців тому +1

    Like always Top,Top,Top🚀🚀🚀

  • @regrioz
    @regrioz 11 місяців тому +1

    thank you so much ♥ good video

  • @sujjee
    @sujjee 11 місяців тому +2

    Hey man! I really enjoyed your videos. I'm currently looking into implementing multi-tenancy (wildcard subdomains). I've read the Vercel documentation and cloned Steves Tey's platform starter kit, but I'm still having trouble understanding the concepts. Would you be able to create a video on this topic that is more beginner-friendly? I'm particularly interested in learning how to use the new Next.js app route feature.

    • @hamedbahram
      @hamedbahram  11 місяців тому

      Absolutely! I'll cover that in future videos.

  • @saigunavanam5801
    @saigunavanam5801 5 місяців тому +1

    great video sir it was working in test mode after hosting and registered domain with my site domain with resend after that i am getting error like this
    Failed to load resource: the server responded with a status of 500 ()
    Uncaught (in promise) Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.

    • @hamedbahram
      @hamedbahram  5 місяців тому +1

      Run `npm run build` and `npm run start` to serve the production build and see what errors you get locally.

    • @saiguna6676
      @saiguna6676 5 місяців тому

      Yes sir did what you said same errors came ,after hosting my page I am getting the above error sir

    • @saigunavanam5801
      @saigunavanam5801 5 місяців тому

      @@hamedbahram same error sir in that and when i put in hosting i get the above error\

  • @shahryartavakkoli
    @shahryartavakkoli 11 місяців тому +1

    Dear Hamed would you mind explaining about difference of layout and template in NextJS 13 in a video with sample code please?

    • @hamedbahram
      @hamedbahram  11 місяців тому +1

      Absolutely! I'll cover that in future videos.

  • @valenciagapastel
    @valenciagapastel 2 місяці тому +1

    what would cause the email not to send. read through all the docs. console.log says its working just fine, but I'm not receiving an email :/

    • @hamedbahram
      @hamedbahram  2 місяці тому +1

      Clone my code and compare what you're doing differently. If not in the code it may be that you haven't verified the email from which you're sending the email.

    • @valenciagapastel
      @valenciagapastel 2 місяці тому

      @@hamedbahram it was the email. Thanks!

  • @CalvaryBibleFellowship
    @CalvaryBibleFellowship 5 місяців тому +1

    does resend have recaptcha feature? I wanted to prevent too many submits by adding in a recaptcha feature.

    • @hamedbahram
      @hamedbahram  5 місяців тому

      You 'd need to implement that in your client-side forms and alternatively also in your backend APIs before hitting resend to send the emails.

  • @damianalcalaylopez7229
    @damianalcalaylopez7229 10 місяців тому +1

    Hi thanks for the vid!! Appreciate it a lot!
    Also wanted to ask if you know how to add an attachment file like pdf or image to the email.

    • @hamedbahram
      @hamedbahram  10 місяців тому

      My pleasure! you can use the `attachments ` property on the `send` function like ↓
      ```
      await resend.emails.send({
      from: 'Acme ',
      to: ['delivered@resend.dev'],
      subject: 'hello world',
      text: 'it works!',
      attachments: [
      {
      filename: 'invoice.pdf',
      content: invoiceBuffer,
      },
      ],
      });
      ```

  • @criteria6972
    @criteria6972 5 місяців тому +1

    Does it work as intended when you host it on Vercel? Resend works locally in development for me, however when its being hosted on Vercel my emails aren't sent, neither are they being received. Can you do a tutorial for Resend being used in production.

    • @hamedbahram
      @hamedbahram  5 місяців тому

      Are you using the resend provided email, or have you verified you own domain?

    • @criteria6972
      @criteria6972 4 місяці тому +1

      @@hamedbahram I have added a domain and it all works in local development. Just not on vercel. I even tried the example on resend for serverless functions and i am getting the same result.

    • @hamedbahram
      @hamedbahram  4 місяці тому +1

      @@criteria6972 Strange! I tried it on my end and it works fine.

  • @mayorplaystoo
    @mayorplaystoo 11 місяців тому +1

    It’s hard being a new developer and not knowing what to choose Js or Ts?? Pls I need advice ❤❤❤

    • @hamedbahram
      @hamedbahram  11 місяців тому +1

      If you're a new developer, I suggest starting from Js. Once you got comfortable with what you're learning you can sprinkle in Ts.

    • @mayorplaystoo
      @mayorplaystoo 11 місяців тому +1

      @@hamedbahram thank you 🙏…
      I’ve learnt quite a bit of Js and I’m getting comfortable and now I’m creating my portfolio but when I check next auth Tutorials they all mostly use Ts which is making me debate which to use

    • @hamedbahram
      @hamedbahram  11 місяців тому

      @@mayorplaystoo If you're comfortable then use TS. In case of NextAuth, it is not that much difference. I havve a video covering it in JS => ua-cam.com/video/Eh3EpwqT4cM/v-deo.htmlsi=ctwYbul9V3F5XD2d

  • @John-eq5cd
    @John-eq5cd 8 місяців тому +1

    One query, looking at the contact-form.tsx file, a client component, the function sendEmail, which is imported and is a server action, is called when the form is submitted. From what I have understood server actions or server components shouldn’t work when imported into client components.
    Can you clarify?
    Many thanks

    • @hamedbahram
      @hamedbahram  8 місяців тому +1

      Watch this to learn about server actions → ua-cam.com/video/sdKFEo6978U/v-deo.html
      Watch this to learn about server components → ua-cam.com/video/3Dw6D_WuzSE/v-deo.html

    • @John-eq5cd
      @John-eq5cd 8 місяців тому

      Thank you. I have watched both of these now and feel I understand better.
      For those who are interested, here are some of the key points I picked up:
      Server Actions
      We cannot define a server action inside a client component (I have found I can define a server action in the same client component file with 'use server', but it cannot be put into the client functional component)
      Server actions can be imported into a client component
      Server Components
      All components inside '/app' are server components by default
      Server components are only rendered on the server
      Client components are pre-rendered on the server; the html is generated on the server and then hydrated on the client side
      We cannot import server components into a client component as they would become client components
      Server components can only be passed into a client component as a prop or as children.
      We can import client components into server components, for example importing a navbar search field, which requires user input, in a client component into the main navbar server component

  • @akinfetemitope8495
    @akinfetemitope8495 5 місяців тому +1

    how do you build the project with "use server"

    • @hamedbahram
      @hamedbahram  5 місяців тому

      Can you expand on your question?

    • @akinfetemitope8495
      @akinfetemitope8495 5 місяців тому +1

      @@hamedbahram okay thank you
      I have a project that requires me to use “use server” in one of the files but when I try building to be able to deploy to cpanel it gives me server actions are not supported with static export. So my question is what is the workaround because I need that file
      Thanks

    • @hamedbahram
      @hamedbahram  5 місяців тому

      @@akinfetemitope8495 Got it. Well server actions are functions that run on the server, so you'd need a server, which means it won't work with static export! you need to deploy to a platform that supports serverless or edge functions.

    • @akinfetemitope8495
      @akinfetemitope8495 5 місяців тому

      @@hamedbahram okay thanks

  • @devbenshort
    @devbenshort 5 місяців тому +1

    The resend url is not working

    • @hamedbahram
      @hamedbahram  5 місяців тому

      Which url do you mean? This one 👉🏼 resend.com ?

    • @olaniranemmanuel2549
      @olaniranemmanuel2549 5 місяців тому

      @@hamedbahram Its not still working, facing same issue even tho I used it 2 month ago

  • @ButchicHernandez-cv5rm
    @ButchicHernandez-cv5rm 11 місяців тому

    Another great video Sir ! I have a question, what will be your approach for silencing spam email? As well how do you create an auto response email from the developer side. Thanks and more success.

    • @hamedbahram
      @hamedbahram  11 місяців тому

      Thank you. There are different ways to prevent spam, from managed services to bot detection, captcha, etc. As for the auto-response, you can set it up in the server action, like in the video.

  • @digemberdangwal295
    @digemberdangwal295 7 місяців тому

    Can this be implemented in a React project? Not asking for Next.js

  • @rosmildolopes3985
    @rosmildolopes3985 Місяць тому

    isn't it necesary a POST

    • @hamedbahram
      @hamedbahram  28 днів тому

      A server action makes a post request under the hood.

  • @user-ny9em7sy7f
    @user-ny9em7sy7f 8 місяців тому

    How to set some domain to use, i wanna just deploy site on vercel for portfolio. Can i then use this email from documentation or still need to add my domain?

    • @hamedbahram
      @hamedbahram  8 місяців тому

      You need to add your own domain.

    • @user-ny9em7sy7f
      @user-ny9em7sy7f 8 місяців тому +1

      @@hamedbahram can i make it for free or need to pay to get domain?

    • @hamedbahram
      @hamedbahram  8 місяців тому

      @@user-ny9em7sy7f If you want your own domain you have to buy it.

    • @user-ny9em7sy7f
      @user-ny9em7sy7f 8 місяців тому

      @@hamedbahram Is forbidden to use this default (for test) address domain? Just wanna deploy it on vercel for portfolio website...

  • @durgashreenv8426
    @durgashreenv8426 6 місяців тому +1

    When I run my project locally, I am able to see it work perfectly, but when I try to deploy it on vercel, I get this error "./app/api/send/route.js
    Module not found: Can't resolve 'resend' " I even tried running the command: git config core.ignorecase false But I still see the same issue

    • @hamedbahram
      @hamedbahram  6 місяців тому +1

      That's weird 🤔 Can you double check if you have `resend` as a dependency in your `package.json` file?

    • @durgashreenv8426
      @durgashreenv8426 6 місяців тому +1

      @@hamedbahram Resolved thank you 😊 Your teachings are amazing and very clear, thank you for that as well!

    • @hamedbahram
      @hamedbahram  6 місяців тому +1

      @@durgashreenv8426 My pleasure!