'Struggling with a backend solution for AWS amplify front end react app contact form

I've researched this topic for over two weeks now, and I need your support/advice.

I have a frontend react app hosted on AWS amplify, connected through GitHub. The app is a portfolio site, that does not need a user authentication or login/signup options.

The only reason I'm struggling with finding a backend solution is that in my contact page, I have a contact form that I want to send a message directly to my email.

Right now I use emailjs in my app to get send the data from the app to my email.

My problem is that I don't want my emailjs user id to be public, so obviously I tried using environment variables but those does not seem to work in a frontend app in amplify.

I need an advice whether I should:

  • Use a different service to send the email
  • Use a backend service of aws (which leads to many other complications)
  • Create a whole backend app from scratch just to receive this request
  • Any other way I did not think about

I know many information about these topics appears online but after a very long research and testing, nothing seems to work.

Thank you for your time



Solution 1:[1]

This question can be answered using many different approches. I will answer it via a decoupled approach.

You can build a backend end solution using an AWS SDK that you are familiar with. For example AWS SDK for Java. This backend solution then would use the AWS SDK for Java to invoke AWS Services that you need. You can use the Java SDK to invoke SES to send email. Likewise, you can return data from a serverless Aurora database using the RDSDataClient.

You can implement you backend as a Rest API that accepts GET/POST requests to perform AWS operations.

Then you can deploy this backend in a container using Amazon ECS. Then your frond end React app would use a LIB like AXIOS or Fetch API to fetch the data.

This is one approach that uses containers, a decoupled React app, etc. That is how I would implement this use case. You can build a lot of functionality into a Rest API that uses the AWS SDKs and then have that run within a container.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1