<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Elena Diaz</title>
    <description>The latest articles on DEV Community by Elena Diaz (@elenadiaz32505).</description>
    <link>https://dev.to/elenadiaz32505</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1136250%2F3081dfc0-ca0e-4a65-ae44-1ac54a13e6d2.jpg</url>
      <title>DEV Community: Elena Diaz</title>
      <link>https://dev.to/elenadiaz32505</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/elenadiaz32505"/>
    <language>en</language>
    <item>
      <title>My First Hackathon: A Journey of Collaboration and Learning</title>
      <dc:creator>Elena Diaz</dc:creator>
      <pubDate>Tue, 07 Nov 2023 00:34:51 +0000</pubDate>
      <link>https://dev.to/elenadiaz32505/my-first-hackathon-a-journey-of-collaboration-and-learning-omc</link>
      <guid>https://dev.to/elenadiaz32505/my-first-hackathon-a-journey-of-collaboration-and-learning-omc</guid>
      <description>&lt;p&gt;Have you ever wondered what it’s like to participate in a hackathon? Well, let me share my experience from the &lt;a href="https://www.womenwhocode.com/"&gt;Women Who Code&lt;/a&gt; Hackathon for Social Good 2023. Lasting 9 days, this exhilarating event brought together women from different corners of the globe, creating a supportive and inspiring environment for beginners and experts alike.&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction: Overcoming Initial Hesitations and Regrets
&lt;/h3&gt;

&lt;p&gt;Joining the hackathon was an exciting adventure, filled with new experiences and collaborative learning. For someone new to the world of hackathons, the initial steps might seem daunting, but with the right support and enthusiasm, it can turn into a rewarding learning experience.&lt;/p&gt;

&lt;p&gt;As someone who has been working as a frontend developer for over five years, I recently embarked on my first hackathon experience at the Women Who Code Hackathon for Social Good 2023. I'll be honest – during my college years, the idea of participating in a hackathon terrified me. I often second-guessed my abilities and were super competitive. Looking back, I regret not taking the leap sooner. I realize now that the learning and growth that come from such experiences are invaluable. This experience taught me that stepping out of your comfort zone brings incredible growth and learning. So, if you are feeling hesitant like I was, trust me, it's never too late to embrace new challenges and opportunities for personal and professional development.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting Started: The Joy of Teaming Up
&lt;/h3&gt;

&lt;p&gt;Discovering the hackathon through Women Who Code social groups, I initially planned to go solo. However, a friend from another group reached out, and we decided to team up. We pitched our ideas to the Women Who Code community, and before we knew it, we had an enthusiastic squad of members on board, each contributing their distinct skills and perspectives to the table. With specialists focusing on backend development, UI/UX design, and project research, our team was a powerhouse of diverse skills and perspectives.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Hackathon Experience
&lt;/h3&gt;

&lt;p&gt;The nine-day hackathon commenced with an energized meet-up, allowing us to strategize and outline our project's key milestones. With our team spread across different time zones, from New York, Italy, London, and Texas, we leveraged digital tools such as &lt;a href="https://meet.google.com/"&gt;Google Meet&lt;/a&gt;, &lt;a href="https://slack.com/"&gt;Slack&lt;/a&gt; to ensure seamless communication and coordinated efforts. Additionally, we used &lt;a href="//www.figma.com"&gt;Figma&lt;/a&gt; for prototyping designs and &lt;a href="//trello.com"&gt;Trello&lt;/a&gt; helped us stay organized with tasks.&lt;/p&gt;

&lt;p&gt;Balancing the intensity of the hackathon, we put in some serious hours while making sure no one burned out. Whenever roadblocks arose, we fostered open communication through Slack, readily sharing resources and helping overcome any challenges hindering our progress.&lt;/p&gt;

&lt;p&gt;Despite the short deadline and logistical complexities, the collaborative spirit among like-minded women in the field fostered an enriching environment, creating a supportive space where we could learn and thrive together. This positive vibe and teamwork truly powered our journey, bringing us closer to project completion.&lt;/p&gt;

&lt;h3&gt;
  
  
  Embracing New Technologies and User-Centric Designs
&lt;/h3&gt;

&lt;p&gt;During the hackathon, my teammate and I focused on frontend development using &lt;a href="https://necolas.github.io/react-native-web/"&gt;React Native for Web&lt;/a&gt;, uncovering its immense potential for our project. While we were well-versed in React, our knowledge of React Native for Web was initially limited. Nevertheless, with the unwavering support of our team, we eagerly immersed ourselves in the world of frontend development, leading to a series of challenges and victories. I explored the integration of a barcode scanner using JavaScript libraries, adding depth to our project and enhancing its user appeal. Alongside managing authentication and secure routes, my focus extended to refining responsive design, incorporating user interfaces via Material UI, and seamlessly implementing API calls for efficient database access. Each step bolstered my understanding of the dynamic web development landscape.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reflecting on the Journey
&lt;/h3&gt;

&lt;p&gt;Despite our team not securing the top position and not being able to build all the functionality we had initially planned, the wealth of knowledge and skills gained in such a short span was truly remarkable. The hackathon not only highlighted the potential of rapid application development but also underscored the vital role of teamwork, communication, and adaptability in achieving collective success. Navigating new technologies, troubleshooting in real-time, and collaborating with a diverse group of like-minded individuals provided a profound perspective on the world of coding and development. Overall, this experience has undeniably sparked a newfound enthusiasm for future hackathons and collaborative endeavors.&lt;/p&gt;

&lt;p&gt;If you are considering joining a hackathon, my advice is simple: dive in with an open mind, embrace the challenges, and relish every moment of the learning journey. You will be amazed at what you can accomplish when surrounded by a supportive and empowering community of fellow coders and innovators.&lt;/p&gt;

&lt;p&gt;Happy coding! 👩🏻‍💻💖&lt;/p&gt;




&lt;p&gt;If you found this helpful, support my work by sharing this article, referring me for frontend jobs, or if inclined &lt;a href="https://www.buymeacoffee.com/elenadiaz32505"&gt;Buy Me A Coffee&lt;/a&gt;, &lt;a href="https://ko-fi.com/elenadiaz"&gt;Ko-fi&lt;/a&gt;, or &lt;a href="https://paypal.me/elenadiaz32505"&gt;Paypal&lt;/a&gt;. Your support keeps me going – thank you!&lt;/p&gt;

</description>
      <category>hackathon</category>
      <category>frontend</category>
      <category>webdev</category>
      <category>learning</category>
    </item>
    <item>
      <title>Part 3 - Building a Full Stack Contact Form: Deployment 2023</title>
      <dc:creator>Elena Diaz</dc:creator>
      <pubDate>Sun, 20 Aug 2023 01:29:59 +0000</pubDate>
      <link>https://dev.to/elenadiaz32505/part-3-building-a-full-stack-contact-form-deployment-2023-2dj6</link>
      <guid>https://dev.to/elenadiaz32505/part-3-building-a-full-stack-contact-form-deployment-2023-2dj6</guid>
      <description>&lt;p&gt;Welcome to Part 3 of our comprehensive full-stack contact form series! In this installment, your final dive will go into the deployment, taking the impressive groundwork you've laid so far and transforming it into a fully functional and hosted communication tool online.&lt;/p&gt;

&lt;h3&gt;
  
  
  Contents
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
Preparing for Deployment

&lt;ul&gt;
&lt;li&gt;Backend Enhancement: Transitioning to HTTPS&lt;/li&gt;
&lt;li&gt;Frontend Refinement: Transitioning to HTTPS and Production Build&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Deployment: GitHub and CyberPanel

&lt;ul&gt;
&lt;li&gt;Backend Deployment&lt;/li&gt;
&lt;li&gt;Keeping the Backend Server Running: PM2&lt;/li&gt;
&lt;li&gt;Frontend Deployment&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Troubleshooting&lt;/li&gt;

&lt;li&gt;Conclusion&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a id="Part-3:-Preparing-for-Deployment"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Preparing for Deployment
&lt;/h2&gt;

&lt;p&gt;In this phase, we'll be focusing on the crucial steps to get your contact form ready for deployment. This will involve making the necessary adjustments, including the conversion of your backend from HTTP to HTTPS to ensure seamless POST requests.&lt;/p&gt;

&lt;p&gt;&lt;a id="Backend-Enhancement:-Transitioning-to-HTTPS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Backend Enhancement: Transitioning to HTTPS
&lt;/h3&gt;

&lt;p&gt;In order to ensure secure communication between your frontend and backend, it's important to convert your backend from using HTTP to HTTPS. This transition guarantees the secure transfer of data through your full-stack contact form. SSL certificates will be needed to complete this part.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resource and Reference:&lt;/strong&gt; A valuable resource that provides detailed insights into configuring SSL certificates for Node.js HTTPS can be found at &lt;a href="https://adamtheautomator.com/https-nodejs/" rel="noopener noreferrer"&gt;https://adamtheautomator.com/https-nodejs/&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Install HTTPS Package:&lt;/strong&gt; Start by installing the https package using the following command in your terminal:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i https
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Import HTTPS Module:&lt;/strong&gt; At the top of your server.js file, import the https module as follows:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const https = require('https');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Update Server Creation:&lt;/strong&gt; Modify the server creation process. You'll now create an HTTPS server instance using the &lt;strong&gt;https.createServer&lt;/strong&gt; method which will replace the &lt;strong&gt;app.listen&lt;/strong&gt; method going forward. This involves specifying the paths to your SSL certificate and private key files.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const httpsServer = https.createServer(
    {
        key: fs.readFileSync(
            'path-to-privkey.pem'
        ),
        cert: fs.readFileSync(
            'path-to-cert.pem'
        ),
    },
    app
);

httpsServer.listen(serverPort, () =&amp;gt;
    console.log(`backend is running on port ${serverPort}`)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't forget to comment out or remove the &lt;strong&gt;app.listen&lt;/strong&gt; line.&lt;/p&gt;

&lt;p&gt;With these updates, your backend is now transitioned to use HTTPS. In the next step, we'll make a small change in the frontend to ensure that the fetch URL points to the HTTPS backend, completing the circle of secure communication between your frontend and backend.&lt;/p&gt;

&lt;p&gt;&lt;a id="Frontend-Refinement:-Transitioning-to-HTTPS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Frontend Refinement: Transitioning to HTTPS and Production Build
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;HTTPS&lt;/strong&gt;: The HyperText Transfer Protocol Secure (HTTPS) guarantees secure data exchange over the internet by encrypting information exchanged between the server and the client. ==HTTPS will be used and discussed in part 3 of the series before deployment.==&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With the backend now utilizing HTTPS for secure communication, it's essential to ensure that the frontend also points to the updated secure API endpoint. Let's make this crucial update:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Update API Endpoint URLs:&lt;/strong&gt; Open your frontend codebase and find the sections where you make API calls to the backend. If you've transitioned your backend to use HTTPS, simply add the letter "s" to the URL to switch from HTTP to HTTPS.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let response = await fetch('https://localhost:5000/send', {
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Build the React application for production. I made a production specific folder outside from the dev folder. On package.json, add the build script. This script builds the react application, saves the build to the prod folder and removes it from the dev folder.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Build for Production:&lt;/strong&gt; To get your React application ready to be deployed, it needs to undergo a special process called "building for production." This process is like packaging your app in a way that makes it suitable for sharing over the internet. To make things organized, I've created a separate folder specifically for the production version of your app. This makes it super easy when it comes to uploading the production version to GitHub.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here's how to do it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Creating a Production Folder:&lt;/strong&gt; I've set up a special folder outside of your development workspace. This is where the final version of your app that's ready for deployment will be placed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Build Script in package.json:&lt;/strong&gt; I've added a special script to the &lt;strong&gt;package.json&lt;/strong&gt; file. This script automates the process. First, it builds the React app in the development folder. Then, it copies the built files to the production folder. Finally, it tidies up the development folder by removing the unnecessary build files.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're using &lt;strong&gt;create-react-app&lt;/strong&gt;, the build script will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"build": "react-scripts build &amp;amp;&amp;amp; XCOPY C:\\Dev\\contactform\\build\\\* C:\\Prod\\contactform_prod /s /y &amp;amp;&amp;amp; RMDIR /s /q C:\\Dev\\contactform\\build",
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you're using &lt;strong&gt;nano-react-app&lt;/strong&gt;, the build script will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"build": "vite build &amp;amp;&amp;amp; XCOPY C:\\Dev\\contactform\\build\\\* C:\\Prod\\contactform_prod /s /y &amp;amp;&amp;amp; RMDIR /s /q C:\\Dev\\contactform\\build",
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Run the Build Script:&lt;/strong&gt; Save the changes in your package.json file then run the following command to initiate the production build in your terminal:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Publish to GitHub:&lt;/strong&gt; Open the production build folder using VSCode. Go to the source control section and select publish to github as a private repo.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fdiazelena325%2Fcontactform%2Fmain%2Ftutorial_images%2Fgithubpublish.png" alt="github publish"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This will make your production-ready frontend code ready for Cyberpanel.&lt;/p&gt;

&lt;p&gt;&lt;a id="Deployment:-GitHub-and-CyberPanel"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Deployment: GitHub and CyberPanel
&lt;/h2&gt;

&lt;p&gt;&lt;a id="Backend-Deployment"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Backend Deployment
&lt;/h3&gt;

&lt;p&gt;When it comes to deploying your backend to the server, the process is smooth and straightforward. Here's how you do it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Remote Connection:&lt;/strong&gt; Connect remotely to your CyberPanel server, where your portfolio website is stored. Go to the directory location where your websites public_html is located. Just outside the &lt;strong&gt;public_html&lt;/strong&gt; folder, create a folder named &lt;strong&gt;emailsvc&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The necessary backend files will go inside this folder, which are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;config.js&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;package.json&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;server.js&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Remember, there's no need to import the &lt;strong&gt;node_modules&lt;/strong&gt; folder; it's already in your &lt;strong&gt;package.json&lt;/strong&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Install Packages:&lt;/strong&gt; In the terminal, navigate to the location of your backend files on the server. Install the required packages. You can do this by running either of the following commands:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install express nodemailer cors https --save
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This step ensures that your backend has all the necessary dependencies to run smoothly.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Test Backend:&lt;/strong&gt; To ensure that your backend is working correctly on the server, log in to your host service through a terminal, and run the command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run mailstart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This test run is crucial to confirm that everything is set up and ready for action.&lt;/p&gt;

&lt;p&gt;With your backend deployed and successfully tested, you've achieved a significant milestone in bringing your full-stack contact form to life in a live environment.&lt;/p&gt;

&lt;p&gt;It's important to note that if you close your terminal that is logged into your host service, the backend could stop running. To ensure continuous operation, follow the upcoming steps that will help you keep your backend running reliably.&lt;/p&gt;

&lt;p&gt;&lt;a id="Keeping-the-Backend-Server-Running"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Keeping the Backend Server Running: PM2
&lt;/h4&gt;

&lt;p&gt;To ensure the continuous operation of your backend, we'll use a tool called PM2. PM2 allows you to manage various backend services and keep them running efficiently. To get more information about PM2 go to: &lt;a href="https://pm2.keymetrics.io/docs/usage/process-management/" rel="noopener noreferrer"&gt;https://pm2.keymetrics.io/docs/usage/process-management/&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Install PM2:&lt;/strong&gt; In your terminal, run the following command to install PM2 globally:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install pm2 -g
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will make PM2 available for managing your backend services.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Unique Start Scripts:&lt;/strong&gt; Ensure that each of your backend services has a distinct start script name. For example, in our case, we named our script &lt;strong&gt;mailstart&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Start the Service:&lt;/strong&gt; To initiate a backend service using PM2, execute the following command:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pm2 start "npm run mailstart"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command tells PM2 to manage the execution of your backend service.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Stop the Service:&lt;/strong&gt; If you need to halt the service, you have two options:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;To stop all backend services simultaneously, run:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pm2 stop all
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To stop a specific service, provide its unique identifier (ID):
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pm2 stop &amp;lt;id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By using PM2, you can ensure that your backend services stay active. This is a crucial step in making sure your full-stack contact form remains operational and accessible at all times.&lt;/p&gt;

&lt;p&gt;&lt;a id="Frontend-Deployment"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Frontend Deployment
&lt;/h3&gt;

&lt;p&gt;Deploying the frontend of your application using CyberPanel's Git management feature is the final step towards making your full-stack contact form accessible to users.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Log in to your CyberPanel dashboard and navigate to the "Websites" section, then "List Websites" sub-section.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go to the "Manage" section of your website in this list, then look for the "Manage Git" button and click on it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose the folder where your portfolio website is deployed in the drop-down list.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Look for the "Pull" button and click on it. This action will retrieve the latest changes from your GitHub repository and deploy them to the selected folder.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;🥳&lt;strong&gt;Congratulations, your contact form is deployed!&lt;/strong&gt; 🏆🎉&lt;/p&gt;

&lt;p&gt;&lt;a id="Troubleshooting"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;p&gt;During the process of creating and deploying your full-stack contact form, you might encounter a few issues. Here are a couple of common challenges and their solutions that I came across:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Permission Denied Error with SSL Certificate:&lt;/strong&gt; If you encounter an EACCES (permission denied) error while using the SSL certificate, it's likely a file permission issue. To resolve this, navigate to the location of the key file (privkey.pem), and change its permissions using the following command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CHMOD 744 privkey.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Auto-Reply Emails Going to Spam:&lt;/strong&gt; Sometimes, auto-reply messages can end up in recipients' spam folders. I resolved this by including an HTML version of the message (converted from the text version).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These resources really helped figure it out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.textfixer.com/html/convert-text-html.php" rel="noopener noreferrer"&gt;Text to HMTL converter&lt;/a&gt;&lt;/strong&gt; helped with emails ending up in spam folder&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://stackoverflow.com/questions/40608635/email-send-through-nodemailer-goes-into-spam-for-gmail" rel="noopener noreferrer"&gt;This stack overflow&lt;/a&gt;&lt;/strong&gt; really helped with a nodemailer issue&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.mail-tester.com/" rel="noopener noreferrer"&gt;Test-mailer&lt;/a&gt;&lt;/strong&gt; to see what security issues could appear&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="Conclusion"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;🌟You've now gone through the entire process of creating, deploying, and troubleshooting your full-stack contact form!🌟&lt;/p&gt;

&lt;p&gt;Let's recap:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tutorial Recap:&lt;/strong&gt; You started by creating a sleek and functional frontend contact form using React and then moved on to setting up the backend using Node.js. The form's data is sent via a secure POST request to your backend, and finally an auto-reply message is sent to the user.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Error Handling and Security:&lt;/strong&gt; Throughout this journey, we've emphasized the importance of handling errors gracefully and prioritizing security. Properly handling errors and ensuring the secure transmission of data are critical aspects of any web application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Experiment and Customize:&lt;/strong&gt; While this tutorial provides a solid foundation, don't hesitate to experiment and customize the code to match your specific needs. Every project is unique, and exploring different functionalities can be a great learning experience.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With your full-stack contact form up and running, you're now better equipped to handle communication with visitors to your website or portfolio. As you continue to develop your skills, you'll find even more ways to leverage the power of full-stack development for creating engaging and dynamic web applications.&lt;/p&gt;

&lt;p&gt;If you have any questions or if there are additional steps you'd like me to cover, please feel free to let me know.&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀🌌🌝&lt;/p&gt;




&lt;p&gt;If you found this helpful, support my work by sharing this article, referring me for frontend jobs, or if inclined &lt;a href="https://www.buymeacoffee.com/elenadiaz32505" rel="noopener noreferrer"&gt;Buy Me A Coffee&lt;/a&gt;, &lt;a href="https://ko-fi.com/elenadiaz" rel="noopener noreferrer"&gt;Ko-fi&lt;/a&gt;, or &lt;a href="https://paypal.me/elenadiaz32505" rel="noopener noreferrer"&gt;Paypal&lt;/a&gt;. Your support keeps me going – thank you!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>tutorial</category>
      <category>deployment</category>
      <category>fullstack</category>
    </item>
    <item>
      <title>Part 2 - Building a Full Stack Contact Form: Node.js Backend 2023</title>
      <dc:creator>Elena Diaz</dc:creator>
      <pubDate>Sun, 20 Aug 2023 01:29:16 +0000</pubDate>
      <link>https://dev.to/elenadiaz32505/part-2-building-a-full-stack-contact-form-nodejs-backend-2023-jdp</link>
      <guid>https://dev.to/elenadiaz32505/part-2-building-a-full-stack-contact-form-nodejs-backend-2023-jdp</guid>
      <description>&lt;p&gt;Welcome to Part 2 of our Full Stack Contact Form Series! We're about to unlock the world of backend development to enable the actual sending of emails. Get ready to harness the power of Node.js, Express, Nodemailer, CORS, and HTTPS to create a seamless communication experience. By the end of this guide, you'll have hands-on experience on how these technologies work together to bring your contact form to life.&lt;/p&gt;

&lt;h3&gt;
  
  
  Contents
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
Backend Development

&lt;ul&gt;
&lt;li&gt;Creating Your Node.js Project with npm&lt;/li&gt;
&lt;li&gt;Installing Essential Dependencies (Express, Nodemailer)&lt;/li&gt;
&lt;li&gt;Storing Data Constants in config.js&lt;/li&gt;
&lt;li&gt;Setting Up Your server.js Backend File&lt;/li&gt;
&lt;li&gt;Creating Nodemailer Functions for Email Sending&lt;/li&gt;
&lt;li&gt;Crafting API Routes for Email Handling&lt;/li&gt;
&lt;li&gt;Testing Your Full-Stack Contact Form Locally&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;GitHub Repository for Backend Code&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a id="Backend-Development"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Backend Development
&lt;/h2&gt;

&lt;p&gt;Our journey into the backend realm begins with Node.js (I'm using version 18.13.0) and the npm package manager. These tools will be your trusty companions as we embark on building the backbone of our email-sending mechanism. So, let's roll up our sleeves and get started on creating a backend that ensures your contact form is not just eye-catching, but fully functional too.&lt;/p&gt;

&lt;p&gt;&lt;a id="Creating-Your-Nodejs-Project-with-npm"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating Your Node.js Project with npm
&lt;/h3&gt;

&lt;p&gt;Let's kick off our backend development by setting up a Node.js project using npm. This will provide the foundation for building the functionalities that power your email-sending mechanism.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Create a Dedicated Backend Folder:&lt;/strong&gt; Begin by creating a folder specifically for your backend code. Open this folder in your preferred code editor, like VSCode.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Initialize the Project:&lt;/strong&gt; In the terminal within your backend folder, enter the following command to generate a basic package.json template file:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm create -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will initialize your Node.js project and set up the essential package.json file.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Structure Your Files:&lt;/strong&gt;
Create two important files within your backend folder:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;server.js:&lt;/strong&gt; This is where you'll write the core functionality code for your backend.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;config.js:&lt;/strong&gt; Utilize this file to store email configuration details.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's how your project folder might be structured:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/contactform_backend
    ├── package.json
    ├── server.js
    ├── config.js

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With these foundational steps complete, you've set the stage for your backend development journey. The &lt;strong&gt;package.json&lt;/strong&gt; file will hold key information about your project, and the &lt;strong&gt;server.js&lt;/strong&gt; file will become the heart of your email-sending mechanism. The &lt;strong&gt;config.js&lt;/strong&gt; file will be where we store our constant variables. In the next section, we'll dive into creating the server and setting up the functionalities that bring your contact form to life.&lt;/p&gt;

&lt;p&gt;&lt;a id="Installing-Essential-Dependencies"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Essential Dependencies (Express, Nodemailer)
&lt;/h3&gt;

&lt;p&gt;Now, let's equip your backend with the necessary tools to bring your email-sending mechanism to life.&lt;/p&gt;

&lt;p&gt;Technologies utilized in this project are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Node.js&lt;/strong&gt;: A runtime environment enabling the execution of JavaScript code on the server-side.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Express&lt;/strong&gt;: A streamlined and versatile web application framework built for Node.js, optimized for routing and middleware management.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nodemailer&lt;/strong&gt;: A specialized Node.js module designed to simplify the process of sending emails within applications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CORS&lt;/strong&gt;: An Express middleware that facilitates Cross-Origin Resource Sharing, allowing seamless handling of HTTP requests across varying origins.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's install the required dependencies that make the magic happen.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Installing Dependencies:&lt;/strong&gt; In your terminal, navigate to your backend folder and install the required dependencies using the following commands:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   npm install express nodemailer cors --save
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will add &lt;strong&gt;express&lt;/strong&gt;, &lt;strong&gt;nodemailer&lt;/strong&gt;, and &lt;strong&gt;cors&lt;/strong&gt; to your project, enabling you to create a functional server and send emails.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Updating Your package.json:&lt;/strong&gt; Open your &lt;strong&gt;package.json&lt;/strong&gt; file and add the following &lt;strong&gt;mailstart&lt;/strong&gt; entry to your scripts section:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
            "test": "echo \"Error: no test specified\" &amp;amp;&amp;amp; exit 1",
            "mailstart": "node server.js"
        },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and change the &lt;strong&gt;main&lt;/strong&gt; field from &lt;strong&gt;config.js&lt;/strong&gt; to &lt;strong&gt;server.js&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"main": "server.js",
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The full &lt;strong&gt;package.json&lt;/strong&gt; should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    {
        "name": "contactform_backend",
        "version": "1.0.0",
        "description": "",
        "main": "server.js",
        "scripts": {
            "test": "echo \"Error: no test specified\" &amp;amp;&amp;amp; exit 1",
            "mailstart": "node server.js"
        },
        "keywords": [],
        "author": "",
        "license": "ISC",
        "dependencies": {
            "cors": "^2.8.5",
            "express": "^4.18.2",
            "nodemailer": "^6.9.4"
        }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This updated package.json includes scripts to start your server and lists the dependencies your backend relies on. With these dependencies installed and your package.json updated, your backend is armed with the tools it needs to function effectively.&lt;/p&gt;

&lt;p&gt;&lt;a id="Storing-Data-Constants-in-config"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Storing Data Constants in config.js
&lt;/h3&gt;

&lt;p&gt;The config.js file is where you'll store the email configuration details, such as credentials for sending emails and predefined messages.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Populate with Credentials:&lt;/strong&gt; In config.js, insert the following code:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// change the following details with your information
    module.exports = {
        USER: 'NewEmail@domain.com',
        PASS: 'password',
        EMAIL: 'NewEmail@domain.com',
        HOST: 'smtp.mailhost.com',
        MAILPORT: 555,
        YOURNAME: 'Your Name',
        YOURSITE: 'www.yoursite.com',
    };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace the placeholders with the actual credentials and information that correspond to the domain email account created on Whois.com (see part 1). These details are essential for successfully sending emails using Nodemailer.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;USER:&lt;/strong&gt; Username of email account (domain email address set up in part 1)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PASS:&lt;/strong&gt; Password of email account&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;EMAIL:&lt;/strong&gt; Email address&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HOST:&lt;/strong&gt; SMTP host&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MAILPORT:&lt;/strong&gt; STMP port, usually 587&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;YOURNAME:&lt;/strong&gt; Your full name for the sender and auto reply message&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;YOURSITE:&lt;/strong&gt; Your portfolio website&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example of domain email credentials:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgebqcahruhs68pue9hv3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgebqcahruhs68pue9hv3.png" alt="whois email information" width="544" height="881"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a id="Setting-Up-Your-serverjs-Backend-File"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting Up Your server.js Backend File
&lt;/h3&gt;

&lt;p&gt;Your server.js file is the heart of your backend. Here you'll configure routes, send emails, and make sure everything runs smoothly. Let's dive in and set up the initial structure.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Importing Required Packages and Initial Setup:&lt;/strong&gt;
Start by importing the necessary packages and setting up the initial configuration:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var express = require('express');
var router = express.Router();
var nodemailer = require('nodemailer');
var cors = require('cors');
const fs = require('fs');
const creds = require('./config');

const app = express();
app.use(cors());
app.use(express.json());
app.use('/', router);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Creating a Test Route:&lt;/strong&gt;
Let's create a basic test route to ensure your backend is up and running:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.get('/', (req, res) =&amp;gt; {
    res.json('hi');
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Listening to the Port:&lt;/strong&gt;
Finally, set your backend to listen on a specific port (in this case, port 5000):
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.listen(serverPort, () =&amp;gt; console.log(`backend is running on port ${serverPort}`));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Testing the Backend:&lt;/strong&gt;
To test your backend, run the following command in your terminal:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run mailstart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A successful start of your backend will be indicated in the terminal. You can also open your browser and navigate to &lt;a href="http://localhost:5000" rel="noopener noreferrer"&gt;http://localhost:5000&lt;/a&gt; to see the "hi" message.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiyf28amfs59tkf6mmfp6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiyf28amfs59tkf6mmfp6.png" alt="localhost message" width="588" height="157"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With your &lt;strong&gt;server.js&lt;/strong&gt; file set up and now listening on port 5000, your backend is ready to go to respond to requests!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnlgexgo227rupoxfnfng.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnlgexgo227rupoxfnfng.png" alt="terminal output" width="698" height="186"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we make updates to the backend, it's important to note that we'll need to stop and start it for the changes to take effect.&lt;/p&gt;

&lt;p&gt;To &lt;strong&gt;turn off&lt;/strong&gt; the backend, press &lt;strong&gt;Ctrl + C&lt;/strong&gt; in the terminal where the backend is currently running.&lt;/p&gt;

&lt;p&gt;To &lt;strong&gt;turn on&lt;/strong&gt; the backend, run this command again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run mailstart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a id="Creating-Nodemailer-Functions-for-Email-Sending"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Creating Nodemailer Functions for Email Sending
&lt;/h4&gt;

&lt;p&gt;Let's bring the power of Nodemailer into your backend to enable the actual sending of emails. We'll start by configuring Nodemailer using the details from your Whois email information.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Setting Up Transport Configuration:&lt;/strong&gt;
Create the &lt;strong&gt;transport&lt;/strong&gt; object, which holds the configuration for sending emails. Replace the fields with the details from your Whois email information. This includes the SMTP host, port, user, password, and the email address from which the emails will be sent:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var transport = {
    host: creds.HOST,
    port: creds.MAILPORT,
    auth: {
        user: creds.USER,
        pass: creds.PASS,
    },
    from: creds.EMAIL,
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Creating the Nodemailer Transporter:&lt;/strong&gt;
Next, utilize the &lt;strong&gt;transport&lt;/strong&gt; configuration to create a Nodemailer transporter. This transporter is responsible for sending emails. We'll also use the &lt;strong&gt;verify&lt;/strong&gt; method to ensure that the server is ready to accept messages:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var transporter = nodemailer.createTransport(transport);
transporter.verify((error, success) =&amp;gt; {
    if (error) {
        console.log(error);
    } else {
        console.log('Server is ready to take messages');
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's start the backend server. In case of any issues, the terminal will show an error message, usually due to incorrect SMTP settings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fimapjz94a7tj4zjm30pk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fimapjz94a7tj4zjm30pk.png" alt="terminal output" width="800" height="182"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a id="Crafting-API-Routes-for-Email-Handling"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Crafting API Routes for Email Handling
&lt;/h4&gt;

&lt;p&gt;Now, we're about to tie everything together by creating API routes that handle email sending requests. These routes will enable your backend to receive data from your frontend, send the message to your email, and even respond with an automated acknowledgment. Exciting, isn't it?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;router.post('/send', (req, res, next) =&amp;gt; {
    var name = req.body.name;
    var email = req.body.email;
    var message = req.body.message;
    var senderEmail = `${name} &amp;lt;${creds.EMAIL}&amp;gt;`;
    var yourEmail = `${creds.YOURNAME} &amp;lt;${creds.EMAIL}&amp;gt;`;
    var content = `name: ${name} \n email: ${email} \n message: ${message} `;
    var mail = {
        from: senderEmail,
        to: creds.EMAIL,
        subject: `New Portfolio Message from ${name}`,
        text: content,
    };

//Deliver message from your portfolio to your email address
    transporter.sendMail(mail, (err, data) =&amp;gt; {
        console.log(err);
        console.log(data);
        if (err) {
            res.json({
                status: 'fail',
            });
        } else {
            res.json({
                status: 'success',
            });

            //If Success, send Auto Reply email
            transporter.sendMail(
                {
                    from: yourEmail,
                    to: email,
                    subject: 'Message received',
                    text: `Hi ${name},\nThank you for sending me a message. I will get back to you soon.\n\nBest Regards,\n${creds.YOURNAME}\n${creds.YOURSITE}\n\n\nMessage Details\nName: ${name}\n Email: ${email}\n Message: ${message}`,
                    html: `&amp;lt;p&amp;gt;Hi ${name},&amp;lt;br&amp;gt;Thank you for sending me a message. I will get back to you soon.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Best Regards,&amp;lt;br&amp;gt;${creds.YOURNAME}&amp;lt;br&amp;gt;${creds.YOURSITE}&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Message Details&amp;lt;br&amp;gt;Name: ${name}&amp;lt;br&amp;gt; Email: ${email}&amp;lt;br&amp;gt; Message: ${message}&amp;lt;/p&amp;gt;`,
                },
                function (error, info) {
                    if (error) {
                        console.log(error);
                    } else {
                        console.log('Message sent: ' + info.response);
                    }
                }
            );
        }
    });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this code, the &lt;strong&gt;/send&lt;/strong&gt; route is created to handle POST requests from your frontend. It extracts the &lt;strong&gt;name&lt;/strong&gt;, &lt;strong&gt;email&lt;/strong&gt;, and &lt;strong&gt;message&lt;/strong&gt; from the request body and constructs an email to send to your specified email address. It also sends an auto-reply to the sender using the provided data.&lt;/p&gt;

&lt;p&gt;With this code, your backend is now fully equipped to handle email sending requests. The message data will be extracted from the request and sent to your designated email address, while an automatic acknowledgment will be sent back to the sender. Your backend is primed and ready to test.&lt;/p&gt;

&lt;p&gt;&lt;a id="Testing-Your-Full-Stack-Contact-Form-Locally"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing Your Full-Stack Contact Form Locally
&lt;/h3&gt;

&lt;p&gt;Great job! You're now at the exciting stage of testing your full-stack contact form locally. Follow these steps to see your creation in action:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Start the Backend:&lt;/strong&gt; Open a terminal window, navigate to the backend folder and run:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run mailstart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will fire up your backend server.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Start the Frontend:&lt;/strong&gt; Open another terminal window, navigate to the frontend folder, and run:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will start your frontend development server.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Test the Form:&lt;/strong&gt; With both the backend and frontend servers up and running, open your browser and navigate to the localhost for the frontend. Mine defaults to &lt;strong&gt;&lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt;&lt;/strong&gt; (use the appropriate port for your frontend server).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Fill out the contact form with some test data with a valid return email and hit the submit button.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj5infibvpkjberuo3vu4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj5infibvpkjberuo3vu4.png" alt="sending message" width="800" height="553"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should see a successful message on the frontend, indicating that the message was sent.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwqx0ic07gmdcj1mtjvgt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwqx0ic07gmdcj1mtjvgt.png" alt="message sent" width="800" height="605"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Try &lt;strong&gt;testing&lt;/strong&gt; the form for &lt;strong&gt;issues&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;These are covered on the client-side.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;missing data&lt;/li&gt;
&lt;li&gt;using an invalid email format&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You should see the following error message on the frontend when the form is unable to send the message with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;incorrect credentials&lt;/li&gt;
&lt;li&gt;backend server is turned off&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fil60exw2sxrb77qey99y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fil60exw2sxrb77qey99y.png" alt="error" width="800" height="607"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Check Emails:&lt;/strong&gt; Now, check your email inbox. You should receive an email from the tester's name containing the message details. The sender will also receive an auto-reply acknowledging the message.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Your contact form's mailbox will show the following:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjx49dn9i8k2ttqdrc872.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjx49dn9i8k2ttqdrc872.png" alt="contact message" width="754" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The sender will receive this auto-reply message:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj1r18qmyhi10kxo4pn19.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj1r18qmyhi10kxo4pn19.png" alt="sender's auto reply" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With these steps, you've successfully tested your full-stack contact form locally! 🎇 The messages are being sent from your frontend, processed by your backend, and received in your email inbox. It's a satisfying moment when everything comes together seamlessly.&lt;/p&gt;

&lt;p&gt;&lt;a id="GitHub-Repository-for-Backend-Code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  GitHub Repository for Backend Code
&lt;/h2&gt;

&lt;p&gt;You can find the complete &lt;a href="https://github.com/diazelena325/contactform_backend" rel="noopener noreferrer"&gt;backend code on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the upcoming and final part of this series, we'll delve into the exciting realm of deploying your full-stack contact form, making it accessible online. This step is pivotal as it enables you to amplify your communication capabilities with visitors to your website. Stay tuned for a wealth of valuable insights and practical guidance that will take your project to its grand finale.&lt;/p&gt;

&lt;p&gt;As a quick recap, if you haven't already, make sure to catch &lt;a href="https://dev.to/elenadiaz32505/part-1-full-stack-contact-form-getting-started-react-frontend-2023-1bh4"&gt;Part 1: Getting Started &amp;amp; React Frontend Development&lt;/a&gt; of this series where we ventured into creating the frontend contact form, skillfully integrating the POST request that seamlessly connects to the backend. Your journey is nearly complete, and the culmination promises to be both enlightening and rewarding. &lt;a href="https://dev.to/elenadiaz32505/part-3-building-a-full-stack-contact-form-deployment-2023-2dj6"&gt;Part 3: Deployment&lt;/a&gt; will be the final touches and getting everything ready for deployment.&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀🌠&lt;/p&gt;




&lt;p&gt;If you found this helpful, support my work by sharing this article, referring me for frontend jobs, or if inclined &lt;a href="https://www.buymeacoffee.com/elenadiaz32505" rel="noopener noreferrer"&gt;Buy Me A Coffee&lt;/a&gt;, &lt;a href="https://ko-fi.com/elenadiaz" rel="noopener noreferrer"&gt;Ko-fi&lt;/a&gt;, or &lt;a href="https://paypal.me/elenadiaz32505" rel="noopener noreferrer"&gt;Paypal&lt;/a&gt;. Your support keeps me going – thank you!&lt;/p&gt;

</description>
      <category>node</category>
      <category>backend</category>
      <category>email</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Part 1 - Full Stack Contact Form: Getting Started &amp; React Frontend 2023</title>
      <dc:creator>Elena Diaz</dc:creator>
      <pubDate>Sun, 20 Aug 2023 01:28:14 +0000</pubDate>
      <link>https://dev.to/elenadiaz32505/part-1-full-stack-contact-form-getting-started-react-frontend-2023-1bh4</link>
      <guid>https://dev.to/elenadiaz32505/part-1-full-stack-contact-form-getting-started-react-frontend-2023-1bh4</guid>
      <description>&lt;p&gt;Have you ever followed a tutorial to create a contact form, only to hit a roadblock when it comes to moving beyond your local environment? If that frustration sounds familiar, you're in good company. As I worked on refining my portfolio site and adding more functionalities, I realized the vital role that backend processes play in achieving a truly flawless user experience. This insight prompted me to put together a comprehensive tutorial that leaves no stone unturned – from initial form creation to the final deployment steps.&lt;/p&gt;

&lt;p&gt;Throughout this series, we'll delve deep into the realm of web development, crafting a polished and fully functional contact form that enhances your website's communication capabilities. By the time you reach the end of this guide, you'll possess the skills needed to elevate your website with a truly seamless communication channel.&lt;/p&gt;

&lt;h3&gt;
  
  
  Contents
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
Getting Started

&lt;ul&gt;
&lt;li&gt;What You'll Accomplish&lt;/li&gt;
&lt;li&gt;Prerequisites and Tools&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Setting Up a Domain Email with Whois.com&lt;/li&gt;

&lt;li&gt;

Setting Up the Frontend (React)

&lt;ul&gt;
&lt;li&gt;Creating a New React Application&lt;/li&gt;
&lt;li&gt;Crafting a User-Friendly Contact Form Interface with Inputs and Messages&lt;/li&gt;
&lt;li&gt;Elevating the Form's Aesthetics with CSS Styling&lt;/li&gt;
&lt;li&gt;Enabling Form Data Management with State&lt;/li&gt;
&lt;li&gt;Implementing Client-Side Validation for Email Input&lt;/li&gt;
&lt;li&gt;Creating the Email Sending Function and Integrating Backend Communication&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;GitHub Repository for Frontend Code&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a id="Getting-Started-&amp;amp;-Frontend-Development"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;Welcome to Part 1 of this 3 part comprehensive guide, where we'll embark on a journey to create a full stack contact form using the power of React and Node.js.&lt;/p&gt;

&lt;p&gt;&lt;a id="What-youll-accomplish"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What You'll Accomplish
&lt;/h3&gt;

&lt;p&gt;In this multi-part tutorial, I'll guide you through the process of building a robust full-stack contact form using React and Node.js. By following along, you'll:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Integrate Domain Email:&lt;/strong&gt; Learn how to create and integrate a personalized email address associated with your domain, elevating your website's professionalism.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Create a User-Friendly Frontend:&lt;/strong&gt; Design an intuitive and visually appealing contact form interface using React, ensuring your users have a smooth interaction.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Set Up a Powerful Backend:&lt;/strong&gt; Build a Node.js backend to process and manage incoming contact form submissions, making sure no messages slip through the cracks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Achieve Seamless Deployment:&lt;/strong&gt; Deploy your completed full-stack contact form project online, allowing visitors to your website to access and utilize the contact form efficiently.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a id="Prerequisites-and-Tools"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites and Tools
&lt;/h3&gt;

&lt;p&gt;Before we take the plunge into creating our full-stack contact form, let's make sure you're equipped with the right skills and tools. Here's what you'll need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Solid Foundation:&lt;/strong&gt; It's essential to have a strong grasp of React, JavaScript, HTML, CSS, and Node.js. These form the backbone of our development journey. Additionally, a familiarity with NPM (Node Package Manager) for handling dependencies will prove advantageous.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Code Editor:&lt;/strong&gt; I highly recommend working with Visual Studio Code (VsCode). Its user-friendly interface and powerful features will make your coding experience smoother.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Domain Email Setup:&lt;/strong&gt; To achieve a professional touch, we'll utilize Whois.com for configuring email addresses within your domain. This will enable automatic replies to those who reach out through the contact form.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;GitHub Repository:&lt;/strong&gt; Ensure you have a GitHub repository ready for version control and collaboration. This will be our launchpad for deploying the contact form.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hosting Exploration:&lt;/strong&gt; We'll explore the use of CyberPanel for hosting. Its streamlined approach will simplify the deployment process, ensuring your contact form is up and running efficiently.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, let's roll up our sleeves and get started on this exciting journey!&lt;/p&gt;

&lt;p&gt;&lt;a id="Setting-Up-a-Domain-Email-with-Whoiscom"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up a Domain Email with Whois.com
&lt;/h2&gt;

&lt;p&gt;If you're ready to elevate the professionalism of your website, configuring a personalized domain email can be a significant step. While this guide focuses on setting up a domain email through Whois.com, it's important to note that you can achieve similar results if you have access to the necessary SMTP (Simple Mail Transfer Protocol) data from your domain provider. Here's a step-by-step guide to help you create an email address associated with your domain:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Accessing the "Manage Email" Section:&lt;/strong&gt; Head over to Whois.com and after logging into your account and going into your domain, navigate to the "Manage Email" section. This is where you'll be orchestrating the creation of your domain-based email address.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Creating a New User:&lt;/strong&gt; Look for the "Add User" option – this will be your gateway to establishing an email address that's intricately tied to your domain.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Form Completion:&lt;/strong&gt; A form will pop up, fill it out with all the necessary information required for the new email address. This will include the email prefix (the part before the "@" symbol), alternate email, and other pertinent details.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;User Addition and Essential Details:&lt;/strong&gt; After successfully adding the user, a collection of essential details will be displayed. Keep these close, as they'll be integral to the backend setup.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fdiazelena325%2Fcontactform%2Fmain%2Ftutorial_images%2FSMTP_INFO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fdiazelena325%2Fcontactform%2Fmain%2Ftutorial_images%2FSMTP_INFO.png" alt="whois email information"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This process ensures a personalized email address linked to your domain, enhancing your professional communication capabilities.&lt;/p&gt;

&lt;p&gt;&lt;a id="Setting-Up-the-Frontend-(React)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up the Frontend (React)
&lt;/h2&gt;

&lt;p&gt;Now that we've laid the groundwork, it's time to tackle the frontend using the power of React.&lt;/p&gt;

&lt;p&gt;&lt;a id="Creating-a-New-React-Application"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a New React Application
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Prepare the Workspace:&lt;/strong&gt; Begin by creating a dedicated folder for your project and open it in your preferred code editor, such as Visual Studio Code (VSCode).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Initialize the React App:&lt;/strong&gt; Open the Terminal within your project folder and choose one of the following commands to initiate a React app template:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For a comprehensive React template:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

npx create-react-app .


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;For a simplified minimalist React template:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

npx nano-react-app .


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Launching the App Locally:&lt;/strong&gt; To run your newly created React application on your local machine, execute the following command:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you opted for the comprehensive template:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

npm start


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you went with the minimalist template, perform these two commands:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

npm install
npm start


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a id="Crafting-a-User-Friendly-Contact-Form-Interface-with-Inputs-and-Messages"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Crafting a User-Friendly Contact Form Interface with Inputs and Messages
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Selecting App.js for Efficiency:&lt;/strong&gt; To expedite development, we'll employ the &lt;strong&gt;App.js&lt;/strong&gt; file for constructing the contact form. If you don't already have an &lt;strong&gt;App.css&lt;/strong&gt; file, create one within the same location as App.js.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

/contactform
    /src
        ├── App.css
        ├── App.jsx
        ├── index.jsx



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Initial Page Structure:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The starting configuration of your page will resemble this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import React from 'react';
import './App.css';

function App() {
    return (
        &amp;lt;div&amp;gt;
        &amp;lt;/div&amp;gt;
    );
}

export default App;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Enhancing with Form Elements:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Populate your App.jsx file with the following code to build the foundation of the contact form interface:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import React from 'react';
import './App.css';

function App() {
    return (
        &amp;lt;div className='app'&amp;gt;
            &amp;lt;h1&amp;gt;Contact Me&amp;lt;/h1&amp;gt;
            &amp;lt;form
                id='contact-form'
                className='contact-form'&amp;gt;
                &amp;lt;input
                    placeholder='name*'
                    type='text'
                    name='name'
                    required={true}
                /&amp;gt;
                &amp;lt;input
                    placeholder='email address*'
                    type='email'
                    name='email'
                    required={true}
                /&amp;gt;
                &amp;lt;textarea
                    maxLength={300}
                    placeholder='message (max 300 characters)*'
                    name='message'
                    required={true}
                /&amp;gt;
                &amp;lt;button type='submit'&amp;gt;Submit&amp;lt;/button&amp;gt;
            &amp;lt;/form&amp;gt;
        &amp;lt;/div&amp;gt;
    );
}

export default App;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a id="Elevating-the-Form's-Aesthetics-with-CSS-Styling"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Elevating the Form's Aesthetics with CSS Styling
&lt;/h3&gt;

&lt;p&gt;To create a simple and user-friendly form, let's enhance its visual appeal with some CSS styling.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Defining Color Variables:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Start by setting up color variables in your :root selector:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

:root {
    --maincolor: #ffcdb2;
    --basecolor: #6d6875;
    --accentcolor1: #ffb4a2;
    --accentcolor2: #e5989b;
    --accentcolor3: #b5838d;
    --whitecolor: #ffffff;
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Structuring the App Container:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Implement styling for the main container holding the form:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

.app {
    font-family: Helvetica, sans-serif;
    background-color: var(--maincolor);
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--basecolor);
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Formatting the Contact Form:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Craft styling rules for the contact form and its elements:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 50%;
}

.contact-form &amp;gt; input {
    height: 2.5rem;
    border: none;
    border-radius: 2px;
    background-color: var(--accentcolor1);
    font-size: 1.4rem;
    color: var(--basecolor);
    padding: 0.5rem;
}

.contact-form &amp;gt; textarea {
    height: 7rem;
    border: none;
    border-radius: 2px;
    background-color: var(--accentcolor2);
    font-size: 1.4rem;
    color: var(--basecolor);
    padding: 0.5rem;
    resize: none;
}

input::placeholder,
textarea::placeholder {
    color: var(--basecolor);
}

.contact-form &amp;gt; button {
    height: 3rem;
    border: none;
    border-radius: 2px;
    background-color: var(--accentcolor3);
    font-size: 1.4rem;
    color: var(--whitecolor);
    padding: 0.5rem;
    cursor: pointer;
    transition: 0.4s ease-in-out;
}

.contact-form &amp;gt; button:hover {
    transition: 0.4s ease-in-out;
    background-color: var(--basecolor);
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here is the final look:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fdiazelena325%2Fcontactform%2Fmain%2Ftutorial_images%2FContactMeFrontend.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fdiazelena325%2Fcontactform%2Fmain%2Ftutorial_images%2FContactMeFrontend.png" alt="Contact Form Frontend"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a id="Enabling-Form-Data-Management-with-State"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Enabling Form Data Management with State
&lt;/h3&gt;

&lt;p&gt;Let's delve into the realm of functionality. To streamline the process, we'll harness the power of state management, ensuring smoother data storage and updates in tandem with the backend.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Importing useState:&lt;/strong&gt;
Begin by importing the useState hook from React:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import React, { useState } from 'react';


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Implementing State Instances:&lt;/strong&gt;
Set up instances for managing different aspects of the form's state:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

function App() {
    //Email form
    const [emailForm, setEmailForm] = useState({
        name: '',
        email: '',
        message: '',
    });

    //Result if message was sent or not
    const [result, setResult] = useState('');

    //Status of while message is being sent
    const [status, setStatus] = useState('Submit');

    // Rest of the JSX and form components...
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Binding State to Form Inputs:&lt;/strong&gt;
Bind the state values to the respective input fields:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

    &amp;lt;input
        placeholder='name*'
        type='text'
        name='name'
        required={true}
        value={emailForm.name}
    /&amp;gt;
    &amp;lt;input
        placeholder='email address*'
        type='email'
        name='email'
        required={true}
        value={emailForm.email}
    /&amp;gt;
    &amp;lt;textarea
        maxLength={300}
        placeholder='message (max 300 characters)*'
        name='message'
        required={true}
        value={emailForm.message}
    /&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Updating Submit Button and Result Display:&lt;/strong&gt;
Adjust the button text to display the sending status, and include an &lt;strong&gt;'h3'&lt;/strong&gt; element to showcase the result, bound to the &lt;strong&gt;'result'&lt;/strong&gt; state:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;button type='submit'&amp;gt;{status}&amp;lt;/button&amp;gt;
&amp;lt;h3&amp;gt;{result}&amp;lt;/h3&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;By incorporating useState, you're effectively enhancing the management of your form's data. This dynamic approach ensures that data is stored and updated seamlessly, creating a user-friendly interaction. With these elements in place, your contact form is poised to become a dynamic communication tool.&lt;/p&gt;

&lt;p&gt;&lt;a id="Implementing-Client-Side-Validation-for-Email-Input"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementing Client-Side Validation for Email Input
&lt;/h3&gt;

&lt;p&gt;Enhance your form's interactivity by incorporating client-side validation. This step will ensure smoother handling of user input and improve the overall user experience.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Function to Reset the Form:&lt;/strong&gt;
Let's begin by creating a function that clears the emailForm values once the submission is complete:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

function resetEmailForm() {
        setEmailForm({ name: '', email: '', message: '' });
    }


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Function to Handle Form Changes:&lt;/strong&gt;
Next, develop a function that updates the emailForm values as changes occur in the input fields. Additionally, if there's a result message displayed, it will be cleared:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

function handleEmailFormChange(event) {
        setEmailForm((prevEmailData) =&amp;gt; {
            return {
                ...prevEmailData,
                [event.target.name]: event.target.value,
            };
        });

        if (result.length &amp;gt; 0) {
            setResult('');
        }
    }


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Applying Function to Input Fields:&lt;/strong&gt;
Implement the &lt;strong&gt;'handleEmailFormChange'&lt;/strong&gt; function to each input field using the &lt;strong&gt;'onChange'&lt;/strong&gt; event:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;input
    placeholder='name*'
    type='text'
    name='name'
    required={true}
    value={emailForm.name}
    onChange={handleEmailFormChange}
/&amp;gt;
&amp;lt;input
    placeholder='email address*'
    type='email'
    name='email'
    required={true}
    value={emailForm.email}
    onChange={handleEmailFormChange}
/&amp;gt;
&amp;lt;textarea
    maxLength={300}
    placeholder='message (max 300 characters)*'
    name='message'
    required={true}
    value={emailForm.message}
    onChange={handleEmailFormChange}
/&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a id="Creating-the-Email-Sending-Function-and-Integrating-Backend-Communication"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating the Email Sending Function and Integrating Backend Communication
&lt;/h3&gt;

&lt;p&gt;Now it's time to bring your contact form to life by crafting the function responsible for initiating the email sending process and integrating communication with the backend. This step will enable the dynamic interaction between your frontend and backend systems.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Adding the Form Submission Functionality:&lt;/strong&gt;
Integrate the &lt;strong&gt;'handleSubmit'&lt;/strong&gt; function with your form using the &lt;strong&gt;'onSubmit'&lt;/strong&gt; event handler:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;Form
    id='contact-form'
    onSubmit={handleSubmit}
    method='POST'&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Implementing the handleSubmit Function:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The handleSubmit function orchestrates the entire email sending process. It extracts data from the form, initiates a POST request to the backend, and handles response messages accordingly:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

const handleSubmit = async (e) =&amp;gt; {
        setResult('');
        e.preventDefault();
        setStatus('Sending...');

        const { name, email, message } = e.target.elements;

        let details = {
            name: name.value,
            email: email.value,
            message: message.value,
        };

        try {
            let response = await fetch('http://localhost:5000/send', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json;charset=utf-8',
                },
                body: JSON.stringify(details),
            });
            setStatus('Submit');
            let result = await response.json();

            if (result.status === 'success') {
                setResult('Message Sent!');
                resetEmailForm();
            } else if (result.status === 'fail') {
                alert('Uh oh! Message failed to send.');
            }
        } catch (error) {
            console.error(error);
            setStatus('Submit');
            setResult('Uh oh! Issues with submitting message.');
        }
    };


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;🎆Yay, frontend has been completed!🎆&lt;/p&gt;

&lt;p&gt;&lt;a id="GitHub-Repository-for-Frontend-Code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  GitHub Repository for Frontend Code
&lt;/h2&gt;

&lt;p&gt;You can find the complete &lt;a href="https://github.com/diazelena325/contactform" rel="noopener noreferrer"&gt;frontend code on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; When you attempt to submit the form, you will encounter an issue as the backend has not been created yet.&lt;/p&gt;

&lt;p&gt;With the frontend development phase successfully completed, our next step is to dive into crafting the backend. Get ready for &lt;a href="https://dev.to/elenadiaz32505/part-2-building-a-full-stack-contact-form-nodejs-backend-2023-jdp"&gt;Part 2: Node.js Backend Development&lt;/a&gt;, where we'll explore the backend creation process and ensure the full-stack contact form is up and running flawlessly.&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀🪐&lt;/p&gt;




&lt;p&gt;If you found this helpful, support my work by sharing this article, referring me for frontend jobs, or if inclined &lt;a href="https://www.buymeacoffee.com/elenadiaz32505" rel="noopener noreferrer"&gt;Buy Me A Coffee&lt;/a&gt;, &lt;a href="https://ko-fi.com/elenadiaz" rel="noopener noreferrer"&gt;Ko-fi&lt;/a&gt;, or &lt;a href="https://paypal.me/elenadiaz32505" rel="noopener noreferrer"&gt;Paypal&lt;/a&gt;. Your support keeps me going – thank you!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>react</category>
    </item>
  </channel>
</rss>
