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

Поделиться
HTML-код
  • Опубликовано: 14 дек 2024

Комментарии • 74

  • @iamparmjeetmishra
    @iamparmjeetmishra 11 месяцев назад +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  11 месяцев назад +1

      You're welcome. Glad I could help!

  • @sole008
    @sole008 Год назад +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  Год назад +4

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

  • @criteria6972
    @criteria6972 8 месяцев назад +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  8 месяцев назад

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

    • @criteria6972
      @criteria6972 8 месяцев назад +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  8 месяцев назад +1

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

  • @anversadutt
    @anversadutt Год назад +1

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

  • @akinfetemitope8495
    @akinfetemitope8495 9 месяцев назад +1

    how do you build the project with "use server"

    • @hamedbahram
      @hamedbahram  9 месяцев назад

      Can you expand on your question?

    • @akinfetemitope8495
      @akinfetemitope8495 9 месяцев назад +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  9 месяцев назад

      @@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 9 месяцев назад

      @@hamedbahram okay thanks

  • @durgashreenv8426
    @durgashreenv8426 10 месяцев назад +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  10 месяцев назад +1

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

    • @durgashreenv8426
      @durgashreenv8426 10 месяцев назад +1

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

    • @hamedbahram
      @hamedbahram  10 месяцев назад +1

      @@durgashreenv8426 My pleasure!

  • @saigunavanam5801
    @saigunavanam5801 9 месяцев назад +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  9 месяцев назад +1

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

    • @saiguna6676
      @saiguna6676 9 месяцев назад

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

    • @saigunavanam5801
      @saigunavanam5801 8 месяцев назад

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

  • @samnj4
    @samnj4 9 месяцев назад +1

    Your tutorials has saved me a lot, thanks🤟.

  • @John-eq5cd
    @John-eq5cd Год назад

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

  • @shahryartavakkoli
    @shahryartavakkoli Год назад +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  Год назад +1

      Absolutely! I'll cover that in future videos.

  • @sujjee
    @sujjee Год назад +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  Год назад

      Absolutely! I'll cover that in future videos.

  • @CalvaryBibleFellowship
    @CalvaryBibleFellowship 9 месяцев назад +1

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

    • @hamedbahram
      @hamedbahram  9 месяцев назад

      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.

  • @Nikox102
    @Nikox102 Год назад

    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  Год назад

      You're welcome! Glad to hear that!

  • @devbenshort
    @devbenshort 9 месяцев назад +1

    The resend url is not working

    • @hamedbahram
      @hamedbahram  9 месяцев назад

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

    • @olaniranemmanuel2549
      @olaniranemmanuel2549 9 месяцев назад

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

  • @John-eq5cd
    @John-eq5cd Год назад +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  Год назад +1

      Watch this to learn about server actions → ruclips.net/video/sdKFEo6978U/видео.html
      Watch this to learn about server components → ruclips.net/video/3Dw6D_WuzSE/видео.html

    • @John-eq5cd
      @John-eq5cd Год назад

      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

  • @valenciagapastel
    @valenciagapastel 6 месяцев назад +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  6 месяцев назад +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 6 месяцев назад

      @@hamedbahram it was the email. Thanks!

  • @AavaniVedanshi
    @AavaniVedanshi Год назад +1

    It’s a fantastic lesson to learn.

  • @damianalcalaylopez7229
    @damianalcalaylopez7229 Год назад +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  Год назад

      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,
      },
      ],
      });
      ```

  • @devmab
    @devmab Год назад +1

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

  • @mayorplaystoo
    @mayorplaystoo Год назад +1

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

    • @hamedbahram
      @hamedbahram  Год назад +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 Год назад +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  Год назад

      @@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 => ruclips.net/video/Eh3EpwqT4cM/видео.htmlsi=ctwYbul9V3F5XD2d

  • @agustinmolina1027
    @agustinmolina1027 Год назад +1

    Like always Top,Top,Top🚀🚀🚀

  • @Toulkun
    @Toulkun Месяц назад +1

    is it possible to receive email from any valid one?

    • @hamedbahram
      @hamedbahram  Месяц назад

      What do you mean by that?

    • @Toulkun
      @Toulkun Месяц назад

      I want to receive emails by visitors of my website.

  • @ButchicHernandez-cv5rm
    @ButchicHernandez-cv5rm Год назад

    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  Год назад

      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 11 месяцев назад

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

  • @regrioz
    @regrioz Год назад +1

    thank you so much ♥ good video

  • @quizproject-n1k
    @quizproject-n1k Год назад

    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  Год назад

      You need to add your own domain.

    • @quizproject-n1k
      @quizproject-n1k Год назад +1

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

    • @hamedbahram
      @hamedbahram  Год назад

      @@quizproject-n1k If you want your own domain you have to buy it.

    • @quizproject-n1k
      @quizproject-n1k Год назад

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

  • @rosmildolopes3985
    @rosmildolopes3985 4 месяца назад

    isn't it necesary a POST

    • @hamedbahram
      @hamedbahram  4 месяца назад

      A server action makes a post request under the hood.