<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Ijeoma Igboagu - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Ijeoma Igboagu - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sun, 24 May 2026 16:29:43 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/author/Ijay/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ Learn Cloud Security Fundamentals in AWS – A Guide for Beginners ]]>
                </title>
                <description>
                    <![CDATA[ Security is a vital part of every system and infrastructure. The word "security" comes from the Latin securitas, which is composed of se- (meaning “without”) and cura (meaning “care” or “worry”). Originally, it meant "without worry." Over time, it ha... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/learn-cloud-security-fundamentals-in-aws-a-guide-for-beginners/</link>
                <guid isPermaLink="false">69377429f6e4912378332463</guid>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ cloud security ]]>
                    </category>
                
                    <category>
                        <![CDATA[ #sharedresponsibilitymodel ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cloud Computing ]]>
                    </category>
                
                    <category>
                        <![CDATA[ BeginnerFriendly ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ijeoma Igboagu ]]>
                </dc:creator>
                <pubDate>Tue, 09 Dec 2025 00:58:17 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1764958826138/12b261c3-9a38-4b0b-b67a-48ce54452d5f.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Security is a vital part of every system and infrastructure. The word "security" comes from the Latin <em>securitas</em>, which is composed of <em>se-</em> (meaning “without”) and <em>cura</em> (meaning “care” or “worry”). Originally, it meant "without worry." Over time, it has come to signify being safe or protected.</p>
<p>Today, when we discuss security, we usually refer to protection from harm, danger, or threats, whether in our homes, online, while using online banking, or even across an entire country. Security is important in everything we do.</p>
<p>Cloud providers, such as AWS, are no exception. Their infrastructure must be safeguarded to ensure users’ peace of mind. But on platforms like AWS, security is a <strong>shared responsibility</strong>. This means that both the provider and the user play a role in maintaining security.</p>
<p>Amazon Web Services (AWS) is one of the most popular cloud service providers worldwide. With great power and flexibility comes the responsibility to secure your infrastructure, data, and applications in the cloud.</p>
<p>In this tutorial, we’ll explore the fundamental aspects of cloud security in AWS – especially those that are your responsibility – making it easy to understand if you’re new to cloud computing.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ol>
<li><p><a class="post-section-overview" href="#heading-what-is-cloud-security">What is Cloud Security?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-why-is-cloud-security-important">Why is Cloud Security Important?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-key-cloud-security-concepts">Key Cloud Security Concepts</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-what-is-a-root-user">What is a Root User?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-create-an-iam-user-for-daily-tasks">How to Create an IAM User for Daily Tasks</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-key-differences-between-the-root-user-and-an-iam-user">Key Differences Between the Root User and an IAM User</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-what-is-mfa">What is MFA?</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-understanding-the-aws-shared-responsibility-model">Understanding the AWS Shared Responsibility Model</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-rds-relational-database-service">RDS (Relational Database Service)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-s3-simple-storage-service">S3 (Simple Storage Service)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-give-a-user-permission">How to give a user permission</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-testing-the-policy">Testing the Policy</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
<ul>
<li><a class="post-section-overview" href="#heading-further-reading">Further Reading</a></li>
</ul>
</li>
</ol>
<h2 id="heading-what-is-cloud-security">What is Cloud Security?</h2>
<p>Cloud security is the set of rules, tools, and practices used to protect your data, apps, and services stored online (in the "cloud"). It helps prevent data loss, hacking, and misuse of information.</p>
<p>Think of cloud security like locking the doors of your house. You wouldn’t leave your doors open for anyone to enter. And in the same way, your cloud account must be secured so that your data remains safe.</p>
<p>If your cloud services aren't secure, hackers could steal your data or cause major damage. Whether you're a business or just someone using cloud apps, keeping your information safe is essential.</p>
<h2 id="heading-why-is-cloud-security-important">Why is Cloud Security Important?</h2>
<p>Cloud security matters because it ensures that only the right people have access to your information. It protects your data from being lost, stolen, or misused. With good security in place, your applications can run safely without being exposed to attacks.</p>
<p>It also helps you keep your personal or business data private. When your cloud environment is well-protected, the risk of data breaches and financial loss is greatly reduced.</p>
<p>Now that you understand why cloud security is important, let’s look at how AWS helps you stay secure and what your own role is in keeping things safe.</p>
<h2 id="heading-key-cloud-security-concepts">Key Cloud Security Concepts</h2>
<p>In AWS, cloud security is the responsibility of both AWS <strong>and</strong> the customer. This model is called the Shared Responsibility Model.</p>
<p>But before learning how AWS divides security duties, you need to understand that while AWS protects its infrastructure, you must protect your own account.</p>
<p>Let’s discuss some key security concepts that are your responsibility, so you know how to do your part in the shared responsibility model.</p>
<h3 id="heading-what-is-a-root-user">What is a Root User?</h3>
<p>When you create an AWS account, the first identity that’s created is the <strong>Root</strong> user Account. This account has full, unrestricted control. It can delete resources, change ownership, and even close your entire AWS account. Because of this, it’s risky to use it for everyday tasks.</p>
<p>AWS recommends using root only for a few important account-level actions.</p>
<p>Certain tasks require a root user account, so you will need to use it occasionally. Such tasks include:</p>
<ul>
<li><p>Updating billing and payment information</p>
</li>
<li><p>Closing your AWS account</p>
</li>
<li><p>Changing the root account email</p>
</li>
<li><p>Recovering or resetting MFA for the root user</p>
</li>
</ul>
<p>Apart from these few tasks, avoid using the root user Account completely. Your everyday work should be done through IAM users, not the root account.</p>
<h3 id="heading-how-to-create-an-iam-user-for-daily-tasks">How to Create an IAM User for Daily Tasks</h3>
<p>Before you start creating any infrastructure in your AWS account, you need an IAM user with the right permissions.</p>
<p>Here’s how to create an IAM user, step by step:</p>
<ul>
<li><p>Open the AWS console.</p>
</li>
<li><p>Search for <strong>IAM</strong>, then select it. This takes you to the <strong>IAM page</strong>.</p>
</li>
<li><p>On the left-hand side, you will see <strong>Users</strong>.</p>
</li>
<li><p>Click on it. This takes you to the <strong>Create user</strong> page.</p>
</li>
<li><p>Click the <strong>Create user</strong> button. It takes you to the “specify user details page” where you will create an <strong>IAM user.</strong></p>
</li>
<li><p>Enter a username (for example, <code>adminuser</code>).</p>
</li>
<li><p>Click on “Provide user access to the AWS Management Console”.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764236205525/47c2da54-537f-4242-9048-ced4b7ca6172.png" alt="providing a user access to the AWS console" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<ol start="4">
<li><p>Scroll down and click on “Set a password,” or let AWS generate one for you.</p>
</li>
<li><p>Click <strong>Next</strong> to go to the permissions page.</p>
</li>
<li><p>Select <strong>Attach existing policies directly</strong>.</p>
</li>
<li><p>Choose <code>AdministratorAccess</code>. This permission gives the IAM user full access to perform all administrative tasks in your account.</p>
</li>
<li><p>Click <strong>Create user</strong>.</p>
</li>
</ol>
<p>Once you’ve created this user, sign in with it and use it for your day-to-day tasks. The root user should stay locked down and only be used for rare account-level changes.</p>
<h4 id="heading-video-walkthrough-of-how-to-create-an-iam-user">Video Walkthrough of How to Create an IAM User:</h4>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764235482269/bf5b1f00-13b2-4ff5-b1e4-e6b2fd2796cb.gif" alt="bf5b1f00-13b2-4ff5-b1e4-e6b2fd2796cb" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<h3 id="heading-key-differences-between-the-root-user-and-an-iam-user">Key Differences Between the Root User and an IAM User</h3>
<p>Just to be clear, let’s summarise the differences between these two accounts:</p>
<h4 id="heading-root-account">Root Account</h4>
<p>This is the very first account created when you set up AWS. It has unlimited power – literally, everything in the account can be changed, deleted, or closed.</p>
<p>It’s meant for rare, high-level tasks like billing changes, MFA resets, or closing the account. Because it’s so powerful, you shouldn’t use it for daily work.</p>
<h4 id="heading-iam-user-account">IAM User Account</h4>
<p>This is a user you create inside your AWS account for everyday tasks. You can assign specific permissions, like admin or limited access, to this user. It’s much safer because you can control what it can and cannot do.</p>
<p>If something goes wrong or the credentials are compromised, the blast radius is much smaller than for the root user.</p>
<p>In short, the Root is the master key too powerful for daily use. IAM users are customizable and safer for your regular work.</p>
<p>Here’s a helpful visual to show the differences between the two as well:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764248147852/7e053766-f6ba-4a17-9b63-c20695f2933c.jpeg" alt="differences between the two account" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>Now that you have both your root user and IAM user set up properly, let’s go back to the concept of multi-factor authentication, or MFA.</p>
<h3 id="heading-what-is-mfa">What is MFA?</h3>
<p>MFA adds another layer of security when you sign in. It combines something you know, like your password, with something you have, such as a phone or security device. Even if someone gets your password, they can’t log in without your MFA code.</p>
<p>You can enable MFA in several ways:</p>
<ul>
<li><p>Using a virtual MFA app like Google Authenticator or Authy</p>
</li>
<li><p>Using a physical security key such as a YubiKey</p>
</li>
<li><p>Using a hardware device from Gemalto</p>
</li>
<li><p>For AWS GovCloud users, using an MFA device from SurePassID</p>
</li>
</ul>
<p>Enabling MFA makes sure that even if someone gets your password, they still can’t access your account without the second authentication step.</p>
<p>For this tutorial, we’ll use the <strong>Google Authenticator app</strong>, which you can download for free from the Play Store.</p>
<p><strong>How do I turn this on for my account?</strong></p>
<ul>
<li><p>Go to your AWS account.</p>
</li>
<li><p>At the top right corner, you’ll see a menu with your account username or ID. Click on it to open the drop-down.</p>
</li>
<li><p>You’ll see <strong>Security Credentials</strong>. Click on it. This will take you to the IAM-Security Credentials page.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764342765366/76b8ef01-9be2-4d93-918e-aaadf9e771ed.png" alt="security credentials" width="600" height="400" loading="lazy"></p>
<ul>
<li><p>At the top of the page, you’ll see a button labelled <strong>Assign MFA device</strong>. Click on it.</p>
</li>
<li><p>You’ll be redirected to a new page where you can choose the type of MFA device you want to use. Scroll down and select <strong>Virtual MFA device</strong> (this is what the Google Authenticator app uses).</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764342668287/5867caaf-af5d-4dfe-b026-68a16dfa1ad1.png" alt="MFA page selection" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>Then just follow the on-screen instructions:</p>
<ul>
<li><p>Open the <strong>Google Authenticator</strong> app on your phone.</p>
</li>
<li><p>Tap the <strong>+</strong> button and scan the QR code displayed on the AWS screen.</p>
</li>
<li><p>Enter the two codes generated by the app to verify your device.</p>
</li>
</ul>
<p>Once verified, AWS will link the MFA device to your account and take you back to the Security credentials page. If you scroll down, you’ll see your MFA device listed as <strong>assigned</strong>.</p>
<p>The next time you log in to AWS, you’ll be prompted to enter your MFA code from the Google Authenticator app before you can access your console.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764345845580/2eec5886-7ce7-43e0-8612-1035655a0619.gif" alt="MFA verification at login" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>Always enable MFA for both your root user account and your IAM user account, as it’s one of the simplest and most effective ways to protect your AWS account.</p>
<p>Now that you understand these security fundamentals, we can get back to the shared responsibility model.</p>
<h2 id="heading-understanding-the-aws-shared-responsibility-model">Understanding the AWS Shared Responsibility Model</h2>
<p>The AWS Shared Responsibility Model divides responsibilities between AWS and the customer.</p>
<h3 id="heading-1-awss-responsibility-security-of-the-cloud">1. AWS’s Responsibility (Security of the Cloud)</h3>
<p>AWS is responsible for protecting the infrastructure that runs the services offered in the AWS Cloud. This includes physical security, hardware, software, networking, and facilities.</p>
<h3 id="heading-2-customers-responsibility-security-in-the-cloud">2. Customer’s Responsibility (Security in the Cloud)</h3>
<p>The customer is responsible for securing the data, user accounts, applications, and configurations they store in the cloud.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746970123152/016f8eef-fa2c-4bcb-866b-323fe7585b9d.png" alt="The shared responsibility model in AWS" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p><strong><em>Image source:</em></strong> <a target="_blank" href="https://aws.amazon.com/compliance/shared-responsibility-model/"><em>AWS shared responsibility model</em></a></p>
<p>For example, AWS is responsible for securing its data centres and servers. But customers also have a role to play by properly configuring their accounts and resources.</p>
<p>Let’s take two popular AWS services, <strong>RDS (Relational Database Service)</strong> and <strong>S3 (Simple Storage Service)</strong>, as examples.</p>
<h3 id="heading-rds-relational-database-service">RDS (Relational Database Service)</h3>
<p><strong>AWS responsibilities:</strong></p>
<ul>
<li><p>Automates database patching</p>
</li>
<li><p>Audits and maintains the underlying instance and storage disks</p>
</li>
<li><p>Applies operating system patches automatically</p>
</li>
</ul>
<p><strong>Customer responsibilities (you):</strong></p>
<ul>
<li><p>Manage in-database users, roles, and permissions</p>
</li>
<li><p>Choose whether your database is public or private</p>
</li>
<li><p>Review and control inbound rules, ports, and IP addresses in the database’s security group</p>
</li>
<li><p>Configure database encryption settings</p>
</li>
</ul>
<h3 id="heading-s3-simple-storage-service">S3 (Simple Storage Service)</h3>
<p><strong>AWS responsibilities:</strong></p>
<ul>
<li><p>Ensures encryption options are available for your data</p>
</li>
<li><p>Guarantees virtually unlimited storage capacity</p>
</li>
<li><p>Prevents AWS employees and the public from accessing your data</p>
</li>
<li><p>Keeps each customer’s data separated from others</p>
</li>
</ul>
<p><strong>Customer responsibilities (you):</strong></p>
<ul>
<li><p>Define your S3 bucket policies according to your security standards</p>
</li>
<li><p>Review bucket configuration settings</p>
</li>
<li><p>Create and manage IAM users and roles with the right permissions</p>
</li>
</ul>
<p>Now you understand who’s responsible for what.</p>
<h2 id="heading-how-to-give-a-user-permission">How to Give a User Permission</h2>
<p>Security in the cloud isn’t just about strong passwords or enabling MFA – it’s also about controlling <em>who</em> can access <em>what</em>. One of the most important principles in AWS security is to grant users only the access they actually need, nothing more. That’s how you keep your environment safe and your resources protected.</p>
<p>So here’s a key question: how do we know to whom to allow or deny access in the cloud?</p>
<h3 id="heading-demonstration">Demonstration</h3>
<p>Let’s walk through a simple, real-life example together.</p>
<p>Imagine you have a developer on your team who needs access to an S3 bucket named <strong>demo-test-app-ij</strong>. The goal is to let them upload and view files in the bucket, but not delete anything.</p>
<p>We already created a user earlier in this guide, so we’ll use that same one here.</p>
<p>To get started, go to <strong>IAM</strong> from your AWS Management Console. Then click on <strong>Users</strong> from the left-hand menu.</p>
<p>Select the user we created earlier. If you don’t have one yet, go back and follow the steps I showed you before to create a new IAM user.</p>
<p>Once you click on the user’s name, you’ll be taken to the <strong>Permissions</strong> page. On the permissions page, click on <strong>Add permissions</strong>.</p>
<p>From the dropdown options, select <strong>Create inline policy</strong>. This will open the <strong>Specify permissions</strong> page, where you’ll define the user’s access.</p>
<p>Scroll down through the list of services and select <strong>S3</strong>. In our example, we’re using S3 because we want to control access to a specific bucket.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764317236877/10517fde-3bbd-4af3-9e16-289793894903.png" alt="An example showing the permission page" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<p>Once you select the service you want to define permissions for, the <strong>Actions</strong> and <strong>Resources</strong> sections will appear automatically.</p>
<p>In the Actions section, you’ll see a list of what the user can do with the service. Here, you can toggle the effect button to either “Allow” or “Deny.”</p>
<p>Under Actions, scroll through the list and find <strong>DeleteObject</strong>. Set this action to Deny: DeleteObject. This ensures the user won’t be able to delete any files from the bucket.</p>
<p>Next, move on to the Resources section. Here, you’ll specify which bucket these permissions apply to.</p>
<p>Add the following bucket ARN: <code>arn:aws:s3:::demo-test-app-ij/*</code>. This means the rule applies to everything inside the <strong>demo-test-app-ij</strong> bucket.</p>
<p>Once you’ve added the ARN and confirmed the settings, click <strong>Save policy</strong>.</p>
<p>Now, let’s put all these instructions together in a practical example:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764335991549/1d33af0a-23c8-4790-aab4-b629db4b7ba9.gif" alt="1d33af0a-23c8-4790-aab4-b629db4b7ba9" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<h3 id="heading-testing-the-policy">Testing the Policy</h3>
<p>Now it’s time to confirm that our permissions work the way we expect.</p>
<p>Head over to the <strong>S3</strong> service and open the bucket named <strong>demo-test-app-ij</strong>. Try uploading a file; it should upload successfully. Next, try deleting that same file. You’ll see an error message saying <strong>Failed to delete objects</strong>.</p>
<p>That’s exactly what we want! The user can upload and view files, but can’t delete them, because we never permitted them to do so.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764336439667/279c1f4b-7d5b-477a-b782-cf1378204430.gif" alt="279c1f4b-7d5b-477a-b782-cf1378204430" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Security has always been about peace of mind. Whether it’s your home, your phone, or your cloud account, you’ll want to know your data is safe.</p>
<p>AWS gives you a strong foundation by securing the cloud itself. But your part matters too: things like enabling MFA, using strong passwords, and managing who can access what. These simple habits go a long way in keeping your data protected.</p>
<p>Cloud security isn’t a one-time setup. It’s an ongoing practice. When both AWS and its users stay alert, the cloud becomes a place you can trust to store, build, and grow with confidence.</p>
<p>Now that you have a basic understanding of how security works in AWS, you’re ready to go deeper and start exploring the services that keep it all running smoothly.</p>
<h3 id="heading-further-reading">Further Reading</h3>
<ul>
<li><p><a target="_blank" href="https://www.freecodecamp.org/news/cloud-computing-guide-for-beginners/">What is Cloud Computing? A Guide for Beginners</a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/ijaydimples">How t</a><a target="_blank" href="https://www.freecodecamp.org/news/how-to-deploy-a-kubernetes-app-on-aws-eks/">o D</a><a target="_blank" href="https://www.linkedin.com/in/ijeoma-igboagu/">eploy a</a> <a target="_blank" href="https://www.freecodecamp.org/news/how-to-deploy-a-kubernetes-app-on-aws-eks/">Kub</a><a target="_blank" href="https://github.com/ijayhub">ernete</a><a target="_blank" href="https://twitter.com/ijaydimples">s App o</a><a target="_blank" href="https://www.freecodecamp.org/news/how-to-deploy-a-kubernetes-app-on-aws-eks/">n A</a><a target="_blank" href="https://twitter.com/ijaydimples">WS EKS</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/news/best-aws-services-for-frontend-deployment/">T</a><a target="_blank" href="https://github.com/ijayhub">he Bes</a><a target="_blank" href="https://www.freecodecamp.org/news/best-aws-services-for-frontend-deployment/">t AW</a><a target="_blank" href="https://twitter.com/ijaydimples">S Servi</a><a target="_blank" href="https://www.freecodecamp.org/news/best-aws-services-for-frontend-deployment/">ces</a> <a target="_blank" href="https://www.linkedin.com/in/ijeoma-igboagu/">to Depl</a><a target="_blank" href="https://www.freecodecamp.org/news/best-aws-services-for-frontend-deployment/">oy</a> <a target="_blank" href="https://github.com/ijayhub">Front-</a><a target="_blank" href="https://www.freecodecamp.org/news/best-aws-services-for-frontend-deployment/">End Applications in 20</a><a target="_blank" href="https://twitter.com/ijaydimples">25</a></p>
</li>
<li><p><a target="_blank" href="https://twitter.com/ijaydimples">W</a><a target="_blank" href="https://www.freecodecamp.org/news/backend-as-a-service-beginners-guide/">hat</a> <a target="_blank" href="https://twitter.com/ijaydimples">is Back</a><a target="_blank" href="https://www.freecodecamp.org/news/backend-as-a-service-beginners-guide/">end</a> <a target="_blank" href="https://github.com/ijayhub">as a</a> <a target="_blank" href="https://www.freecodecamp.org/news/backend-as-a-service-beginners-guide/">Service (BaaS)? A Beginner's Guide</a></p>
</li>
<li><p><a target="_blank" href="https://dev.to/ijay/the-hidden-challenges-of-building-with-aws-8mg">The Hidden Challenges of Building with AWS</a></p>
</li>
</ul>
<p>If you found this article helpful, feel free to share it. And if you prefer learning through videos, I also explain cloud topics in simple terms on my <a target="_blank" href="https://www.youtube.com/@cloudinreallife">YouTube channel</a>.</p>
<p>Stay updated with my projects by following me on <a target="_blank" href="https://twitter.com/ijaydimples">Twitter</a>, <a target="_blank" href="https://www.linkedin.com/in/ijeoma-igboagu/">LinkedIn</a> and <a target="_blank" href="https://github.com/ijayhub">GitHub</a>.</p>
<p>Thank you for reading!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Deploy a Kubernetes App on AWS EKS ]]>
                </title>
                <description>
                    <![CDATA[ AWS makes it much easier to deploy containerized applications, and running Kubernetes in the cloud is a powerful way to scale and manage these applications. Among the many managed Kubernetes services AWS offers, Amazon EKS (Elastic Kubernetes Service... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-deploy-a-kubernetes-app-on-aws-eks/</link>
                <guid isPermaLink="false">68a85abd010317ca95b5506e</guid>
                
                    <category>
                        <![CDATA[ Devops ]]>
                    </category>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cloud ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Kubernetes ]]>
                    </category>
                
                    <category>
                        <![CDATA[ deployment ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ijeoma Igboagu ]]>
                </dc:creator>
                <pubDate>Fri, 22 Aug 2025 11:55:41 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755863277691/28937c4d-5862-464d-84a1-dfab01a577bb.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>AWS makes it much easier to deploy containerized applications, and running Kubernetes in the cloud is a powerful way to scale and manage these applications.</p>
<p>Among the many managed Kubernetes services AWS offers, Amazon EKS (Elastic Kubernetes Service) stands out for its seamless integration with the AWS ecosystem, strong reliability, and excellent support.</p>
<p>If you’re ready to move beyond local setups and want to deploy a real-world Kubernetes app on AWS EKS, this guide will walk you through the entire process. Whether you’re working on a microservice, a full-stack app, or just experimenting with Kubernetes in an environment that mimics production, you’ll find this walkthrough useful.</p>
<p>In this article, I’ll guide you through the process of creating your EKS cluster, deploying your application, and making it accessible over the internet, step by step.</p>
<h2 id="heading-what-well-cover">What We’ll Cover:</h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-prerequisites">Prerequisites</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-what-is-a-kubernetes-cluster">What is a Kubernetes Cluster?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-what-is-amazon-elastic-kubernetes-service">What is Amazon Elastic Kubernetes Service?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-why-use-amazon-eks-for-kubernetes">Why Use Amazon EKS for Kubernetes?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-create-a-kubernetes-cluster-using-aws">How to Create a Kubernetes Cluster Using AWS</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-resources">Resources</a></p>
</li>
</ul>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>To get started, make sure you have the following installed on your local machine:</p>
<ul>
<li><p>Have a basic understanding of cloud services.</p>
</li>
<li><p>Have a basic understanding of the Linux command line.</p>
</li>
<li><p>Have an <a target="_blank" href="https://aws.amazon.com/free/">AWS account</a>.</p>
</li>
<li><p>Install eksctl, a simple CLI tool to create and manage EKS clusters.</p>
</li>
<li><p>Install kubectl, the standard Kubernetes command-line tool.</p>
</li>
<li><p>Install Docker to build and package your app into a container.</p>
</li>
</ul>
<p>Before setting up a Kubernetes cluster for our application, it’s essential to understand a few basic concepts.</p>
<h2 id="heading-what-is-a-kubernetes-cluster"><strong>What is a Kubernetes Cluster?</strong></h2>
<p>A Kubernetes (also called K8S) cluster consists of machines (called nodes) that run containerized applications. It works alongside container engines like <a target="_blank" href="https://cri-o.io/#what-is-cri-o"><strong>CRI-O</strong></a> or <a target="_blank" href="https://containerd.io/"><strong>containerd</strong></a> to help you deploy and manage your apps more efficiently.</p>
<p>Kubernetes nodes come in two main types:</p>
<ul>
<li><p><strong>Master nodes (control plane):</strong> These handle the brainwork, such as scheduling, scaling, and managing the cluster’s overall state.</p>
</li>
<li><p><strong>Worker nodes (data plane):</strong> They run the actual applications inside the containers.</p>
</li>
</ul>
<p>If you're new to Kubernetes or want to brush up, check out the free course <a target="_blank" href="https://training.linuxfoundation.org/training/introduction-to-kubernetes/?lid=axmt8lvbjbl8"><strong>Introduction to Kubernetes (LFS158)</strong></a> from the Linux Foundation.</p>
<h2 id="heading-what-is-amazon-elastic-kubernetes-service">What is Amazon Elastic Kubernetes Service?</h2>
<p>Amazon Elastic Kubernetes Service (EKS) is a managed service that enables easy Kubernetes deployment on AWS, eliminating the need to set up and maintain your own Kubernetes control plane node.</p>
<p>AWS EKS takes care of the heavy lifting by managing the control plane, handling upgrades, and installing core components, such as the container runtime and essential Kubernetes processes. It also offers built-in tools for scaling, high availability, and backup.</p>
<p>With EKS, you or your team can focus on building and running applications, while AWS handles the underlying infrastructure.</p>
<h2 id="heading-why-use-amazon-eks-for-kubernetes"><strong>Why Use Amazon EKS for Kubernetes?</strong></h2>
<p>Here are some key benefits of using AWS EKS:</p>
<ul>
<li><p>EKS handles upgrades, patching, and high availability for you, giving you a fully managed control plane with minimal manual effort.</p>
</li>
<li><p>You can easily scale your applications, and the infrastructure grows as your needs evolve.</p>
</li>
<li><p>It has built-in support for IAM roles, private networking, and encryption.</p>
</li>
<li><p>AWS EKS runs on highly available infrastructure across multiple AWS Availability Zones, making your application available globally.</p>
</li>
<li><p>With Amazon EKS, you get the power of Kubernetes without managing the underlying setup. So you can stay focused on building and running your apps.</p>
</li>
</ul>
<h2 id="heading-how-to-create-a-kubernetes-cluster-using-aws"><strong>How to Create a Kubernetes Cluster Using AWS</strong></h2>
<p>Now let’s walk through the process of getting a Kubernetes cluster up and running.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754818871609/8b0f622a-af82-4a29-bb22-fbdb1a6279bb.png" alt="lets get started" class="image--center mx-auto" width="225" height="225" loading="lazy"></p>
<h3 id="heading-step-1-how-to-install-the-tools-needed-to-create-a-cluster"><strong>Step 1: How to Install the Tools Needed to Create a Cluster</strong></h3>
<p>The easiest and most developer-friendly way to spin up an Elastic Kubernetes Service that you can use at the production level is by using <strong>eksctl</strong>. It takes care of the manual setup and automatically provisions the necessary AWS resources.</p>
<p>Before we begin, we need to install two essential tools:</p>
<ul>
<li><p><strong>eksctl</strong> – This is used to create and manage your EKS cluster.</p>
</li>
<li><p><strong>kubectl</strong> – This allows you to interact with your cluster, deploy apps, and manage Kubernetes resources.</p>
</li>
</ul>
<p>These tools will make it easy to set up your Kubernetes cluster and work with it directly from your terminal.</p>
<h4 id="heading-how-to-install-eksctl">How to Install eksctl</h4>
<p>Open your browser and go to the official <a target="_blank" href="https://eksctl.io/">eksctl</a> documentation. Scroll down to the <strong>Installation</strong> section.</p>
<p>Scroll to the <strong>Unix</strong> instructions if you're using Ubuntu or a similar system. Then copy the installation command and paste it into your terminal.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754819104540/48310ddc-89fb-49b9-990b-ca425ac81e55.gif" alt="Installing eksctl tool" class="image--center mx-auto" width="1920" height="971" loading="lazy"></p>
<p>Once it’s done, run <code>eksctl version</code> to confirm that the installation was successful.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754819269922/69d18189-f3ea-421b-9666-e37c43d7c077.gif" alt="checking the version" class="image--center mx-auto" width="1920" height="1078" loading="lazy"></p>
<h4 id="heading-how-to-install-kubectl">How to Install kubectl</h4>
<p>The next step is to install <a target="_blank" href="https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/">kubectl</a>. You can find the installation instructions in the official Kubernetes documentation, which provides steps based on your operating system.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754819717619/028418cb-424a-4514-a7a7-dfd17c2c03ce.gif" alt="Installing kubectl" class="image--center mx-auto" width="1920" height="971" loading="lazy"></p>
<h3 id="heading-step-2-how-to-create-the-elastic-kubernetes-service-eks-cluster"><strong>Step 2: How to Create the Elastic Kubernetes Service (EKS) Cluster</strong></h3>
<p>Now that you've installed the tools needed to create and interact with a Kubernetes cluster on AWS, it's time to launch the cluster.</p>
<p>To get started, open your terminal and run the following command:</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Create an EKS cluster named "k8s-example" in eu-west-2 (London)</span>
eksctl create cluster --name k8s-example --region eu-west-2
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754820013644/a763f4f1-4b5f-47c2-9c09-3148cb77f579.gif" alt="Creating a terminal in your cluster" class="image--center mx-auto" width="1920" height="1078" loading="lazy"></p>
<p>One great thing about using AWS EKS is that once your Kubernetes cluster is created, it automatically updates your <code>~/.kube/config</code> file. This means you can start interacting with your cluster right away, using <code>kubectl</code> – no extra setup needed.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754825286662/7b7f68a9-72c1-4306-bc09-a0d5c528b900.png" alt="Cluster ready on AWS" width="1437" height="124" loading="lazy"></p>
<p>After running the command (as shown in the GIF above), your Kubernetes cluster is successfully created.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754825194425/a6c611d4-837f-4106-955f-99bdcbb9cf5d.gif" alt="Kubernetes cluster created" width="1920" height="971" loading="lazy"></p>
<p>Head over to the AWS console, and you’ll see your new cluster listed with a status of <strong>Active</strong>.</p>
<p>With your cluster up and running, it’s time to test the connection. You can do this by running a few <code>kubectl</code> commands in your terminal to list the nodes, pods and namespaces in your cluster.</p>
<p><strong>To test the connection:</strong></p>
<pre><code class="lang-bash">kubectl get nodes
</code></pre>
<p>This command lists all the nodes in your cluster.</p>
<pre><code class="lang-bash">kubectl get pods
</code></pre>
<p>This command lists all the pods currently running.</p>
<pre><code class="lang-bash">kubectl get namespaces
</code></pre>
<p>This command lists all the namespaces currently running.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754825006032/4d2e72ff-8eb9-48be-bd90-efffbb840241.png" alt="testing the cluster" width="1226" height="379" loading="lazy"></p>
<p>If each command returns a list of resources, congratulations! Your connection to the Kubernetes cluster is successful.</p>
<h3 id="heading-step-3-how-to-create-kubernetes-manifests"><strong>Step 3: How to Create Kubernetes Manifests</strong></h3>
<p>Let’s define the application using a YAML file. In this file, you’ll create two key resources: a <strong>Deployment</strong> and a <strong>Service</strong>.</p>
<ul>
<li><p>The <strong>Deployment</strong> ensures your application runs reliably by specifying how many replicas to run, which container image to use, and how to manage updates.</p>
</li>
<li><p>The <strong>Service</strong> makes your application accessible — both within the Kubernetes cluster and, if needed, from the internet, even if the underlying pods change or restart.</p>
</li>
</ul>
<p>Together, these resources orchestrate your application so it can run consistently in different environments and be accessed by others.</p>
<pre><code class="lang-yaml"><span class="hljs-comment">#deployment-example.yaml</span>

<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">apps/v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Deployment</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">amazon-deployment</span>
  <span class="hljs-attr">namespace:</span> <span class="hljs-string">default</span>
  <span class="hljs-attr">labels:</span>
    <span class="hljs-attr">app:</span> <span class="hljs-string">amazon-app</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">replicas:</span> <span class="hljs-number">5</span>
  <span class="hljs-attr">selector:</span>
    <span class="hljs-attr">matchLabels:</span>
      <span class="hljs-attr">app:</span> <span class="hljs-string">amazon-app</span>
      <span class="hljs-attr">tier:</span> <span class="hljs-string">frontend</span>
      <span class="hljs-attr">version:</span> <span class="hljs-number">1.0</span><span class="hljs-number">.0</span>
  <span class="hljs-attr">template:</span>
    <span class="hljs-attr">metadata:</span>
      <span class="hljs-attr">labels:</span>
        <span class="hljs-attr">app:</span> <span class="hljs-string">amazon-app</span>
        <span class="hljs-attr">tier:</span> <span class="hljs-string">frontend</span>
        <span class="hljs-attr">version:</span> <span class="hljs-number">1.0</span><span class="hljs-number">.0</span>
    <span class="hljs-attr">spec:</span>
      <span class="hljs-attr">containers:</span>
        <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">amazon-container</span>
          <span class="hljs-attr">image:</span> <span class="hljs-string">ooghenekaro/amazon:2</span>
          <span class="hljs-attr">ports:</span>
            <span class="hljs-bullet">-</span> <span class="hljs-attr">containerPort:</span> <span class="hljs-number">3000</span>
<span class="hljs-meta">---</span>
<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Service</span>
<span class="hljs-attr">metadata:</span>
  <span class="hljs-attr">name:</span> <span class="hljs-string">amazon-service</span>
  <span class="hljs-attr">labels:</span>
    <span class="hljs-attr">app:</span> <span class="hljs-string">amazon-app</span>
<span class="hljs-attr">spec:</span>
  <span class="hljs-attr">type:</span> <span class="hljs-string">LoadBalancer</span>
  <span class="hljs-attr">ports:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">port:</span> <span class="hljs-number">80</span>
      <span class="hljs-attr">targetPort:</span> <span class="hljs-number">3000</span>
  <span class="hljs-attr">selector:</span>
    <span class="hljs-attr">app:</span> <span class="hljs-string">amazon-app</span>
</code></pre>
<p>The service uses a <strong>LoadBalancer type,</strong> which tells AWS to provision an <strong>Elastic Load Balancer</strong> (ELB) and route traffic to the pods.</p>
<h3 id="heading-step-4-how-to-deploy-the-app-to-eks"><strong>Step 4: How to Deploy the App to EKS</strong></h3>
<p>Now that your YAML file is defined and the Kubernetes cluster on AWS EKS is ready, it’s time to deploy your application. </p>
<p>To do this, run the following command in your terminal to apply the configuration defined in your manifest file: </p>
<pre><code class="lang-bash">kubectl apply -f deployment-example.yaml
</code></pre>
<p>This command tells Kubernetes to create the necessary pods and services based on what’s specified in the manifest file.</p>
<p>Next, you can check the status of your pods and services:</p>
<pre><code class="lang-bash">kubectl get pods
kubectl get svc or service
kubectl get all
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754824866347/8b48e580-d25f-4965-9c29-3609778365f0.png" alt="checking to see if our application is deployed properly" width="1920" height="1078" loading="lazy"></p>
<h3 id="heading-step-5-how-to-access-your-application"><strong>Step 5: How to Access Your Application</strong></h3>
<p>To view your application in the browser, run the following command to list your services:</p>
<pre><code class="lang-yaml"><span class="hljs-string">kubectl</span> <span class="hljs-string">get</span> <span class="hljs-string">svc</span>
</code></pre>
<p>Look for the <strong>EXTERNAL-IP</strong> of your service.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754824764125/b78b8feb-e5da-4d3c-b467-6ccb88d00373.png" alt="Display of the External IP on the browser" width="1920" height="194" loading="lazy"></p>
<p>Copy the IP address and paste it into your browser. Your app should now be live!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754824488894/821522c0-186f-48fd-8c64-ed29a2ba4447.png" alt="live site" width="1716" height="908" loading="lazy"></p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>Deploying a Kubernetes app on AWS EKS may seem complex at first, but with tools like eksctl and kubectl, the process is surprisingly approachable.</p>
<p>Whether you're a developer experimenting with Kubernetes or a team looking to scale production workloads, EKS provides a strong, scalable foundation that supports your applications as they grow.</p>
<h2 id="heading-resources">Resources</h2>
<ul>
<li><p><a target="_blank" href="https://labs.play-with-k8s.com/">Play with Kubernetes</a></p>
</li>
<li><p><a target="_blank" href="https://www.docker.com/101-tutorial/">Docker 101 Tutorial</a></p>
</li>
<li><p><a target="_blank" href="https://dev.to/ijay/how-to-create-a-cicd-using-aws-elastic-beanstalk-15nh">How to Create a CI/CD Pipeline Using AWS Elastic Beanstalk</a></p>
</li>
</ul>
<p>Thanks for reading!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ The Best AWS Services to Deploy Front-End Applications in 2025 ]]>
                </title>
                <description>
                    <![CDATA[ As front-end development evolves, finding the right deployment service is more important than ever. Amazon Web Services (AWS), a cloud-based service, offers a number of helpful tools and platforms for hosting modern front-end applications. Although i... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/best-aws-services-for-frontend-deployment/</link>
                <guid isPermaLink="false">68363d68d27e47d637cc580b</guid>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Developer ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Frontend Development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ deployment ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ijeoma Igboagu ]]>
                </dc:creator>
                <pubDate>Tue, 27 May 2025 22:32:08 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1748382386996/10b7c32c-f456-4717-b37c-b1668565bede.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>As front-end development evolves, finding the right deployment service is more important than ever. Amazon Web Services (AWS), a cloud-based service, offers a number of helpful tools and platforms for hosting modern front-end applications. Although it may present challenges for beginners, AWS can help give companies an edge with its global reach.</p>
<p>In this article, I’ll break down the best AWS services for frontend deployment in 2025, covering their use cases and their pros and cons. Whether you’re launching a static website, a React/Vue application, or a complex web application, this article will help you find the most effective AWS solution for your needs.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-why-choose-aws-for-frontend-hosting">Why Choose AWS for Frontend Hosting?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-aws-services-for-frontend-hosting">AWS Services for Frontend Hosting</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-amazon-s3-simple-storage-service">Amazon S3 (Simple Storage Service)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-aws-elastic-beanstalk">AWS Elastic Beanstalk</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-amazon-ec2-elastic-compute-cloud">Amazon EC2 (Elastic Compute Cloud)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-aws-amplify">AWS Amplify</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-aws-lightsail">AWS LightSail</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-aws-app-runner">AWS App Runner</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-related-articles">Related Articles</a></p>
</li>
</ul>
<h2 id="heading-why-choose-aws-for-frontend-hosting">Why Choose AWS for Frontend Hosting?</h2>
<p>Before we explore the specific AWS services for frontend hosting, let’s first look at why developers and companies often choose AWS over more familiar platforms like <a target="_blank" href="https://www.netlify.com/">Netlify</a> or <a target="_blank" href="https://vercel.com/">Vercel</a>.</p>
<ul>
<li><p>AWS has data centers worldwide, reducing latency and ensuring high availability. This means that apps deployed using their services can be easily and quickly accessed anywhere in the world (as long as that region has a nearby data center).</p>
</li>
<li><p>Any provisioned AWS service has security features like encryption, IAM, and DDoS protection.</p>
</li>
<li><p>AWS automatically scales to handle high traffic spikes without downtime.</p>
</li>
<li><p>AWS is flexible – it supports frameworks like React, Vue, Angular, and Next.js.</p>
</li>
<li><p>AWS easily integrates with other AWS services like databases (DynamoDB, RDS), APIs (API Gateway), and authentication (Cognito).</p>
</li>
</ul>
<h2 id="heading-aws-services-for-frontend-hosting">AWS Services for Frontend Hosting</h2>
<h3 id="heading-amazon-s3-simple-storage-service"><strong>Amazon S3 (Simple Storage Service)</strong></h3>
<p>Amazon S3 is a storage service from AWS mainly used to store files like HTML, CSS, JavaScript, Images, and Videos. These files make up static websites – that is, websites that don’t change based on user actions.</p>
<p>Many developers use S3 to host their static websites because it’s reliable, it works well, and it doesn’t cost much. You just upload your files to an S3 bucket, make them public, and your website is live. You can also connect a custom domain and add extra features like faster loading through a CDN (like CloudFront).</p>
<p><strong>Use Case:</strong><br>AWS S3 is perfect for hosting static websites and storing media files, such as portfolio sites, blogs, documentation pages, or any site that doesn't require a server to run backend code.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746277600652/c2a29581-edd7-478e-8993-9bf1d951aab8.png" alt="c2a29581-edd7-478e-8993-9bf1d951aab8" class="image--center mx-auto" width="1767" height="343" loading="lazy"></p>
<p><strong>Pros:</strong></p>
<ul>
<li><p>Easy to use and affordable for most projects.</p>
</li>
<li><p>Keeps your files available almost all the time.</p>
</li>
<li><p>Your data is stored safely and can be backed up automatically.</p>
</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li>It doesn’t support backend features like running code, handling forms, or connecting to databases.</li>
</ul>
<p>To help you get started using S3 for hosting, here’s an article that explains <a target="_blank" href="https://www.freecodecamp.org/news/host-a-static-website-on-aws-s3-and-cloudfront/">how to host a static website using AWS S3 and Cloudfront</a>.</p>
<h3 id="heading-aws-elastic-beanstalk"><strong>AWS Elastic Beanstalk</strong></h3>
<p>AWS Elastic Beanstalk is a service that helps you quickly deploy and manage web applications without needing to handle the underlying infrastructure. While it’s often used for backend services, it also works well for frontend apps that need server-side features.</p>
<p><strong>Use Case:</strong><br>AWS Elastic Beanstalk is ideal for hosting full-stack applications, especially those built with server-side frameworks like Next.js or Nuxt.js. It handles both the frontend and backend in one environment.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746279088455/a417bf0a-8cb6-4d1e-bddb-33a470e082f9.png" alt="Using AWS Elastic BeanStalk to create a full-stack application" class="image--center mx-auto" width="1891" height="413" loading="lazy"></p>
<p><strong>Pros:</strong></p>
<ul>
<li><p>Automatically scales your app based on traffic</p>
</li>
<li><p>Includes load balancing to manage high traffic smoothly</p>
</li>
<li><p>Works well with other AWS tools like RDS for databases and CloudWatch for monitoring</p>
</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><p>More complex to set up compared to simpler services like Amplify or S3</p>
</li>
<li><p>Not the best choice for static websites that don’t require server-side logic</p>
</li>
</ul>
<p>To better understand how it works, I used AWS Elastic Beanstalk to set up a CI/CD pipeline. You can read this article: <a target="_blank" href="https://dev.to/ijay/how-to-create-a-cicd-using-aws-elastic-beanstalk-15nh">How to Create a CI/CD Using AWS Elastic BeanStalk</a>.</p>
<h3 id="heading-amazon-ec2-elastic-compute-cloud"><strong>Amazon EC2 (Elastic Compute Cloud)</strong></h3>
<p>Amazon EC2 lets you run your virtual server in the cloud. You can install any software, upload a website, open or close ports, and have full control over how your application runs. It's similar to having your physical computer, but it's hosted online and it’s more flexible.</p>
<p><strong>Use Case:</strong><br>AWS EC2 is great for developers or teams who need full control over their hosting setup. It's useful for projects where the frontend and backend are closely connected, or where you need to run custom services, tools, or configurations that simpler platforms can’t handle.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746280458269/6acafa6a-70f5-4a31-807c-de3cc3c09dfa.png" alt="using the EC2 for running your web application" class="image--center mx-auto" width="1542" height="394" loading="lazy"></p>
<p><strong>Pros:</strong></p>
<ul>
<li><p>Full control over the server environment.</p>
</li>
<li><p>Supports custom setups, tools, and applications.</p>
</li>
<li><p>It is a flexible way to run any application on it.</p>
</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><p>Takes time to learn and manage.</p>
</li>
<li><p>You’re responsible for handling updates, scaling, and security.</p>
</li>
</ul>
<p>To help you understand how it works and how to connect it to your code editor (IDE), here's an article that walks you through the process: <a target="_blank" href="https://www.freecodecamp.org/news/how-to-connect-your-aws-ec2-instance-to-vs-code/">How to Connect Your AWS EC2 Instance to VS Code</a>.</p>
<h3 id="heading-aws-amplify"><strong>AWS Amplify</strong></h3>
<p>AWS Amplify is a platform that makes it easy to build and host frontend and mobile applications. It’s designed for developers working with frameworks like React, Vue, Angular, or Next.js.</p>
<p>Amplify handles things like hosting, authentication, APIs, and data storage. It supports Git-based CI/CD, which means your app can automatically update every time you push code. It comes with built-in support for popular tools like Cognito (for login systems), AppSync (for APIs), and DynamoDB (for databases). You can even create different environments based on your Git branches.</p>
<p><strong>Use Case:</strong><br>AWS Amplify is ideal for teams or solo developers building full-stack apps with modern frontend tools, especially when you want built-in features like user authentication, cloud APIs, and easy deployment.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746282073570/9392f80c-aede-400a-a8f8-207167f44545.png" alt="using amplify for frontend or full-stack application" class="image--center mx-auto" width="1811" height="797" loading="lazy"></p>
<p><strong>Pros:</strong></p>
<ul>
<li><p>Simple full-stack hosting – frontend and backend in one place.</p>
</li>
<li><p>Fast setup with automatic scaling.</p>
</li>
<li><p>Comes with HTTPS, custom domain setup, and performance monitoring.</p>
</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><p>More expensive than simpler solutions like S3 for basic static sites.</p>
</li>
<li><p>Less flexibility for developers who want full control over infrastructure.</p>
</li>
</ul>
<p>Here is a simple guide for building with AWS Amplify. I hope it helps you understand it better: <a target="_blank" href="https://dev.to/ijay/how-can-aws-amplify-improve-your-development-process-2gj5">How Can AWS Amplify Improve Your Development Process?</a></p>
<p>And here’s an in-depth guide that walks you through <a target="_blank" href="https://www.freecodecamp.org/news/ultimate-guide-to-aws-amplify-and-reacxt/">building a full-stack app with AWS Amplify and React</a>.</p>
<h3 id="heading-aws-lightsail"><strong>AWS LightSail</strong></h3>
<p>AWS LightSail is a beginner-friendly cloud hosting service that offers a quick and easy way to launch small applications. It works like a simpler version of EC2 and comes with pre-configured environments for Node.js, LAMP (Linux, Apache, Mysql, PHP), and WordPress. This means that you don’t have to spend time setting everything up from scratch.</p>
<p><strong>Use Case:</strong><br>It is perfect for freelancers, small businesses, or anyone who wants to host a simple website or app, such as a blog, a small web app, or an online portfolio.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746348715984/c013a2de-b004-4c44-a5c6-23ddb9226962.png" alt="using AWS light sail for your application" class="image--center mx-auto" width="290" height="512" loading="lazy"></p>
<p><strong>Pros:</strong></p>
<ul>
<li><p>More affordable than EC2.</p>
</li>
<li><p>Easy to set up and manage.</p>
</li>
<li><p>Comes with ready-to-use application stacks.</p>
</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><p>Not ideal for large or fast-growing projects.</p>
</li>
<li><p>Has fewer customisation and scaling options compared to EC2 or Amplify.</p>
</li>
</ul>
<p>For a fun, project-based tutorial, check out this guide that teaches you <a target="_blank" href="https://www.freecodecamp.org/news/how-do-deploy-docker-containers-to-the-cloud-with-aws-lightsail/">how to use AWS LightSail to deploy Docker containers to the cloud</a>.</p>
<h3 id="heading-aws-app-runner"><strong>AWS App Runner</strong></h3>
<p>AWS App Runner is a service that helps you run web applications without setting up or managing any servers. You just connect your source code or a container image, and App Runner handles everything. It's a quick way to get your frontend or backend app online, especially if your app needs server-side processing.</p>
<p><strong>Use Case:</strong><br>App Runner is a good choice for frontend applications built with server-side rendering (like Next.js), full-stack apps, or APIs. It’s also helpful if your app is containerised and you want it to scale automatically based on traffic.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746351485218/748d06a5-b4dd-493d-b809-e72af84d0f5c.png" alt="Using AWS App Runner" class="image--center mx-auto" width="1628" height="360" loading="lazy"></p>
<p><strong>Pros:</strong></p>
<ul>
<li><p>No server setup or management.</p>
</li>
<li><p>Automatically scales your app as needed.</p>
</li>
<li><p>Easy to connect with GitHub or Amazon ECR.</p>
</li>
<li><p>HTTPS and custom domain support included.</p>
</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><p>It’s not the best choice for very simple websites that only show static content like HTML, CSS, and JavaScript files. Other services like S3 are easier and cheaper for that kind of site.</p>
</li>
<li><p>It doesn’t give you as much control as EC2 or ECS. For example, you can’t fully customise the server environment or how things run behind the scenes. So, it’s great for simple or standard setups, but not ideal if you need to fine-tune advanced settings.</p>
</li>
</ul>
<p>If you want to learn more about deploying apps with AppRunner, here’s a tutorial about <a target="_blank" href="https://www.freecodecamp.org/news/kotlin-aws-app-runner/">deploying a Kotlin microservice to AppRunner</a> that you can check out.</p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>AWS offers a variety of powerful tools for hosting frontend applications, from simple static site hosting on S3 to full-stack managed deployments with Amplify. Whether you’re a solo developer launching your portfolio or a team deploying a production web app, AWS has the flexibility and scalability to support your frontend needs.</p>
<p>By understanding each service’s purpose and use case, you can confidently pick the best fit for your project and scale as needed. Start small, experiment, and grow with AWS.</p>
<p>If you found this article helpful, please share it with others who may find it interesting.</p>
<p>Stay updated with my projects by following me on <a target="_blank" href="https://twitter.com/ijaydimples">Twitter</a>, <a target="_blank" href="https://www.linkedin.com/in/ijeoma-igboagu/">LinkedIn</a> and <a target="_blank" href="https://github.com/ijayhub">GitHub</a>.</p>
<h3 id="heading-related-articles">Related Articles</h3>
<ul>
<li><p><a target="_blank" href="https://www.freecodecamp.org/news/how-to-deploy-websites-and-applications/">How to Deploy Your Websites and Apps – User-Friendly Deployment Strategies</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/news/backend-as-a-service-beginners-guide/">What is Backend as a Service (BaaS)? A Beginner's Guide</a></p>
</li>
<li><p><a target="_blank" href="https://dev.to/ijay/how-to-use-aws-s3-console-for-website-deployment-2mhh">How to Use AWS S3 Console for Website Deployment</a></p>
</li>
<li><p><a target="_blank" href="https://dev.to/ijay/how-to-secure-aws-infrastructure-1k8h">How to Secure AWS Infrastructure</a></p>
</li>
</ul>
<p>Thank you for reading.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Connect Your AWS EC2 Instance to VS Code ]]>
                </title>
                <description>
                    <![CDATA[ As a DevOps engineer, it is crucial to master at least one cloud provider. Cloud services simplify storage, data migration, and CI/CD workflows and help make these tasks easier and more efficient. If you need a basic introduction to cloud computing, ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-connect-your-aws-ec2-instance-to-vs-code/</link>
                <guid isPermaLink="false">67e2ec52cd467794ee79d63e</guid>
                
                    <category>
                        <![CDATA[ ec2 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ software development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ssh ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cloud ]]>
                    </category>
                
                    <category>
                        <![CDATA[ server ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ijeoma Igboagu ]]>
                </dc:creator>
                <pubDate>Tue, 25 Mar 2025 17:48:02 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1742397603245/c1ca0496-dbab-4570-8b6b-cb4bac5f72c1.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>As a DevOps engineer, it is crucial to master at least one cloud provider. Cloud services simplify storage, data migration, and CI/CD workflows and help make these tasks easier and more efficient.</p>
<p>If you need a basic introduction to cloud computing, here’s a beginner-friendly tutorial for you: <a target="_blank" href="https://www.freecodecamp.org/news/cloud-computing-guide-for-beginners/"><strong>What is Cloud Computing? A Guide for Beginners.</strong></a></p>
<p>In this guide, I’ll show you how to create an AWS EC2 instance. This is one of AWS’s top services for building applications. By the end of this guide, you'll know how to launch an AWS EC2 instance and connect it to VS Code.</p>
<h2 id="heading-table-of-contents"><strong>Table of Contents</strong></h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-prerequisites">Prerequisites</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-what-is-an-aws-ec2-instance">What is an AWS EC2 Instance?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-why-connect-your-aws-ec2-instance-to-vs-code">Why Connect Your AWS EC2 Instance to VS Code?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-launch-and-connect-your-aws-ec2-instance-to-vs-code">How to Launch and Connect Your AWS EC2 Instance to VS Code</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-step-1-create-an-aws-ec2-instance">Step 1: Create an AWS EC2 Instance</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-2-connect-the-aws-ec2-instance-to-your-code-editor">Step 2: Connect the AWS EC2 Instance to Your Code Editor</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-3-install-the-programming-language">Step 3: Install the Programming Language</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-open-a-remote-window">Step 4: Open a Remote Window</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-5-access-your-project-folder">Step 5: Access Your Project Folder</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ul>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>Before you start, make sure you have:</p>
<ul>
<li><p>An AWS account. If you do not have one, <a target="_blank" href="https://aws.amazon.com/free/?gclid=Cj0KCQiAvvO7BhC-ARIsAGFyToVguvjmSCa99VkB7XsHepginSELSYCCYnVzZXeZSKFpRRTC8DKyh98aAkZkEALw_wcB&amp;trk=2d3e6bee-b4a1-42e0-8600-6f2bb4fcb10c&amp;sc_channel=ps&amp;ef_id=Cj0KCQiAvvO7BhC-ARIsAGFyToVguvjmSCa99VkB7XsHepginSELSYCCYnVzZXeZSKFpRRTC8DKyh98aAkZkEALw_wcB:G:s&amp;s_kwcid=AL!4422!3!645125273261!e!!g!!aws!19574556887!145779846712&amp;all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc&amp;awsf.Free%20Tier%20Types=*all&amp;awsf.Free%20Tier%20Categories=*all">sign up here</a>.</p>
</li>
<li><p>A GitHub repository with your source code. If you don’t have a GitHub account, <a target="_blank" href="https://github.com/">sign up here</a>.</p>
</li>
<li><p>Basic knowledge of web development and version control.</p>
</li>
<li><p>A code editor. For this tutorial, I’m using VS Code.</p>
</li>
</ul>
<p>Let’s jump right in!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735997217784/fdb3b399-7a07-4cf2-8577-10859bf5542d.gif" alt="fdb3b399-7a07-4cf2-8577-10859bf5542d" class="image--center mx-auto" width="220" height="220" loading="lazy"></p>
<h2 id="heading-what-is-an-aws-ec2-instance">What is an AWS EC2 Instance?</h2>
<p>AWS EC2 (Elastic Compute Cloud) allows you to run virtual machines in the cloud. These computers allow you to run your applications without needing physical hardware.</p>
<p>There are a number of things you can you do with AWS EC2, such as hosting websites or apps, running big data or machine-learning tasks, creating testing environments, and handling tasks that need flexible, scalable computing power.</p>
<h2 id="heading-why-connect-your-aws-ec2-instance-to-vs-code">Why Connect Your AWS EC2 Instance to VS Code?</h2>
<p>Connecting your AWS EC2 instance to VS Code is helpful for several reasons. Before we start the setup process, it’s important to learn why it’s beneficial.</p>
<ol>
<li><p>Using VS Code provides a familiar and efficient development space. It feels like coding on your own machine.</p>
</li>
<li><p>You don’t have to log into your AWS EC2 instance each time. You can edit files, run commands, and debug code from a distance.</p>
</li>
<li><p>You can streamline your workflow with built-in terminal access and extensions. This way, you won't have to switch between SSH clients all the time.</p>
</li>
<li><p>You can push changes to GitHub. This makes working together and deploying much smoother.</p>
</li>
<li><p>VS Code works well with Java, Node.js, and Python. It supports many languages and frameworks, so it's great for cloud development.</p>
</li>
</ol>
<p>Now that you understand the benefits, let’s move on to setting up the connection.</p>
<h2 id="heading-how-to-launch-and-connect-your-aws-ec2-instance-to-vs-code"><strong>How to Launch and Connect Your AWS EC2 Instance to VS Code</strong></h2>
<p>To launch an EC2 instance on AWS, just follow these steps:</p>
<h3 id="heading-step-1-create-an-aws-ec2-instance"><strong>Step 1: Create an AWS EC2 Instance</strong></h3>
<p>First, log into your AWS account. Then, use the search bar to find EC2 and select it.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736016609765/f784db8e-46cc-4e03-abc0-7bdea9b1c668.png" alt="Searching for EC2 on AWS Console" class="image--center mx-auto" width="1920" height="970" loading="lazy"></p>
<p>Click EC2 and follow the on-screen instructions to create a new instance.</p>
<ol>
<li><p><strong>Choose an AMI (Amazon Machine Image):</strong> This is a pre-configured template that includes an operating system and may come with additional software.</p>
</li>
<li><p><strong>Select an instance type:</strong> Pick the right size for your needs. For example, <code>t2.micro</code> is a good option for beginners and small workloads.</p>
</li>
<li><p><strong>Configure Your EC2 Instance:</strong> Set up networking, storage, security groups, and other options based on your requirements.</p>
</li>
<li><p><strong>Launch Your Instance:</strong> Start your virtual server and access it remotely to begin using it.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736174305817/e8d9d8dd-f09d-4bca-a838-42ee55607fa5.gif" alt="creating an EC2 instance" class="image--center mx-auto" width="1920" height="971" loading="lazy"></p>
<p>Launched instance running:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736174700999/b729de98-bd8f-496f-9486-3079d87fb4de.png" alt="Launched Instance" class="image--center mx-auto" width="1553" height="209" loading="lazy"></p>
<p>So what’s happening in Step 1?</p>
<p>By launching an AWS EC2 instance, you are setting up a remote server in the cloud. AWS offers different AMIs that serve as pre-configured environments.</p>
<h3 id="heading-step-2-connect-the-aws-ec2-instance-to-your-code-editor">Step 2: <strong>Connect the AWS EC2 Instance to Your Code Editor</strong></h3>
<p>To connect your EC2 instance created in AWS to your VS Code, you need SSH.</p>
<h4 id="heading-what-is-ssh">What is SSH?</h4>
<p>SSH (Secure Shell) is a secure way to connect and communicate with other devices. It keeps your connection safe. This is important when you access servers or repositories. In Git, you can use SSH instead of HTTPS to clone repositories with a secure connection.</p>
<h4 id="heading-why-is-ssh-important-here">Why is SSH important here?</h4>
<p>With SSH, you can link your local code editor (like VS Code) to your AWS EC2 instance. This allows you to work on files stored on the EC2 instance directly from your editor as if on your local computer.</p>
<p><strong>To connect your AWS EC2 instance to your local editor using SSH, follow these steps:</strong></p>
<ul>
<li><p>Open your terminal.</p>
</li>
<li><p>Go to the folder where your <code>.pem</code> key file is. The key file (.pem) downloads automatically when you create your EC2 instance (usually in the Downloads folder).</p>
</li>
<li><p>Update the file permissions to keep your key secure and ensure proper authentication.</p>
</li>
</ul>
<p>For Linux users, use this command to update the file permissions:</p>
<pre><code class="lang-bash">chmod 400 codebuild-keypair.pem
</code></pre>
<p>For Windows users, first you’ll need to find the username of your laptop, as you’ll need it to update the file permissions.</p>
<p>To do this, open your terminal and type:</p>
<pre><code class="lang-powershell">whoami
</code></pre>
<p>This will display your current username.</p>
<p>Once you have your username, use the following command to update the file permissions:</p>
<pre><code class="lang-powershell">icacls <span class="hljs-string">"codebuild-keypair.pem"</span> /reset
icacls <span class="hljs-string">"codbuild-keypair.pem"</span> /grant:<span class="hljs-built_in">r</span> <span class="hljs-string">"%USERNAME%:R"</span>
icacls <span class="hljs-string">"codebuld-keypair.pem"</span> /inheritance:<span class="hljs-built_in">r</span>
</code></pre>
<p>Here's what I mean: My username is <strong>ijeon</strong>, so you should replace it with <strong>your laptop's username</strong> and <strong>own</strong> key, which ends with <code>.pem</code> extension.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736021541861/048a9411-2348-48dc-8a6e-04d51dbd347d.png" alt="pasting the command on the terminal" class="image--center mx-auto" width="1096" height="102" loading="lazy"></p>
<p>Running this command above updates the file permissions. So with this, you can work with your remote server.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736021649692/118c75cf-30b4-474c-b726-142c2b4326e9.png" alt="the output of the command pasted" width="722" height="153" loading="lazy"></p>
<p>Now that you have set the correct file permissions, you can use the SSH command along with the IPv4 address to connect to our EC2 instance. Type the following command:</p>
<pre><code class="lang-powershell">ssh <span class="hljs-literal">-i</span> [<span class="hljs-type">PATH</span> <span class="hljs-type">TO</span> <span class="hljs-type">YOUR</span> <span class="hljs-type">.PEM</span> <span class="hljs-type">FILE</span>] ec2<span class="hljs-literal">-user</span><span class="hljs-selector-tag">@</span>[<span class="hljs-type">YOUR</span> <span class="hljs-type">PUBLIC</span> <span class="hljs-type">IPV4</span> <span class="hljs-type">DNS</span>]
</code></pre>
<p>Example:</p>
<pre><code class="lang-powershell">ssh <span class="hljs-literal">-i</span> <span class="hljs-string">"C:\Users\ijeon\OneDrive\Desktop\devops-series-nextwork\codebuild-keypair.pem"</span> ec2<span class="hljs-literal">-user</span>@ec2<span class="hljs-literal">-35</span><span class="hljs-literal">-178</span><span class="hljs-literal">-142</span><span class="hljs-literal">-201</span>.eu<span class="hljs-literal">-west</span><span class="hljs-literal">-2</span>.compute.amazonaws.
</code></pre>
<p>Breaking it down:</p>
<ol>
<li><p><code>ssh</code>: This starts a secure remote connection.</p>
</li>
<li><p><code>-i "C:\Users\ijeon\...\codebuild-keypair.pem"</code>: This tells SSH to use the <code>.pem</code> key file for secure access.</p>
</li>
<li><p><a target="_blank" href="mailto:ec2-user@ec2-35-178-142-201.eu-west-2.compute.amazonaws.com"><code>ec2-user@ec2-35-178-142-201.eu-west-2.compute.amazonaws.com</code></a>:</p>
<ul>
<li><p><code>ec2-user</code> is the default username for EC2 instances.</p>
</li>
<li><p><code>@ec2-35-178-142-201...</code> is the public address of your EC2 instance.</p>
</li>
</ul>
</li>
</ol>
<p>This command logs you into your EC2 instance remotely from your computer. It then uses the key (<code>.pem</code> file) instead of a password for security. It also lets you control the EC2 instance from your terminal as if you were using it directly.</p>
<p>If everything is set up correctly, a “success message” will appear. This confirms that you've logged in and can access the remote server.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1742153348953/a68f32fc-7578-4904-9b2e-e63a353e84a0.gif" alt="connecting via ssh" class="image--center mx-auto" width="1920" height="1079" loading="lazy"></p>
<h3 id="heading-step-3-install-the-programming-language"><strong>Step 3: Install the Programming Language</strong></h3>
<p>Now that you’ve linked your instance to the editor, you can install the packages needed to build your web app. You can use any programming language you're comfortable with, but we’ll use Java for this tutorial. This will be a simple web application – we don’t need to go into advanced details.</p>
<h4 id="heading-1-install-java"><strong>1. Install Java</strong></h4>
<p>In your terminal, run the following commands to install <strong>Java</strong>:</p>
<pre><code class="lang-powershell">sudo dnf install <span class="hljs-literal">-y</span> java<span class="hljs-literal">-1</span>.<span class="hljs-number">8.0</span><span class="hljs-literal">-amazon</span><span class="hljs-literal">-corretto</span><span class="hljs-literal">-devel</span>

export JAVA_HOME=/usr/lib/jvm/java<span class="hljs-literal">-1</span>.<span class="hljs-number">8.0</span><span class="hljs-literal">-amazon</span><span class="hljs-literal">-corretto</span>.x86_64

export PATH=/usr/lib/jvm/java<span class="hljs-literal">-1</span>.<span class="hljs-number">8.0</span><span class="hljs-literal">-amazon</span><span class="hljs-literal">-corretto</span>.x86_64/jre/bin/:<span class="hljs-variable">$PATH</span>
</code></pre>
<p>This installs Java on your system. You also need Maven. It helps manage Java projects and create templates for web applications.</p>
<h4 id="heading-2-install-maven"><strong>2. Install Maven</strong></h4>
<p>Maven helps you organize Java projects. It also lets you create templates for web applications. Run these commands to install Maven:</p>
<pre><code class="lang-powershell"><span class="hljs-built_in">wget</span> https://archive.apache.org/dist/maven/maven<span class="hljs-literal">-3</span>/<span class="hljs-number">3.5</span>.<span class="hljs-number">2</span>/binaries/apache<span class="hljs-literal">-maven</span><span class="hljs-literal">-3</span>.<span class="hljs-number">5.2</span><span class="hljs-literal">-bin</span>.tar.gz

sudo tar <span class="hljs-literal">-xzf</span> apache<span class="hljs-literal">-maven</span><span class="hljs-literal">-3</span>.<span class="hljs-number">5.2</span><span class="hljs-literal">-bin</span>.tar.gz <span class="hljs-literal">-C</span> /opt

<span class="hljs-built_in">echo</span> <span class="hljs-string">"export PATH=/opt/apache-maven-3.5.2/bin:<span class="hljs-variable">$PATH</span>"</span> &gt;&gt; ~/.bashrc

source ~/.bashrc
</code></pre>
<p>To confirm Maven's correct installation, run this command:</p>
<pre><code class="lang-powershell">mvn <span class="hljs-literal">-v</span>
</code></pre>
<p>Also, run the following command to check whether you have Java installed:</p>
<pre><code class="lang-powershell">java <span class="hljs-literal">-version</span>
</code></pre>
<p>Now that you have installed Maven, you can use it to create a Java web app with the following command:</p>
<pre><code class="lang-powershell">mvn archetype:generate \
  <span class="hljs-literal">-DgroupId</span>=com.nextwork.app \
  <span class="hljs-literal">-DartifactId</span>=nextwork<span class="hljs-literal">-web</span><span class="hljs-literal">-project</span> \
  <span class="hljs-literal">-Dpackage</span>=com.nextwork.app \
  <span class="hljs-literal">-DarchetypeArtifactId</span>=maven<span class="hljs-literal">-archetype</span><span class="hljs-literal">-webapp</span> \
  <span class="hljs-literal">-DarchetypeVersion</span>=<span class="hljs-number">1.4</span> \
  <span class="hljs-literal">-DinteractiveMode</span>=false
</code></pre>
<p>Running the command above generates a template for your application. In the terminal, it should show a "Build Success" message. This means the setup worked.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1742122446716/7c51b3a2-6a8c-463d-817c-9630488a803d.png" alt="Installing the template" class="image--center mx-auto" width="1410" height="854" loading="lazy"></p>
<h3 id="heading-step-4-open-a-remote-window"><strong>Step 4:</strong> Open a Remote Window</h3>
<p>Now that you’ve installed the necessary packages and set up your app template, you need to open your IDE or code editor. This will let you access the folders on your remote server.</p>
<p>In your terminal, click the double arrow icon at the bottom left.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736073016500/cb3a4d44-3ae5-4ccb-9006-c592c0be30f7.png" alt="double arrow at the left" class="image--center mx-auto" width="155" height="119" loading="lazy"></p>
<p>When you click on it, it opens a modal window for you.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736073334686/a24d115c-9da3-4b46-80be-a75d73a189ab.gif" alt="connect to the host" class="image--center mx-auto" width="1920" height="1079" loading="lazy"></p>
<p>A window will appear. Click "Connect to Host," which will open another window.</p>
<p>Then choose "Add New SSH Host" to open the SSH connection terminal.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736073802080/45dbc209-0b4c-41a2-83eb-3fa05a8eff20.gif" alt="adding ssh host" class="image--center mx-auto" width="1920" height="1079" loading="lazy"></p>
<p>Input your SSH command to configure the host.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736078262849/b09d017e-cbd3-476e-9641-63dc41e34d83.png" alt="image of SSH connection command" class="image--center mx-auto" width="928" height="146" loading="lazy"></p>
<p>After pressing "Enter," a configuration file will open. In this file, ensure that the <code>.pem</code> file and the <code>IP4v DNS</code> addresses from your EC2 instance are correct.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736083806867/e158ee79-67d3-41c8-bb63-870caab0033b.png" alt="place to press for the configuration file" class="image--center mx-auto" width="890" height="207" loading="lazy"></p>
<p>Here’s a GIF view of the image above:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736083586490/7520a325-376d-42a8-905d-2e22770498de.gif" alt="a gif view of how to open your configuration file" class="image--center mx-auto" width="1920" height="1079" loading="lazy"></p>
<p>Here’s the configuration file:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736084278100/6e71324f-6b47-4a2a-b7a1-89c1be10c39b.png" alt="config file" class="image--center mx-auto" width="1348" height="349" loading="lazy"></p>
<p>Go back to your editor and click on that double arrow again. This will automatically open a new window.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736086002267/53e4edd8-afe2-4652-90ab-56bc90f80405.gif" alt="Re-opening a new window" class="image--center mx-auto" width="1920" height="1079" loading="lazy"></p>
<p>If your editor displays the IPv4 DNS address, your VS Code is successfully connected to the EC2 instance.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736086479299/e399f86c-e236-4efc-8d4d-a7055139d01e.png" alt="connection to the remote server" width="683" height="209" loading="lazy"></p>
<p>Now that you’re connected and a new window has opened, let’s access the folder stored in the cloud.</p>
<h3 id="heading-step-5-access-your-project-folder">Step 5: Access Your Project Folder</h3>
<p>In step 3, remember when you installed Maven? It created a template for your web app. Now, you’ll access the folder where you created this.</p>
<ol>
<li><p>Go to the Explorer panel in the window.</p>
</li>
<li><p>Click the <strong>“</strong>Open Folder<strong>”</strong> button.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736087503207/7fb21fcb-939e-4f17-83d2-93a6e0e3ee68.png" alt="access remote folder" class="image--center mx-auto" width="219" height="171" loading="lazy"></p>
<p>Clicking on this button opens a modal box for you to select your folder, which was created by the Maven template:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1742134089654/77104e69-4c7a-4b59-812d-423167079f24.gif" alt="accessing the folder" class="image--center mx-auto" width="1920" height="1079" loading="lazy"></p>
<p>To access the template file, click the “src” folder. This takes you to the <code>index.jsp</code> file.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1742135158716/4cfedc15-1c2e-4d60-b9f6-fe04c300dfa0.png" alt="template automatically created for you" width="1920" height="1080" loading="lazy"></p>
<p>With this template created, you can decide to tweak it and send it to your Git repository for storage.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Great job! You’ve set up an AWS EC2 instance, linked it to your code editor, and installed the tools needed for your web app. In this tutorial, we used Java, but you can also choose other languages like Node.js or Python.</p>
<p>If you found this article helpful, please share it with others who may find it interesting.</p>
<p>Stay updated with my projects by following me on <a target="_blank" href="https://twitter.com/ijaydimples">Twitter</a>, <a target="_blank" href="https://twitter.com/ijaydimples">LinkedIn</a> and <a target="_blank" href="https://github.com/ijayhub">GitHub</a>.</p>
<p>Thank you for reading.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ What is Backend as a Service (BaaS)? A Beginner's Guide ]]>
                </title>
                <description>
                    <![CDATA[ Building an authentication system can be complex, often requiring a server to store user data. Sometimes, you need a faster, easier solution. For those new to development or without technical expertise, managing servers, databases, and user logins ca... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/backend-as-a-service-beginners-guide/</link>
                <guid isPermaLink="false">67b30da662ec9a593dfeb4a7</guid>
                
                    <category>
                        <![CDATA[ backend ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Databases ]]>
                    </category>
                
                    <category>
                        <![CDATA[ authentication ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ijeoma Igboagu ]]>
                </dc:creator>
                <pubDate>Mon, 17 Feb 2025 10:21:26 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1739291731037/169ad924-9bcb-4af2-9281-fad2488a868d.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Building an authentication system can be complex, often requiring a server to store user data. Sometimes, you need a faster, easier solution.</p>
<p>For those new to development or without technical expertise, managing servers, databases, and user logins can be overwhelming. This is where Backend as a Service (BaaS) helps.</p>
<p>BaaS platforms provide ready-made backend solutions, making app development simpler. Whether you're a developer or someone with no coding experience, BaaS allows you to focus on your app’s features instead of handling backend complexities.</p>
<p>​​This article will explore BaaS, its features, pricing, and popular BaaS​ tools.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-what-is-backend-as-a-service-baas">​​​What is Backend as a Service (BaaS)?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-key-features-of-baas">Key Features of Baas</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-why-use-backend-as-a-service-baas">Why use Backend as a Service (BaaS)?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-when-to-use-backend-as-a-service-baas">When to Use Backend as a Service (BaaS)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-what-are-the-popular-backend-as-a-service-baas-tools">What are the Popular Backend as a Service (BaaS) Tools?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-get-started-with-baas-quick-example">How to Get Started with BaaS (Quick Example)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ul>
<h2 id="heading-what-is-backend-as-a-service-baas">​​​What is Backend as a Service (BaaS)?</h2>
<p>BaaS is a cloud platform that provides pre-built backend infrastructure and services. It eliminates the need for developers to manage servers, databases, and other backend tasks.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1739537937739/4ae3bb03-1196-4298-9299-a0a09c4bd41d.png" alt="Graphical interface of BaaS" width="810" height="583" loading="lazy"></p>
<p>​​<strong>Source:</strong> <a target="_blank" href="https://www.cloudflare.com/fr-fr/learning/serverless/glossary/backend-as-a-service-baas/">https://www.cloudflare.com</a></p>
<h2 id="heading-key-features-of-baas">​​Key Features of BaaS</h2>
<p>Here are some features of BaaS:</p>
<ul>
<li><p>BaaS makes it easy to create and manage user accounts and logins without much coding.</p>
</li>
<li><p>It lets you store and manage data, eliminating the need to set up a database from scratch.</p>
</li>
<li><p>BaaS comes with tools (APIs and SDKs) that help connect your application to the backend easily.</p>
</li>
<li><p>Many BaaS platforms let you see updates in real time, so your application can show live data to users.</p>
</li>
<li><p>BaaS offers space in the cloud to store files and images, making it easy to handle user uploads.</p>
</li>
<li><p>You don’t need to worry about managing servers—BaaS takes care of that for you, so you can focus on building your application.</p>
</li>
<li><p>Some BaaS platforms allow you to send notifications to users about updates or messages.</p>
</li>
<li><p>BaaS often provides tools to track user interactions, helping you understand what works and what doesn’t.</p>
</li>
<li><p>It also makes it easy to integrate with other services like payment systems and social media with minimal effort.</p>
</li>
<li><p>As your app grows, BaaS scales with it, handling more users and data seamlessly.</p>
</li>
</ul>
<h2 id="heading-why-use-backend-as-a-service-baas">Why use Backend as a Service (BaaS)?</h2>
<p>There are several key reasons why BaaS is an excellent choice for developers:</p>
<ul>
<li><p>Pre-built features reduce development time, allowing you to focus on design and functionality instead of backend issues.</p>
</li>
<li><p>With BaaS, you don’t have to worry about servers, scaling, or security updates—the provider takes care of it all.</p>
</li>
<li><p>Most BaaS platforms offer essential features like user authentication, data storage, and real-time updates, helping you build your app without starting from scratch.</p>
</li>
<li><p>As your application gets more users, BaaS can handle it! These services adjust to support more users and data, so you can focus on growing your app.</p>
</li>
<li><p>BaaS handles the infrastructure so you don’t need to spend time or money on the backend. This allows you to focus on design and creating user experiences that add value to your users.</p>
</li>
</ul>
<h2 id="heading-when-to-use-backend-as-a-service-baas">When to Use Backend as a Service (BaaS)</h2>
<p>BaaS is perfect for building an app in a short amount of time without managing the backend. Here are the scenarios when BaaS makes sense:</p>
<ul>
<li><p>BaaS handles your app’s backend, letting you focus on its features. <strong>For example,</strong> when building a to-do list app, BaaS makes it easy to manage user logins and task data without setting up servers from scratch.</p>
</li>
<li><p>For small teams or solo devs, BaaS handles the backend. You do not need extra resources.</p>
</li>
<li><p>If you're launching a startup, Baas lets you release a Minimum Viable Product (MVP) without delay. It helps you speed up development and cut costs. </p>
</li>
<li><p>If your app needs features like user authentication, data storage, or push notifications, BaaS provides them out of the box. For example, when building a social media app, BaaS simplifies user logins and file uploads, saving you from starting from scratch.</p>
</li>
<li><p>BaaS automatically scales to support more users, allowing you to focus on improving your app. For example, a small multiplayer game can start with a few players, and as it grows, BaaS will seamlessly handle thousands without extra backend effort.</p>
</li>
</ul>
<h2 id="heading-what-are-the-popular-backend-as-a-service-baas-tools">What are the Popular Backend as a Service (BaaS) Tools?</h2>
<p>If you're looking to explore BaaS, here are popular platforms you can use:</p>
<h3 id="heading-clerk"><strong>Clerk</strong></h3>
<p>Clerk software focuses on user management. It offers tools for authentication, user profiles, and permissions management. It’s great for developers who need simple user management in their apps.</p>
<p><img src="https://paper-attachments.dropboxusercontent.com/s_C0064052A71C5CFDDDBA59A6AE53132401EA70FC25ACA9B576D0C25C8E9EB8BE_1730034843051_FireShot+Capture+598+-+Clerk+-+Authentication+and+User+Management+-+clerk.com.png" alt="The Graphical Interface of Clerk" width="1920" height="970" loading="lazy"></p>
<h3 id="heading-features-of-clerk"><strong>Features of clerk</strong></h3>
<p>Clerk provides:</p>
<ul>
<li><p>Multi-factor authentication (MFA)</p>
</li>
<li><p>Passwordless login (magic links, OTPs)</p>
</li>
<li><p>Social &amp; OAuth login (Google, GitHub, and so on)</p>
</li>
<li><p>Enterprise SSO (SAML, OAuth)</p>
</li>
<li><p>Biometric login (Face ID, Touch ID)</p>
</li>
</ul>
<p>It also handles:</p>
<ul>
<li><p>User profiles &amp; custom attributes</p>
</li>
<li><p>Roles &amp; permissions</p>
</li>
<li><p>Teams &amp; organizations</p>
</li>
<li><p>Session management</p>
</li>
</ul>
<p>For security, it offers:</p>
<ul>
<li><p>Token-based authentication (JWT)</p>
</li>
<li><p>Rate limiting</p>
</li>
<li><p>Audit logs</p>
</li>
<li><p>GDPR &amp; SOC 2 compliance</p>
</li>
</ul>
<p>For developers, it comes with:</p>
<ul>
<li><p>Prebuilt UI components</p>
</li>
<li><p>SDKs for React, Next.js, Vue, and so on</p>
</li>
<li><p>Custom email &amp; SMS templates</p>
</li>
</ul>
<p>To learn more, click here: <a target="_blank" href="https://clerk.com/">Clerk</a></p>
<h3 id="heading-pricing"><strong>Pricing</strong></h3>
<p>Clerk offers a <strong>Free Plan</strong> that includes up to 10,000 Monthly Active Users (MAUs) at no cost. For more advanced features, the <strong>Pro Plan</strong> is available at $25 per month, which also includes the first 10,000 MAUs.</p>
<p>For detailed and up-to-date information on Clerk's pricing plans, please visit their <a target="_blank" href="https://clerk.com/pricing">official pricing page</a>:</p>
<h3 id="heading-firebase"><strong>Firebase</strong></h3>
<p>Firebase is a Google-backed BaaS platform. It is known for its real-time databases, authentication, and cloud storage. It also has easy-to-use tools for web and mobile apps.</p>
<p><img src="https://paper-attachments.dropboxusercontent.com/s_C0064052A71C5CFDDDBA59A6AE53132401EA70FC25ACA9B576D0C25C8E9EB8BE_1730035263750_FireShot+Capture+599+-+Firebase+-+Googles+Mobile+and+Web+App+Development+Platform_+-+firebase.google.com.png" alt="The Graphical Interface of Firebase" width="1920" height="970" loading="lazy"></p>
<h3 id="heading-features-of-firebase">Features of Firebase</h3>
<p>Firebase provides:</p>
<h3 id="heading-backend-services"><strong>Backend Services</strong></h3>
<ul>
<li><p>Firestore &amp; Realtime Database</p>
</li>
<li><p>Cloud Storage</p>
</li>
<li><p>Serverless Functions</p>
</li>
<li><p>Web Hosting</p>
</li>
</ul>
<h3 id="heading-authentication"><strong>Authentication</strong></h3>
<ul>
<li><p>Email &amp; password login</p>
</li>
<li><p>Social logins (Google, Facebook, and so on)</p>
</li>
<li><p>Phone authentication</p>
</li>
<li><p>Anonymous sign-in</p>
</li>
</ul>
<h3 id="heading-analytics-amp-monitoring"><strong>Analytics &amp; Monitoring</strong></h3>
<ul>
<li><p>Google Analytics</p>
</li>
<li><p>Crash tracking (Crashlytics)</p>
</li>
<li><p>Performance monitoring</p>
</li>
<li><p>A/B testing</p>
</li>
</ul>
<h3 id="heading-engagement-tools"><strong>Engagement Tools</strong></h3>
<ul>
<li><p>Push notifications</p>
</li>
<li><p>Remote app updates</p>
</li>
<li><p>In-app messaging</p>
</li>
</ul>
<h3 id="heading-machine-learning"><strong>Machine Learning</strong></h3>
<ul>
<li><p>Text recognition</p>
</li>
<li><p>Image labelling</p>
</li>
</ul>
<p>To learn more, click here: <a target="_blank" href="https://firebase.google.com/">Firebase</a></p>
<h3 id="heading-pricing-plan">Pricing plan</h3>
<p>Firebase offers a <strong>Spark Plan</strong> (free tier) and a <strong>Blaze Plan</strong> (pay-as-you-go). The Spark Plan provides limited free usage, while the Blaze Plan charges based on your actual usage. For detailed and up-to-date information on Firebase's pricing plans, please visit their <a target="_blank" href="https://firebase.google.com/pricing">official pricing page</a>.</p>
<h3 id="heading-convex"><strong>Convex</strong></h3>
<p>Convex is a serverless BaaS platform. It provides real-time data sync and scalable backend services. The design simplifies serverless computing for developers.</p>
<p><img src="https://paper-attachments.dropboxusercontent.com/s_C0064052A71C5CFDDDBA59A6AE53132401EA70FC25ACA9B576D0C25C8E9EB8BE_1730035688864_FireShot+Capture+600+-+Convex+-+The+fullstack+TypeScript+development+platform+-+www.convex.dev.png" alt="The Graphical Interface of Convex" width="1920" height="970" loading="lazy"></p>
<h3 id="heading-convex-features"><strong>Convex Features</strong></h3>
<ul>
<li><p><strong>Database</strong> – Real-time data storage</p>
</li>
<li><p><strong>Serverless Functions</strong> – Run backend logic without managing servers</p>
</li>
<li><p><strong>Authentication</strong> – Built-in user auth &amp; access control</p>
</li>
<li><p><strong>Caching</strong> – Faster data retrieval</p>
</li>
<li><p><strong>Webhooks &amp; Crons</strong> – Automate tasks &amp; trigger events</p>
</li>
</ul>
<p>To learn more, click here: <a target="_blank" href="https://www.convex.dev/">Convex</a></p>
<h3 id="heading-pricing-1"><strong>Pricing</strong></h3>
<ul>
<li><p><strong>Free Plan</strong> – Limited resources for small projects</p>
</li>
<li><p><strong>Pro Plan</strong> – Pay-as-you-go based on usage</p>
</li>
</ul>
<p>Check out full details for <a target="_blank" href="https://convex.dev/pricing">convex pricing</a></p>
<h3 id="heading-8base"><strong>8base</strong></h3>
<p>A low-code platform that allows developers to build serverless apps with minimal setup. It provides database management, authentication, and API development tools.</p>
<p><img src="https://paper-attachments.dropboxusercontent.com/s_C0064052A71C5CFDDDBA59A6AE53132401EA70FC25ACA9B576D0C25C8E9EB8BE_1730036229410_gui+8base.png" alt="The Graphical Interface of 8base" width="1920" height="970" loading="lazy"></p>
<h3 id="heading-8base-features"><strong>8base Features</strong></h3>
<ul>
<li><p><strong>Backend Builder</strong> – Manage your database easily.</p>
</li>
<li><p><strong>Serverless Functions</strong> – Run custom backend logic.</p>
</li>
<li><p><strong>GraphQL API</strong> – Auto-generated API for your data.</p>
</li>
<li><p><strong>Authentication</strong> – Built-in user login &amp; access control.</p>
</li>
<li><p><strong>File Management</strong> – Store and manage files.</p>
</li>
</ul>
<p>To learn more, click here: <a target="_blank" href="https://www.8base.com/">8base</a></p>
<h3 id="heading-pricing-2"><strong>Pricing</strong></h3>
<ul>
<li><p><strong>Free Plan</strong> – $0/month (1 developer, basic features).</p>
</li>
<li><p><strong>Developer Plan</strong> – $25/month per developer.</p>
</li>
<li><p><strong>Professional Plan</strong> – $150/month (5 developers).</p>
</li>
<li><p><strong>Custom Plan</strong> – Contact 8base for enterprise solutions.</p>
</li>
</ul>
<p>Check out full pricing details here: <a target="_blank" href="https://www.8base.com/pricing">8base Pricing</a></p>
<h3 id="heading-backendless"><strong>Backendless</strong></h3>
<p>Backendless is a no-code platform that makes app development easy. It provides APIs, data storage, user management, and real-time updates in one place.</p>
<p><img src="https://paper-attachments.dropboxusercontent.com/s_C0064052A71C5CFDDDBA59A6AE53132401EA70FC25ACA9B576D0C25C8E9EB8BE_1730036359851_FireShot+Capture+584+-+Backendless+Visual+App+Development+Platform+-+UI+Backend++Database_+-+backendless.com.png" alt="The Graphical Interface of Backendless" width="1920" height="970" loading="lazy"></p>
<h3 id="heading-features">Features</h3>
<ul>
<li><p><strong>UI Builder</strong>: Design your app's front end visually without coding.</p>
</li>
<li><p><strong>Real-Time Database</strong>: Store and sync data in real-time across clients.</p>
</li>
<li><p><strong>User Authentication</strong>: Manage user sign-ups, logins, and roles.</p>
</li>
<li><p><strong>Cloud Code</strong>: Implement custom server-side logic without managing servers.</p>
</li>
<li><p><strong>Push Notifications</strong>: Send real-time alerts to users on various devices.</p>
</li>
</ul>
<p>To learn more, click here: <a target="_blank" href="https://backendless.com/">Backendless</a></p>
<h3 id="heading-pricing-3">Pricing</h3>
<p>Backendless offers several plans to suit different needs:</p>
<ul>
<li><p><strong>Free Plan</strong>: Ideal for small projects or learning purposes.</p>
</li>
<li><p><strong>Scale Fixed Plan</strong>: Provides predictable monthly billing with set resource limits.</p>
</li>
<li><p><strong>Scale Variable Plan</strong>: Offers flexibility with usage-based billing, scaling as your app grows.</p>
</li>
<li><p><strong>Backendless Pro</strong>: A self-hosted solution for enterprises requiring unlimited scalability and control.</p>
</li>
</ul>
<p>For more details on Backendless's pricing plans, please visit their <a target="_blank" href="https://backendless.com/pricing/">official pricing plan page</a>.</p>
<h3 id="heading-appwrite"><strong>Appwrite</strong></h3>
<p>Appwrite is an open-source BaaS that provides databases, authentication, file storage, real-time updates, serverless functions, and API management. It supports multiple platforms and offers built-in security and scalability for modern apps.</p>
<p><img src="https://paper-attachments.dropboxusercontent.com/s_C0064052A71C5CFDDDBA59A6AE53132401EA70FC25ACA9B576D0C25C8E9EB8BE_1730036473890_FireShot+Capture+583+-+Appwrite+-+Build+like+a+team+of+hundreds+-+appwrite.io.png" alt="The Graphical Interface of Appwrite" width="1920" height="970" loading="lazy"></p>
<h3 id="heading-features-1">Features</h3>
<ul>
<li><p><strong>Authentication</strong>: Secure user login with over 30 methods, including email/password, OAuth, and magic URLs.</p>
</li>
<li><p><strong>Database</strong>: Scalable storage with advanced permissions, custom data validation, and support for relationships.</p>
</li>
<li><p><strong>Functions</strong>: Deploy serverless functions in over 13 languages, with automatic GitHub deployment and custom domain support.</p>
</li>
<li><p><strong>Storage</strong>: Manage and serve files with built-in security and privacy features.</p>
</li>
<li><p><strong>Real-Time</strong>: Subscribe to database events for instant updates.</p>
</li>
</ul>
<p>To learn more, click here: <a target="_blank" href="https://appwrite.io/">Appwrite</a></p>
<h3 id="heading-pricing-4"><strong>Pricing</strong></h3>
<ul>
<li><p><strong>Free</strong> – $0/month (5GB bandwidth, 2GB storage, 750K function runs).</p>
</li>
<li><p><strong>Pro</strong> – Starts at $15/month (more storage, bandwidth, &amp; features).</p>
</li>
<li><p><strong>Scale</strong> – Starts at $599/month (for large-scale projects).</p>
</li>
</ul>
<p>For more details on the pricing plan check their <a target="_blank" href="https://appwrite.io/pricing">official pricing page</a>.</p>
<h3 id="heading-nhost"><strong>Nhost</strong></h3>
<p>Nhost is a full backend platform with a GraphQL API, database, authentication, and storage. It’s easy to set up and great for modern app development.</p>
<p><img src="https://paper-attachments.dropboxusercontent.com/s_C0064052A71C5CFDDDBA59A6AE53132401EA70FC25ACA9B576D0C25C8E9EB8BE_1730036732414_FireShot+Capture+585+-+Nhost_+The+Open+Source+Firebase+Alternative+with+GraphQL+-+nhost.io.png" alt="s_C0064052A71C5CFDDDBA59A6AE53132401EA70FC25ACA9B576D0C25C8E9EB8BE_1730036732414_FireShot+Capture+585+-+Nhost_+The+Open+Source+Firebase+Alternative+with+GraphQL+-+nhost.io" width="1920" height="970" loading="lazy"></p>
<h3 id="heading-nhost-features"><strong>Nhost Features</strong></h3>
<ul>
<li><p><strong>Authentication</strong> – Secure login with email, OAuth, and so on.</p>
</li>
<li><p><strong>Database</strong> – Scalable storage with permissions.</p>
</li>
<li><p><strong>Serverless Functions</strong> – Run backend code without servers.</p>
</li>
<li><p><strong>Storage</strong> – Secure file hosting.</p>
</li>
<li><p><strong>Real-Time</strong> – Instant updates on data changes.</p>
</li>
</ul>
<p>To learn more, click here: <a target="_blank" href="https://nhost.io/">Nhost</a>.</p>
<h3 id="heading-pricing-5"><strong>Pricing</strong></h3>
<ul>
<li><p><strong>Free</strong> – $0/month (basic features for small projects).</p>
</li>
<li><p><strong>Pro</strong> – $25/month (more resources &amp; support).</p>
</li>
<li><p><strong>Dedicated Compute</strong> – $50/month per vCPU/2GB RAM (for scaling apps).</p>
</li>
</ul>
<p>Check out full details here: <a target="_blank" href="https://nhost.io/pricing">Nhost Pricing</a></p>
<h3 id="heading-back4apps"><strong>Back4apps</strong></h3>
<p>Back4App is an open-source BaaS that simplifies backend development. It provides a complete infrastructure for building, hosting, and managing scalable apps. With built-in server-side features, developers can focus on coding without managing servers or databases.</p>
<p><img src="https://paper-attachments.dropboxusercontent.com/s_C0064052A71C5CFDDDBA59A6AE53132401EA70FC25ACA9B576D0C25C8E9EB8BE_1730036859543_FireShot+Capture+587+-+Build+launch+and+scale+applications+faster+than+ever+with+the+power_+-+www.back4app.com.png" alt="The Graphical Interface of Back4apps" width="1920" height="970" loading="lazy"></p>
<h3 id="heading-back4app-features"><strong>Back4App Features</strong></h3>
<ul>
<li><p><strong>Database</strong> – Manage data with APIs &amp; a visual editor</p>
</li>
<li><p><strong>Authentication</strong> – Secure user login &amp; roles</p>
</li>
<li><p><strong>Real-Time</strong> – Instant data updates</p>
</li>
<li><p><strong>Push Notifications</strong> – Send alerts to users.</p>
</li>
<li><p><strong>Cloud Functions</strong> – Run custom backend code.</p>
</li>
</ul>
<p>To learn more, click here: <a target="_blank" href="https://www.back4app.com/">Back4apps</a>.</p>
<h3 id="heading-pricing-6"><strong>Pricing</strong></h3>
<ul>
<li><p><strong>Free</strong> – 25K requests, 250MB storage, 1GB transfer/month.</p>
</li>
<li><p><strong>MVP Plan</strong> – For launching small apps.</p>
</li>
<li><p><strong>Dedicated Plan</strong> – For production apps with more resources.</p>
</li>
</ul>
<p>The <strong>MVP Plan</strong> in Back4App refers to a <strong>Minimum Viable Product (MVP) Plan</strong>. It is designed for startups and developers who are launching a small app with essential backend services. This plan provides enough resources to test and validate an idea before scaling up.</p>
<p>While <strong>Dedicated Plan</strong> in Back4App provides a <strong>private server with dedicated resources</strong> for apps that need better performance, security, and scalability. It is ideal for production apps with high traffic or specific infrastructure requirements.</p>
<p>Check out full details here: <a target="_blank" href="https://www.back4app.com/pricing">Back4App Pricing</a>.</p>
<h3 id="heading-aws-amplify"><strong>AWS Amplify</strong></h3>
<p>AWS Amplify is a development platform from Amazon Web Services (AWS). It simplifies building and deploying web and mobile apps. It offers tools and services for developers. They can integrate scalable backends, manage frontends, and add features like authentication, storage, and APIs.</p>
<p><img src="https://paper-attachments.dropboxusercontent.com/s_C0064052A71C5CFDDDBA59A6AE53132401EA70FC25ACA9B576D0C25C8E9EB8BE_1730036938873_FireShot+Capture+588+-+Full+Stack+Development+-+Web+and+Mobile+Apps+-+AWS+Amplify+-+aws.amazon.com.png" alt="The Graphical Interface of Aws Amplify" width="1920" height="970" loading="lazy"></p>
<h3 id="heading-aws-amplify-features"><strong>AWS Amplify Features</strong></h3>
<ul>
<li><p><strong>Authentication</strong> – Secure login with email, social sign-in, and multi-factor authentication</p>
</li>
<li><p><strong>Database &amp; API</strong> – Build real-time APIs with AWS databases</p>
</li>
<li><p><strong>Storage</strong> – Manage files and media with Amazon S3</p>
</li>
<li><p><strong>Hosting</strong> – Deploy full-stack apps with continuous deployment</p>
</li>
</ul>
<p>To learn more, click here: <a target="_blank" href="https://aws.amazon.com/amplify/?gclid=Cj0KCQjwpP63BhDYARIsAOQkATZlSP8VJyO8gGZMtrSp7JE6hMJjFPh1Am4F2eQv5Yex_okPLLvWjlUaAgDQEALw_wcB&amp;trk=e37f908f-322e-4ebc-9def-9eafa78141b8&amp;sc_channel=ps&amp;ef_id=Cj0KCQjwpP63BhDYARIsAOQkATZlSP8VJyO8gGZMtrSp7JE6hMJjFPh1Am4F2eQv5Yex_okPLLvWjlUaAgDQEALw_wcB:G:s&amp;s_kwcid=AL!4422!3!647301987559!p!!g!!amplify%20framework!19613610159!148358959649">Aws Amplify</a></p>
<h3 id="heading-pricing-7"><strong>Pricing</strong></h3>
<ul>
<li><p><strong>Free Tier (First 12 months)</strong></p>
<ul>
<li><p>1,000 build minutes/month</p>
</li>
<li><p>5GB storage</p>
</li>
<li><p>15GB bandwidth</p>
</li>
<li><p>500K API requests</p>
</li>
</ul>
</li>
<li><p><strong>Pay-As-You-Go (After Free Tier)</strong></p>
<ul>
<li><p><strong>Build &amp; Deploy</strong> – $0.01 per build minute</p>
</li>
<li><p><strong>Storage</strong> – $0.023 per GB/month</p>
</li>
<li><p><strong>Bandwidth</strong> – $0.15 per GB served</p>
</li>
<li><p><strong>API Requests</strong> – $0.30 per 1M requests</p>
</li>
</ul>
</li>
</ul>
<p>Full details here: <a target="_blank" href="https://aws.amazon.com/amplify/pricing/">AWS Amplify Pricing</a></p>
<h3 id="heading-supabase"><strong>Supabase</strong></h3>
<p>Supabase is an open-source alternative to Firebase. It uses PostgreSQL for its database. It has built-in features like authentication, APIs, and real-time subscriptions.</p>
<p><img src="https://paper-attachments.dropboxusercontent.com/s_C0064052A71C5CFDDDBA59A6AE53132401EA70FC25ACA9B576D0C25C8E9EB8BE_1730037060219_FireShot+Capture+581+-+Supabase+-+The+Open+Source+Firebase+Alternative+-+supabase.com.png" alt="The Graphical Interface of Supabase" width="1920" height="970" loading="lazy"></p>
<h3 id="heading-supabase-features"><strong>Supabase Features</strong></h3>
<ul>
<li><p><strong>Database</strong> – PostgreSQL with full SQL support.</p>
</li>
<li><p><strong>Authentication</strong> – Secure login with email, password, and social logins.</p>
</li>
<li><p><strong>Storage</strong> – Store and serve files easily.</p>
</li>
<li><p><strong>Real-Time</strong> – Get instant updates when data changes.</p>
</li>
<li><p><strong>Edge Functions</strong> – Run serverless backend logic.</p>
</li>
</ul>
<p>To learn more, click here: <a target="_blank" href="https://supabase.com/">Supabase</a>.</p>
<h3 id="heading-pricing-8"><strong>Pricing</strong></h3>
<ul>
<li><p><strong>Free</strong> – Great for small projects i.e. projects for learning, and experimentation.</p>
</li>
<li><p><strong>Pro</strong> – Starts at $25/month (includes $10 compute credits).</p>
</li>
<li><p><strong>Team</strong> – Starts at $599/month (for advanced features &amp; support).</p>
</li>
</ul>
<p>Full details here: <a target="_blank" href="https://supabase.com/pricing">Supabase Pricing</a></p>
<h2 id="heading-how-to-get-started-with-baas-quick-example">How to Get Started with BaaS (Quick Example)</h2>
<p>Let’s go through a quick example to get started. In this tutorial, I’ll use Firebase as an example.</p>
<ul>
<li><p>Go to the <a target="_blank" href="https://firebase.google.com/">Firebase website</a> and sign up using your Google account.</p>
</li>
<li><p>After signing in, create a new Firebase project by following the on-screen instructions.</p>
</li>
<li><p>Go to "Authentication" and enable a sign-in method, like email/password or Google login</p>
</li>
<li><p>In "Firestore Database," create a new database for your app's data.</p>
</li>
<li><p>Install Firebase SDK in your project and integrate authentication, databases, and other Firebase services into your app.</p>
</li>
</ul>
<p>For more detailed instructions on setting up Firebase, check out this article: <a target="_blank" href="https://www.freecodecamp.org/news/authenticate-react-app-using-firebase/">How to Authenticate Your React App Using Firebase</a> where I explain each step in depth.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Backend as a Service (BaaS) is ideal for developers. It provides an efficient and cost-effective way to handle backend development tasks. BaaS can speed up your development. It lets you avoid server management. You can then focus on building better apps.</p>
<p>If you're new to backend development, check out the BaaS tools in this article. They can simplify your workflow. Try out BaaS today and take your development to the next level!</p>
<p>Have you tried using BaaS for your applications? Share your experiences!</p>
<p>If you found this article helpful, share it with others who may find it interesting.</p>
<p>Stay updated with my projects by following me on <a target="_blank" href="https://twitter.com/ijaydimples">Twitter</a>, <a target="_blank" href="https://twitter.com/ijaydimples">LinkedIn</a> and <a target="_blank" href="https://github.com/ijayhub">GitHub</a>.</p>
<p>Thank you for reading.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Build an Application with AWS Lambda ]]>
                </title>
                <description>
                    <![CDATA[ AWS Lambda is a service from Amazon Web Services (AWS) that lets you run your code in response to events without managing servers. It’s a simple and scalable way to build applications. In this tutorial, I’ll show you how to use AWS Lambda with three ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-build-an-application-with-aws-lambda/</link>
                <guid isPermaLink="false">6798f596558861e9737fa5af</guid>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Devops ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cloud Computing ]]>
                    </category>
                
                    <category>
                        <![CDATA[ aws lambda ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cloud ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ijeoma Igboagu ]]>
                </dc:creator>
                <pubDate>Tue, 28 Jan 2025 15:19:50 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1738077341437/939ee844-0f10-4ea6-b031-9c481019e7c6.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>AWS Lambda is a service from Amazon Web Services (AWS) that lets you run your code in response to events without managing servers. It’s a simple and scalable way to build applications.</p>
<p>In this tutorial, I’ll show you how to use AWS Lambda with three other services:</p>
<ul>
<li><p><strong>Amazon S3</strong> for storing files, images, and videos</p>
</li>
<li><p><strong>Amazon Simple Notification Service (SNS)</strong> for sending notifications</p>
</li>
<li><p><strong>Amazon EventBridge</strong> for scheduling messages</p>
</li>
</ul>
<p>We’ll go through everything step by step.</p>
<p>By the end, with the integration of the other services, you will have built a Goal Manifestation Quote App that sends random inspirational messages to keep you motivated and focused on your goals.</p>
<h3 id="heading-prerequisites">Prerequisites</h3>
<ul>
<li><p>An AWS account: If you don’t have one, sign up <a target="_blank" href="https://aws.amazon.com/">here</a>.</p>
</li>
<li><p>A GitHub repository: This is for storing your source code. If you don’t have a GitHub account, you can create one <a target="_blank" href="https://github.com/">here</a>.</p>
</li>
<li><p>An Integrated Development Environment (IDE) such as <a target="_blank" href="https://code.visualstudio.com/">Visual Studio Code</a> or <a target="_blank" href="https://www.sublimetext.com/download">Sublime Text</a>.</p>
</li>
<li><p>A basic knowledge of web development and any programming language of your choice. I used Python for this tutorial.</p>
</li>
<li><p><a target="_blank" href="https://zenquotes.io/">Zenquote Random API</a></p>
</li>
</ul>
<h3 id="heading-what-youll-learn">What You'll Learn</h3>
<ul>
<li><p>How to create an Amazon S3 bucket</p>
</li>
<li><p>How to use Amazon Simple Notification Service (SNS)</p>
</li>
<li><p>How to use Amazon Lambda</p>
</li>
<li><p>How to use Amazon EventBridge</p>
</li>
</ul>
<h2 id="heading-table-of-contents"><strong>Table of Contents</strong></h2>
<ol>
<li><p><a class="post-section-overview" href="#heading-step-1-set-up-your-development-environment">Step 1: Set Up Your Development Environment</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-2-create-an-amazon-simple-storage-service-s3">Step 2: Create an Amazon Simple Storage Service (S3)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-3-create-an-amazon-simple-simple-notification-service">Step 3: Create an Amazon Simple Notification Service (SNS)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-4-create-an-iam-policy">Step 4: Create an IAM Policy</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-5-create-an-amazon-lambda-function">Step 5: Create an Amazon Lambda function</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-6-create-an-eventbridge">Step 6: Create an EventBridge</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-7-upload-your-code">Step 7. Upload Your Code</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736791948488/38dfe402-1050-410d-869b-0cef2797b792.png" alt="Let's get started 🚀" class="image--center mx-auto" width="600" height="401" loading="lazy"></p>
<h2 id="heading-step-1-set-up-your-development-environment">Step 1: Set Up Your Development Environment</h2>
<p>In this step, you'll get everything set up. Start by signing in to your AWS account, then install <a target="_blank" href="https://www.python.org/downloads/">Python</a> if you don't have it on your IDE.</p>
<h2 id="heading-step-2-create-an-amazon-simple-storage-service-s3"><strong>Step 2: Create an Amazon Simple Storage Service (S3)</strong></h2>
<p>Before we begin creating an S3 bucket, let's first understand what Amazon S3 is:</p>
<p><strong>Amazon S3 (Simple Storage Service)</strong> is a service from Amazon that allows you to store and access any amount or type of data, such as photos, videos, documents, and backups, whenever you need it.</p>
<p>Now that you know the basics of what Amazon S3 is, let's return to the tutorial.</p>
<h3 id="heading-create-an-s3-bucket">Create an S3 Bucket</h3>
<p>There are several ways to create an S3 bucket, but for this tutorial, we'll use the <a target="_blank" href="https://ubuntu.com/download">Ubuntu command line (CMD)</a>, your terminal, or <strong>Amazon CloudShell</strong>, depending on what you're most comfortable with.</p>
<ul>
<li><p>Type boto3 s3 in the web search bar to view a list of related documentation.</p>
</li>
<li><p>Click on the first result.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736792137101/5f38b4ec-fa23-41b3-b108-ca7fc7b390ba.png" alt="Regular Google search" class="image--right mx-auto mr-0" width="848" height="272" loading="lazy"></p>
<ul>
<li>Once the documentation is open, copy the first command you see.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736792202800/5647c731-734f-4134-a558-9d66eee47734.png" alt="boto3 command" width="947" height="376" loading="lazy"></p>
<ul>
<li>Paste it on your CMD OR terminal of your choice – but before then remember to "<strong>cd</strong>" into the right directory.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736792298332/d3384fc3-e31c-4d37-8e17-40ad7e77df28.png" alt="paste command from documentation to your editor" width="725" height="89" loading="lazy"></p>
<ul>
<li>In the documentation, scroll down and click on "create_bucket.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736792399748/0cd59a14-b037-464b-8193-7ec515c4772e.png" alt="0cd59a14-b037-464b-8193-7ec515c4772e" width="223" height="24" loading="lazy"></p>
<ul>
<li><p>Once it's open, scroll down to "Request Syntax." Copy the <strong>bucket name</strong> and the <strong>bucket configuration</strong>.</p>
</li>
<li><p>Other variables listed in the request syntax are optional.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736792898846/eea0f8c4-d153-4bc8-8c78-346fc5bf6a04.png" alt="Request syntax from the documentation" width="887" height="262" loading="lazy"></p>
<ul>
<li>Once this is done, make sure you save.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736793004865/a1c9739c-2d12-4e2d-b057-f09bc61e16a3.png" alt="All command" width="980" height="413" loading="lazy"></p>
<ul>
<li>Go back and call the script:</li>
</ul>
<pre><code class="lang-plaintext">#python3 your file name
</code></pre>
<ul>
<li>Running the script automatically creates an S3 bucket in your Amazon S3.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736793086405/9c0b4671-ea07-4ad7-b1d7-0d785aafa954.png" alt="Automatic creation" width="1904" height="155" loading="lazy"></p>
<ul>
<li>Now you can go to the console to check if it has been created:</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736692453693/320318d4-bdf3-4be3-a709-6cff18459c9c.png" alt="Amazon console" class="image--center mx-auto" width="744" height="129" loading="lazy"></p>
<h3 id="heading-upload-files">Upload Files</h3>
<p>With the bucket created, we can now upload files through the console. I believe there's also a programmatic way to upload files and test, but I haven't explored all the methods in the documentation yet.</p>
<p>Click on the bucket name to be redirected to the object page. This is where you will upload your files for storage.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736692660862/355f828f-f83f-4501-a960-f0068cf9d977.png" alt="upload page" class="image--center mx-auto" width="1837" height="369" loading="lazy"></p>
<p>Click on the <strong>Upload button</strong> to upload a file. Remember, we're creating a Goal Manifestation Quote Application.</p>
<p>Now that we've set up a storage bucket:</p>
<ul>
<li><p>Open a tool like Google Drive, MS Word, WPS, or any other document editor.</p>
</li>
<li><p>Write down the goals you want to achieve.</p>
</li>
<li><p>Save the file in either PDF or DOCX format.</p>
</li>
<li><p>Take the document and upload it to your Amazon S3.o</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736693525955/765b6c3a-ae68-4cbc-9df7-e896a1d63cbb.png" alt="upload a document" class="image--center mx-auto" width="1519" height="402" loading="lazy"></p>
<p>To verify if it's the correct file:</p>
<ul>
<li><p>Navigate to the <strong>Permissions</strong> tab.</p>
</li>
<li><p>Scroll down to <strong>Block public access.</strong></p>
</li>
<li><p>Click on <strong>Edit</strong> and uncheck the box.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736738796036/6ab41bc4-72a8-4874-a491-35bcdda49938.png" alt="block access " class="image--center mx-auto" width="1860" height="291" loading="lazy"></p>
<p>As shown above, it is currently set to "on." Uncheck it to turn it "off."</p>
<ul>
<li><p>On the same bucket settings page, modify the policy.</p>
</li>
<li><p>Scroll down, and you'll see that a bucket policy has been auto-generated.</p>
</li>
<li><p>Go ahead and copy the policy.</p>
</li>
</ul>
<pre><code class="lang-plaintext">{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PublicReadGetObject",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::your-bucket-name/*"
    }
  ]
}
</code></pre>
<ul>
<li>Go back to the bucket policy editor and paste the policy.</li>
</ul>
<p>Once you've completed these steps, your object will have public access.</p>
<p>Return to the <strong>Objects</strong> tab and click on the Object URL provided below:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736740454730/3b36b380-912d-4a2a-a8c5-bee61bd42765.png" alt="3b36b380-912d-4a2a-a8c5-bee61bd42765" class="image--center mx-auto" width="729" height="89" loading="lazy"></p>
<p>With this URL, your upload is now visible.</p>
<h2 id="heading-step-3-create-an-amazon-simple-notification-service-sns"><strong>Step 3: Create an Amazon Simple Notification Service (SNS)</strong></h2>
<p><strong>SNS</strong> is a fully managed messaging service provided by AWS. It enables communication between applications or directly with users by sending notifications.</p>
<p>To create an SNS, follow these steps:</p>
<h4 id="heading-1-log-in-to-the-aws-management-console"><strong>1. Log in to the AWS management console</strong></h4>
<p>Then go to Amazon SNS. Navigate to the SNS Dashboard and select <strong>Topics</strong> from the left-hand menu.</p>
<p>To create a topic:</p>
<ul>
<li><p>Click <strong>Create topic</strong>.</p>
</li>
<li><p>Choose a <strong>Topic type</strong>: Standard (default) or FIFO (for ordered messages).</p>
</li>
<li><p>Enter a <strong>Name</strong> for your topic. (for example, <code>MyFirstSNSTopic</code>).</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736743311856/fa51ecb9-935a-4567-829c-b84ee3c1bee0.png" alt="sns topic creation" class="image--center mx-auto" width="1225" height="727" loading="lazy"></p>
</li>
<li><p>Configure optional settings like encryption, delivery retry policies, or tags.</p>
</li>
<li><p>Click <strong>Create topic</strong>.</p>
</li>
</ul>
<h4 id="heading-2-add-subscriptions"><strong>2. Add Subscriptions:</strong></h4>
<p>Once the topic is created, click on it to open the details page. Select the <strong>Subscriptions</strong> tab.</p>
<p>Click <strong>Create Subscription</strong> and choose:</p>
<ul>
<li><p><strong>Protocol</strong> can be Email, SMS, HTTP/S, Lambda, or SQS.</p>
</li>
<li><p><strong>Endpoints</strong> such as email address, phone number, or URL.</p>
</li>
</ul>
<p>Click <strong>Create Subscription</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736743374208/8005dc71-68ed-4d26-b79b-7b418959ab6c.png" alt="Subscription created" class="image--center mx-auto" width="1544" height="231" loading="lazy"></p>
<h4 id="heading-3-confirm-the-subscription"><strong>3. Confirm the Subscription:</strong></h4>
<p>If you selected email or SMS, a confirmation link or code will be sent to the provided endpoint. Follow the instructions to confirm the subscription.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736743525222/90c3b61d-eeb2-450d-a397-253b9e3c15db.png" alt="A confirm message from amazon sns" class="image--center mx-auto" width="760" height="372" loading="lazy"></p>
<p>Now that we’ve done this, let's create an Amazon Lambda function that will trigger the SNS so that the message will be sent to your mail.</p>
<h2 id="heading-step-4-create-an-iam-policy"><strong>Step 4: Create an IAM Policy</strong></h2>
<p>This policy is created to authorize Amazon Lambda to trigger the event and to ensure that CloudWatch is automatically triggered to monitor the application's events.</p>
<p>To create a policy, follow these steps:</p>
<h4 id="heading-1-log-in-to-the-aws-management-console-1"><strong>1. Log in to the AWS Management console.</strong></h4>
<p>In the left-hand menu, select <strong>Policies</strong>. Then:</p>
<ul>
<li><p>Click <strong>Create policy</strong>.</p>
</li>
<li><p>Choose the <strong>Visual</strong> tab, then select the <strong>SNS</strong> service.</p>
</li>
<li><p>Next, click the <strong>Choose</strong> tab to create a custom policy.</p>
</li>
</ul>
<pre><code class="lang-plaintext">{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "sns:Publish",
            "Resource": "arn:aws:sns:REGION:ACCOUNT_ID:goal_topic"
        }
    ]
}
</code></pre>
<p>Then, replace the following placeholders with your info:</p>
<ul>
<li><p><code>region</code>: Your AWS region (for example, <code>us-east-1</code>).</p>
</li>
<li><p><code>account-id</code>: Your AWS account ID.</p>
</li>
<li><p><code>topic-name</code>: Your SNS topic name.</p>
</li>
</ul>
<h4 id="heading-2-view-and-create-the-policy"><strong>2. View and create the policy:</strong></h4>
<p>You can do this by following these steps:</p>
<ul>
<li><p>Click on the Review button.</p>
</li>
<li><p>Give your policy a <strong>Name</strong> (for example, <code>LambdaSNSPolicy</code>), and optionally, a <strong>Description</strong>.</p>
</li>
<li><p>Click <strong>Create policy</strong>.</p>
</li>
</ul>
<h4 id="heading-3-attach-policy-to-the-lambda-execution-role">3. Attach policy to the Lambda Execution Role</h4>
<p>Now, you need to attach the policy to your Lambda Execution Role. To do that, follow these steps:</p>
<ul>
<li><p>Go to the <strong>Roles</strong> section in the IAM Console.</p>
</li>
<li><p>Search for and select the execution role.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736749886571/70ea6752-5c13-465c-bc05-22e3da50127e.png" alt="lambdaexecution role" class="image--center mx-auto" width="1527" height="275" loading="lazy"></p>
<ul>
<li><p>Next, search for the policy you just created and select it.</p>
</li>
<li><p>Click <strong>Attach policy</strong>.</p>
</li>
</ul>
<p>Both policies will be automatically attached.</p>
<h2 id="heading-step-5-create-an-amazon-lambda-function"><strong>Step 5: Create an Amazon Lambda function</strong></h2>
<p>Amazon Lambda is a service from AWS that lets you run code without managing servers. You upload your code, and Lambda automatically runs and scales it when needed.</p>
<p>Follow these steps to create an Amazon Lambda function:</p>
<h4 id="heading-1-log-in-to-aws-management-console"><strong>1. Log in to AWS Management Console</strong>:</h4>
<p>Navigate to AWS Lambda.</p>
<h4 id="heading-2-create-a-function"><strong>2. Create a Function</strong>:</h4>
<p>Click on the <strong>Create function</strong> and choose the option <strong>Author from scratch</strong>.</p>
<p>Fill in the details:</p>
<ul>
<li><p><strong>Function name</strong>: Enter a unique name (for example, <code>SNSLambdaFunction</code>).</p>
</li>
<li><p><strong>Runtime</strong>: Select the runtime (for example, Python, Node.js, Java, and so on).</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736751631488/fe254e56-89f1-4938-b2a9-e59b24e54a04.png" alt="creating a function" class="image--center mx-auto" width="1512" height="515" loading="lazy"></p>
<ul>
<li><strong>Role</strong>: Choose or create a role. If you already have a role, select <strong>Use an existing role</strong>. Otherwise, select <strong>Create a new role with basic Lambda permissions</strong>.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736751816631/97475623-10dc-4427-87ab-7e8789526e9e.png" alt="role choosing" class="image--center mx-auto" width="1108" height="346" loading="lazy"></p>
<ul>
<li>Click the <strong>Create function button</strong>.</li>
</ul>
<h4 id="heading-3-paste-in-the-code"><strong>3. Paste in the code</strong>:</h4>
<p>On the Lambda function’s page, go to the <strong>Configuration</strong> tab:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736753706928/b0351665-c506-454e-9c71-b4a52fce5a0a.png" alt="configuration tab" class="image--center mx-auto" width="1517" height="404" loading="lazy"></p>
<p>Remember, we are trying to fetch a quote. I'll add the ARN of the topic we created here and include my API keys. But for this tutorial, I will use the API directly to fetch the data.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736754071465/1322e207-5c51-45f1-979f-05f2388e9557.png" alt="1322e207-5c51-45f1-979f-05f2388e9557" class="image--center mx-auto" width="1517" height="404" loading="lazy"></p>
<h4 id="heading-4-write-the-lambda-code"><strong>4. Write the Lambda Code:</strong></h4>
<p>Go to the <strong>Code</strong> tab in your Lambda function. Then write or paste the code from your IDE to process the incoming SNS messages.</p>
<p>Example:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736754319755/60224578-53c2-43f6-9bf1-8cba6afaa1a3.png" alt="Testing code" class="image--center mx-auto" width="1513" height="405" loading="lazy"></p>
<p>Here’s the code:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> os
<span class="hljs-keyword">import</span> json
<span class="hljs-keyword">import</span> urllib.request
<span class="hljs-keyword">import</span> boto3

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">fetch_random_quote</span>():</span>
    <span class="hljs-string">"""
    Fetches a random quote from the ZenQuotes API.
    """</span>
    api_url = <span class="hljs-string">"https://zenquotes.io/api/random"</span>
    <span class="hljs-keyword">try</span>:
        <span class="hljs-keyword">with</span> urllib.request.urlopen(api_url) <span class="hljs-keyword">as</span> response:
            data = json.loads(response.read().decode())
            <span class="hljs-keyword">if</span> data <span class="hljs-keyword">and</span> isinstance(data, list):
                <span class="hljs-comment"># Format the quote and author</span>
                quote = data[<span class="hljs-number">0</span>].get(<span class="hljs-string">"q"</span>, <span class="hljs-string">"No quote available"</span>)
                author = data[<span class="hljs-number">0</span>].get(<span class="hljs-string">"a"</span>, <span class="hljs-string">"Unknown author"</span>)
                <span class="hljs-keyword">return</span> <span class="hljs-string">f'"<span class="hljs-subst">{quote}</span>" - <span class="hljs-subst">{author}</span>'</span>
            <span class="hljs-keyword">else</span>:
                <span class="hljs-keyword">return</span> <span class="hljs-string">"No quote available."</span>
    <span class="hljs-keyword">except</span> Exception <span class="hljs-keyword">as</span> e:
        print(<span class="hljs-string">f"Error fetching random quote: <span class="hljs-subst">{e}</span>"</span>)
        <span class="hljs-keyword">return</span> <span class="hljs-string">"Failed to fetch quote."</span>

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">lambda_handler</span>(<span class="hljs-params">event, context</span>):</span>
    <span class="hljs-string">"""
    AWS Lambda handler function to fetch a random quote and publish it to an SNS topic.
    """</span>
    <span class="hljs-comment"># Get the SNS topic ARN from environment variables</span>
    sns_topic_arn = os.getenv(<span class="hljs-string">"SNS_TOPIC_ARN"</span>)
    sns_client = boto3.client(<span class="hljs-string">"sns"</span>)

    <span class="hljs-comment"># Fetch a random quote</span>
    quote = fetch_random_quote()
    print(<span class="hljs-string">f"Fetched Quote: <span class="hljs-subst">{quote}</span>"</span>)

    <span class="hljs-comment"># Publish the quote to SNS</span>
    <span class="hljs-keyword">try</span>:
        sns_client.publish(
            TopicArn=sns_topic_arn,
            Message=quote,
            Subject=<span class="hljs-string">"Daily Random Quote to help you stay motivated and inspired to achieve your goals"</span>,
        )
        print(<span class="hljs-string">"Quote published to SNS successfully."</span>)
    <span class="hljs-keyword">except</span> Exception <span class="hljs-keyword">as</span> e:
        print(<span class="hljs-string">f"Error publishing to SNS: <span class="hljs-subst">{e}</span>"</span>)
        <span class="hljs-keyword">return</span> {<span class="hljs-string">"statusCode"</span>: <span class="hljs-number">500</span>, <span class="hljs-string">"body"</span>: <span class="hljs-string">"Error publishing to SNS"</span>}

    <span class="hljs-keyword">return</span> {<span class="hljs-string">"statusCode"</span>: <span class="hljs-number">200</span>, <span class="hljs-string">"body"</span>: <span class="hljs-string">"Quote sent to SNS"</span>}
</code></pre>
<h4 id="heading-5-save"><strong>5. Save:</strong></h4>
<p>Click on the deploy button to save.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736756768348/8ec83b6b-874c-47c3-a1ad-8d8b85cd6d48.png" alt="8ec83b6b-874c-47c3-a1ad-8d8b85cd6d48" class="image--center mx-auto" width="336" height="48" loading="lazy"></p>
<h4 id="heading-6-test-your-lambda-function"><strong>6. Test Your Lambda Function</strong>:</h4>
<p>Go to the <strong>Test</strong> tab and create a new test event.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736757103169/834c5b6c-8796-4a52-bcc3-cbd8009b01da.png" alt="TEST EVENT" class="image--center mx-auto" width="1496" height="671" loading="lazy"></p>
<p>Then save and run the test. If it’s successful, a message will be sent:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736757309807/d97f9648-0000-4ec8-b287-df5250b3be0a.png" alt="success msg" class="image--center mx-auto" width="1466" height="365" loading="lazy"></p>
<p>This means the message has been created for you</p>
<p>Finally, check your email or SMS, depending on the endpoint you used for this tutorial. In my case, I used email.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736757884384/d5b949d4-0804-4694-9674-77fc0265e2e8.png" alt="email notification" class="image--center mx-auto" width="1314" height="309" loading="lazy"></p>
<h2 id="heading-step-6-create-an-eventbridge"><strong>Step 6: Create an EventBridge</strong></h2>
<p>Amazon EventBridge is a service that helps you connect applications and AWS services such as the Amazon SNS and Amazon Lambda.</p>
<p>To create an Amazon EventBridge rule, follow these steps:</p>
<h4 id="heading-1-navigate-to-eventbridge"><strong>1. Navigate to EventBridge</strong>:</h4>
<p>In the search bar, type <strong>EventBridge</strong> and select it from the services list.</p>
<h4 id="heading-2-create-a-rule"><strong>2. Create a Rule:</strong></h4>
<p>In the EventBridge console, click <strong>Rules</strong> on the left panel. Then click the <strong>Create rule</strong> button.</p>
<h4 id="heading-3-set-up-the-rule-details"><strong>3. Set Up the Rule Details</strong>:</h4>
<ul>
<li><p><strong>Name</strong>: Enter a unique name for your rule.</p>
</li>
<li><p><strong>Description (optional)</strong>: Add a description to explain what this rule does.</p>
</li>
</ul>
<h4 id="heading-4-choose-the-event-bus"><strong>4. Choose the Event Bus</strong>:</h4>
<p>Select <strong>Default event bus</strong> (or another event bus if you've created one).</p>
<h4 id="heading-5-define-the-event-pattern-or-schedule"><strong>5. Define the Event Pattern or Schedule</strong>:</h4>
<p><strong>For Event Pattern</strong>:</p>
<ul>
<li><p>Choose an <strong>AWS Service</strong> as the event source.</p>
</li>
<li><p>Select the specific <strong>event type</strong> (for example, an S3 file upload or an EC2 instance state change).</p>
</li>
</ul>
<p><strong>For Schedule</strong>:</p>
<ul>
<li>Choose the <strong>Schedule</strong> option to run the rule on a fixed interval (for example, every 5 minutes).</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736759371221/ca28dcf2-061a-4c8f-8191-32bdf8380111.png" alt="rule details" class="image--center mx-auto" width="1513" height="817" loading="lazy"></p>
<ul>
<li>Click on continue. This takes you to the specific details page where:</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736759696183/44ba44e8-2a1b-4cd8-928b-6fe87cc35c4e.png" alt="schedule page" class="image--center mx-auto" width="1509" height="795" loading="lazy"></p>
<ul>
<li><p>Scroll down and click on the cron scheduler. The cron scheduler specifies what time the message will be sent.</p>
</li>
<li><p>Select <strong>"Off"</strong> for the flexible time window option.</p>
</li>
<li><p>Review the rule details to confirm everything is correct.</p>
</li>
<li><p>Click the <strong>"Next"</strong> button to proceed to the <strong>Target</strong> page.</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736760213450/c4f6cccf-7f89-485d-802e-051284c89f9a.png" alt="cron scheduler " width="1475" height="798" loading="lazy"></p>
<p>  The picture above shows when the time the messages will be sent.</p>
<ul>
<li>On the Target page, select <strong>AWS Lambda</strong> to invoke your function.</li>
</ul>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736761288843/e35a7153-48d7-4b34-86ce-9cba68bd5161.png" alt="the target page" class="image--center mx-auto" width="1485" height="511" loading="lazy"></p>
<ul>
<li>Scroll down to invoke and choose the function you created.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736761539389/4faa1dbc-5635-4de3-8087-15a444298b2e.png" alt="invoke the function" class="image--center mx-auto" width="1114" height="193" loading="lazy"></p>
<ul>
<li>Click the "Next" button to proceed. This will take you to the settings page. Under the permissions section, select "Use existing rule."</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736782488383/ffbbcc4e-6379-4c9c-af16-f4c017e7426c.png" alt="setting page" class="image--center mx-auto" width="1509" height="366" loading="lazy"></p>
<ul>
<li>Lastly, go to the review and create a schedule:</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736783029778/2d0e7ff9-bb7d-462d-a644-23517f47e53e.png" alt="2d0e7ff9-bb7d-462d-a644-23517f47e53e" class="image--center mx-auto" width="1463" height="776" loading="lazy"></p>
<ul>
<li>The next page shows you all the details:</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736783558777/4545d2da-5020-46c3-a265-5499e6b4e74f.png" alt="4545d2da-5020-46c3-a265-5499e6b4e74f" class="image--center mx-auto" width="1512" height="828" loading="lazy"></p>
<p>Using the EventBrige creates a scheduler for the users.</p>
<h2 id="heading-step-7-upload-your-code"><strong>Step 7: Upload Your Code</strong></h2>
<p>Finally, upload your code to GitHub and include proper documentation to help explain how the code works.</p>
<p>Check this documentation out if you don’t know how: <a target="_blank" href="https://docs.github.com/en/get-started/start-your-journey/uploading-a-project-to-github">Uploading a project to GitHub</a>.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>If you’ve followed all these steps, you will have created a Goal Manifestation Quote App using AWS Lambda, Amazon S3, Amazon SNS, and Amazon EventBridge. This app fetches motivational quotes and sends them to subscribers on a schedule.</p>
<p>You can find the repository link <a target="_blank" href="https://github.com/ijayhub/goal-manifestation-quote">here</a>.</p>
<p>Feel free to share your progress or ask questions if you have any issues.</p>
<p>If you found this article helpful, share it with others.</p>
<p>Stay updated with my projects by following me on <a target="_blank" href="https://https//twitter.com/ijaydimples">Twitter</a>, <a target="_blank" href="https://www.linkedin.com/in/ijeoma-igboagu/">LinkedIn</a> and <a target="_blank" href="https://github.com/ijayhub">GitHub</a></p>
<p>Thank you for reading 💖.</p>
<p><strong>Disclaimer:</strong><br>The resources shown in this article, including the S3 bucket and its ARN, have been deleted and no longer exist. The details visible in the screenshots are used solely for demonstration purposes.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ What is Cloud Computing? A Guide for Beginners ]]>
                </title>
                <description>
                    <![CDATA[ When I was a kid, I loved looking at clouds and imagining funny shapes. Sometimes, I even wondered if someone was up there! Now that I’m an adult, I still ask, “What’s in the cloud?” When we talk about "the cloud" in technology, we’re not referring t... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/cloud-computing-guide-for-beginners/</link>
                <guid isPermaLink="false">6732b0dbe6dfc6edf3fe9c72</guid>
                
                    <category>
                        <![CDATA[ Cloud Computing ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Developer ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ijeoma Igboagu ]]>
                </dc:creator>
                <pubDate>Tue, 12 Nov 2024 01:35:23 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1730228320580/871eed36-be9c-4ca8-a92d-b0329ad91ffe.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>When I was a kid, I loved looking at clouds and imagining funny shapes. Sometimes, I even wondered if someone was up there! Now that I’m an adult, I still ask, “What’s in the cloud?”</p>
<p>When we talk about "the cloud" in technology, we’re not referring to those fluffy clouds in the sky. Instead, the cloud represents a network of remote servers connected by wires and cables.</p>
<p>In the past, businesses used large servers in their offices to store data, which took up a lot of space. While that still works, imagine having powerful software, lots of storage, and computing resources, without needing a room full of machines. That sounds great! Having an organized space can make you feel calm and focused, and that’s what cloud computing offers.</p>
<p>Today, we can store our pictures, videos, emails, and data in the cloud instead of using boxes and drives like we used to. Major cloud providers like AWS, Microsoft Azure, and Google Cloud allow us to store and access our data from anywhere.</p>
<p>In this article, I’ll explain cloud computing, how it works, and why it’s important for businesses and everyday people.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-what-is-cloud-computing-and-how-does-it-work">What is Cloud Computing and How Does It Work?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-who-are-the-leading-cloud-providers">Who Are the Leading Cloud Providers?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-types-and-models-of-cloud-services">Types and Models of Cloud Services</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-real-world-uses-of-cloud-services">Real-World Uses of Cloud Services</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-do-developers-use-the-cloud">How Do Developers Use the Cloud?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-why-is-cloud-computing-important">Why is Cloud Computing Important?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-what-do-you-need-to-know-to-use-the-cloud">What Do You Need to Know to Use the Cloud?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ul>
<h2 id="heading-what-is-cloud-computing-and-how-does-it-work">What is Cloud Computing and How Does It Work?</h2>
<p>Cloud computing is a process where technology services like storage, databases, computing power, and software are delivered over the Internet. In simple terms, it means using the internet to access storage, apps, or tools on powerful computers that aren’t in your organization. Instead of needing large storage or high-powered equipment yourself, you can connect online to store files, watch movies, or work on projects.</p>
<p>In cloud computing, the three basic functions are:</p>
<ol>
<li><p><strong>Storage:</strong> This lets you save and keep your data online, like using Google Drive or Dropbox for your files.</p>
</li>
<li><p><strong>Computing:</strong> This provides the power to process tasks, similar to how a computer's CPU works. It helps run applications smoothly.</p>
</li>
<li><p><strong>Database:</strong> This stores organized data. For example, services like Amazon RDS or Google Cloud SQL manage information for apps.</p>
</li>
</ol>
<h2 id="heading-who-are-the-leading-cloud-providers">Who Are the Leading Cloud Providers?</h2>
<p>Cloud providers offer the infrastructure and services needed to deploy and scale applications.</p>
<p>Big companies like Amazon Web Service (AWS), Google (Google Cloud), and Microsoft (Azure) are leading providers in the cloud industry.</p>
<p>Below is a summary of each provider:</p>
<ul>
<li><p><strong>Amazon Web Services (AWS):</strong> AWS is a leading cloud provider, offering a wide range of services including cloud storage (S3), databases (RDS), and machine learning tools. It’s known for its scalability, flexibility, and reliability, making it a popular choice for developers and businesses.</p>
</li>
<li><p><strong>Microsoft (Azure):</strong> Microsoft has been around for 45 years, and over time, they've adapted their software like Microsoft Office and Windows, seamlessly integrating these services with the cloud. They provide services like Azure Blob Storage and Azure SQL Database. As a result, Microsoft is considered one of the top cloud providers.</p>
</li>
<li><p><strong>Google (Google Cloud):</strong> Google Cloud offers powerful services like Google BigQuery for data analytics and Google Anthos for managing hybrid applications. Google Cloud is known for its speed and reliability, and provides tools for storage, computing, and database management, making it a solid choice for businesses.</p>
</li>
</ul>
<p>All these cloud providers rent out powerful computers to individuals and businesses, allowing you to store files, use apps, or run a business without needing your own servers and equipment.</p>
<h2 id="heading-types-and-models-of-cloud-services">Types and Models of Cloud Services</h2>
<p>Due to the powerful features of cloud services, some companies prefer to control certain parts themselves. This brings us to three types of service control in cloud computing:</p>
<ol>
<li><p><strong>Infrastructure as a Service (IaaS):</strong><br> Think of IaaS as renting a computer online. You can practice coding or run a website without buying any hardware. For example, you can rent a powerful server from AWS. With IaaS, you have full control over everything. You can choose the operating system and install the software you need.</p>
</li>
<li><p><strong>Platform as a Service (PaaS):</strong><br> PaaS is like having a complete workshop online. It gives you the tools to build and launch projects, like a mobile app. You can create your applications, but the provider handles the servers and storage. This way, you can focus on building your app without worrying about the technical details.</p>
</li>
<li><p><strong>Software as a Service (SaaS):</strong><br> SaaS lets you use software directly on the internet. For example, you can write documents using Google Docs, or practice coding with Replit. With SaaS, you have limited control. You can change some settings, but the provider handles everything else, like maintenance and updates.</p>
</li>
</ol>
<p>These options help businesses decide how much control they want over cloud services.</p>
<h2 id="heading-real-world-uses-of-cloud-services">Real-World Uses of Cloud Services</h2>
<p>Here are some examples of using cloud services in real life:</p>
<ul>
<li><p>When you watch Netflix, you’re using the cloud. Netflix keeps movies on its cloud servers and streams them to you online, so there’s no need to download anything.</p>
</li>
<li><p>Services like Google Drive and Dropbox let you store files in the cloud instead of on your computer. This way, you can access your files from any device with internet access.</p>
</li>
<li><p>With Google Docs, you can create and edit documents in the cloud. You don’t need to install anything on your computer. You can even collaborate with others in real-time.</p>
</li>
</ul>
<h2 id="heading-how-do-developers-use-the-cloud">How Do Developers Use the Cloud?</h2>
<p>Cloud services play a key role in development:</p>
<ul>
<li><p>Cloud services like Amazon Web Service (AWS) and Google Cloud provide development tools, virtual environments, and analytics services which developers can use to test their application.</p>
</li>
<li><p>Getting applications online is made easy with services like <a target="_blank" href="https://aws.amazon.com/amplify/?gclid=Cj0KCQiArby5BhCDARIsAIJvjIQhZ0XF6IF-Pb0N8FNn76tRMfP2CfP_X_fC9xyUgegvLSmLQUhPfFsaApkrEALw_wcB&amp;trk=e37f908f-322e-4ebc-9def-9eafa78141b8&amp;sc_channel=ps&amp;ef_id=Cj0KCQiArby5BhCDARIsAIJvjIQhZ0XF6IF-Pb0N8FNn76tRMfP2CfP_X_fC9xyUgegvLSmLQUhPfFsaApkrEALw_wcB:G:s&amp;s_kwcid=AL!4422!3!647301987538!e!!g!!aws%20amplify!19613610159!148358959849"><strong>AWS Amplify</strong></a>, which allow developers to host their apps without writing the backend code.</p>
</li>
<li><p>Cloud storage allows developers to easily add extra storage as needed while keeping data safe and accessible from any location.</p>
</li>
<li><p>Services like Google TensorFlow and AWS SageMaker offer resources for quickly developing AI and machine learning projects.</p>
</li>
</ul>
<h2 id="heading-why-is-cloud-computing-important">Why is Cloud Computing Important?</h2>
<p>Cloud computing offers several key benefits:</p>
<ul>
<li><p>For businesses that want to save money, cloud computing helps cut out expensive hardware and maintenance. You only pay for what you use, like creating virtual servers or storing files.</p>
</li>
<li><p>Storing data or files in the cloud can help you easily increase or decrease your resources based on your needs. This flexibility lets businesses adapt quickly to changes—for example, an increase in Black Friday sales or Boxing Day.</p>
</li>
<li><p>In the event of a disaster, such as a fire, storing files in the cloud serves as a reliable backup, ensuring that important information is not lost. This is especially beneficial for hospitals and government agencies.</p>
</li>
<li><p>Using cloud service enhances collaboration among workers and ease of getting a file since it is remote.</p>
</li>
<li><p>Most cloud providers offer fast services, which leads to quicker load times.</p>
</li>
<li><p>Cloud services are secure.</p>
</li>
</ul>
<h2 id="heading-what-do-you-need-to-know-to-use-the-cloud">What Do You Need to Know to Use the Cloud?</h2>
<ul>
<li><p>To start using the cloud, you should learn basics like virtual machines, storing data, networking, and security.</p>
</li>
<li><p>Understand how to back up your data and recover it in case of any issues.</p>
</li>
<li><p>Learn how pricing works in the cloud so you can monitor and manage your costs effectively.</p>
</li>
<li><p>Most cloud platforms offer tutorials, tools, and ready-made services to make them easier to understand and speed up development.</p>
</li>
</ul>
<p>It can be overwhelming at first, but just start with the basic services, and everything else will fall into place.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In conclusion, cloud computing is changing the way businesses work and how we store and manage data. It offers flexibility, minimizes cost, and leads to easy collaboration, while improving backup and recovery.</p>
<p>As cloud technology continues to grow, it will become even more important for both individuals and businesses. Whether you're storing personal files or managing a big company, the cloud makes it simpler, safer, and more affordable.</p>
<p>If you found this article helpful, share it with others who may find it interesting.</p>
<p>Stay updated with my projects by following me on <a target="_blank" href="https://https//twitter.com/ijaydimples">Twitter</a>, <a target="_blank" href="https://www.linkedin.com/in/ijeoma-igboagu/">LinkedIn</a> and <a target="_blank" href="https://github.com/ijayhub">GitHub</a>.</p>
<p>Thank you for reading.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Authenticate Your React App Using Firebase ]]>
                </title>
                <description>
                    <![CDATA[ Authentication is a fundamental aspect of modern web and mobile applications. It ensures that users can securely access an app while protecting their data. Firebase, a platform developed by Google, offers a simple and efficient way to add authenticat... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/authenticate-react-app-using-firebase/</link>
                <guid isPermaLink="false">66fca32291d1f0e8dbe5d676</guid>
                
                    <category>
                        <![CDATA[ authentication ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Firebase ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ijeoma Igboagu ]]>
                </dc:creator>
                <pubDate>Wed, 02 Oct 2024 01:34:26 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/Uw_8vSroCSc/upload/a8799e4ad43b3b8fe966910f9171ccd3.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Authentication is a fundamental aspect of modern web and mobile applications. It ensures that users can securely access an app while protecting their data.</p>
<p>Firebase, a platform developed by Google, offers a simple and efficient way to add authentication to your app.</p>
<p>In this article, I’ll walk you through the steps to authenticate your app using Firebase. Whether you're working on a web or mobile application, Firebase provides a straightforward way to integrate various authentication methods. </p>
<p>By the end of this article, you'll have a fully functional authentication system that allows users to sign up, sign in, and manage their accounts securely.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-table-of-contents">Table of Contents</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-prerequisites">Prerequisites</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-why-use-firebase-for-authentication">Why Use Firebase for Authentication?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-1-how-to-set-up-a-firebase-project">Step 1: How to Set Up a Firebase Project</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-2-how-to-install-firebase-in-your-project">Step 2: How to Install Firebase in Your Project</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-3-how-to-initialize-firebase-in-your-app">Step 3: How to Initialize Firebase in Your App</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-4-how-to-set-up-authentication-methods">Step 4: How to Set Up Authentication Methods</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-authentication-method-using-google">Authentication Method Using Google</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-5-how-to-upload-to-github">Step 5: How to Upload to GitHub</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ul>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>Before we begin, you need to have the following:</p>
<ul>
<li><strong>A Google Account</strong>: Firebase is a Google product, and you need a Google account to access the Firebase Console and use Firebase services. If you don’t have a Google account, <a target="_blank" href="https://support.google.com/mail/answer/56256?hl=en">you can create one here</a>.</li>
</ul>
<h2 id="heading-why-use-firebase-for-authentication"><strong>Why Use Firebase for Authentication?</strong></h2>
<p>Firebase Authentication provides backend services and easy-to-use SDKs to authenticate users to your app. It supports various authentication methods, including:</p>
<ul>
<li><p><strong>Email and password authentication</strong></p>
</li>
<li><p><strong>Google, Facebook, Twitter, and GitHub Authentication</strong></p>
</li>
<li><p><strong>Phone Number Authentication</strong></p>
</li>
<li><p><strong>Anonymous Authentication</strong></p>
</li>
</ul>
<p>These features make Firebase an excellent choice for developers who want to implement secure and reliable authentication without dealing with the complexities of building a custom authentication system.</p>
<p>Let’s get started with the setup!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1727802131211/b57dce67-663e-4c03-baa2-21668b543d68.jpeg" alt="b57dce67-663e-4c03-baa2-21668b543d68" class="image--center mx-auto" width="545" height="360" loading="lazy"></p>
<h2 id="heading-step-1-how-to-set-up-a-firebase-project">Step 1: How to Set Up a Firebase Project</h2>
<p>Before using Firebase Authentication, you need to set up a Firebase project.</p>
<p><strong>i. Create a Firebase Project</strong></p>
<ul>
<li>Go to the <a target="_blank" href="https://firebase.google.com/">Firebase Console.</a></li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1723410569746/560dfa39-e8d5-4b22-bb84-94946daeac08.png" alt="Firebase website" class="image--center mx-auto" width="1920" height="970" loading="lazy"></p>
<ul>
<li>Click "Add Project" and follow the on-screen instructions to create a new project.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1727812540013/eceb505e-ea69-43f0-a845-ad26d86d5c26.gif" alt="Creating a project base" class="image--center mx-auto" width="1920" height="971" loading="lazy"></p>
<p>Once your project is created, you’ll be directed to the Firebase project dashboard.</p>
<p><strong>ii. Add Your App to the Project</strong></p>
<ul>
<li><p>In the Firebase console, click on the "Web" icon (&lt;/&gt;) to add a web app to your Firebase project.</p>
</li>
<li><p>Register your app with a nickname, and click "Register app."</p>
</li>
<li><p>You will be provided with a Firebase SDK snippet (Software Development Kit), which you'll need to add to your app.</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1723412408046/4bf3956f-1d7d-4dff-8a70-72a757c01d2b.gif" alt="Registering your project to firebase" class="image--center mx-auto" width="1920" height="971" loading="lazy"></p>
</li>
</ul>
<h2 id="heading-step-2-how-to-install-firebase-in-your-project"><strong>Step 2: How to Install Firebase in Your Project</strong></h2>
<p>To start with Firebase Authentication, you'll first need to install Firebase in your project. Here's how you can do it:</p>
<ul>
<li><p>In your code editor, open the terminal for your project.</p>
</li>
<li><p>Run the following command to install Firebase:</p>
</li>
</ul>
<pre><code class="lang-javascript">npm install firebase
</code></pre>
<p>This command will add Firebase to your project, allowing you to use its authentication and other features.</p>
<h2 id="heading-step-3-how-to-initialize-firebase-in-your-app"><strong>Step 3: How to Initialize Firebase in Your App</strong></h2>
<p>After installing Firebase, the next step is to initialize it in your project using the configuration snippet provided in the Firebase console, commonly referred to as the Firebase SDK snippet.</p>
<p><strong>To set this up:</strong></p>
<ol>
<li><p>Create a folder named <strong>config</strong> in your project directory.</p>
</li>
<li><p>Inside the folder, create a file called <strong>firebase.js</strong>.</p>
</li>
<li><p>Paste the SDK snippet you obtained from the Firebase console into the <strong>firebase.js</strong> file.</p>
</li>
</ol>
<p>Here’s what your project setup should look like:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1723459271302/4773d484-b5a2-4cbe-9626-76765cafd9b8.png" alt="Pasting the SDK in your project" class="image--center mx-auto" width="1920" height="1079" loading="lazy"></p>
<p>This code initializes Firebase in your app, enabling you to utilize Firebase authentication and other services, such as Firebase storage, for managing your data.</p>
<p><strong>Note:</strong> Ensure you generate your unique application key for your application to function correctly.</p>
<h2 id="heading-step-4-how-to-set-up-authentication-methods"><strong>Step 4: How to Set Up Authentication Methods</strong></h2>
<p>Firebase supports multiple authentication methods, like using Google, Facebook, GitHub, and so on.</p>
<p>But let’s set up email and password authentication as an example:</p>
<ul>
<li><p>Go to "Authentication" in the left-hand menu in the Firebase console.</p>
</li>
<li><p>Click on the "Sign-in method" tab.</p>
</li>
<li><p>Enable "Email/Password" under the "Sign-in providers" section.</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1723457322104/6914efdc-87cf-4fce-b84f-bd407b6b4918.gif" alt="Authentication using email and password" class="image--center mx-auto" width="1920" height="971" loading="lazy"></p>
<p>  Now that you've enabled email/password authentication, you can create a sign-up and a sign-in function in your app.</p>
<p>  Let’s create a working example of a sign-up function:</p>
<ul>
<li><p>In your project, create a file named <strong>sign-up.jsx</strong>.</p>
</li>
<li><p>Import the function needed to create a user from Firebase. The function you'll use to create a user is <code>createUserWithEmailAndPassword</code>.</p>
</li>
<li><p>Before creating a user, make sure to import the auth instance that is initialized in <strong>firebase.js</strong> into the <strong>sign-up.jsx</strong> file.</p>
</li>
</ul>
</li>
</ul>
<pre><code class="lang-javascript">    <span class="hljs-keyword">import</span> { auth } <span class="hljs-keyword">from</span> <span class="hljs-string">'../../../config/firebase'</span>;
    <span class="hljs-keyword">import</span> { createUserWithEmailAndPassword } <span class="hljs-keyword">from</span> <span class="hljs-string">'firebase/auth'</span>;

    <span class="hljs-keyword">const</span> SignUp = <span class="hljs-function">() =&gt;</span> {
      <span class="hljs-comment">// To create the user with email and password</span>
      <span class="hljs-keyword">const</span> handleUser = <span class="hljs-keyword">async</span> (e) =&gt; {
        e.preventDefault();
        <span class="hljs-keyword">try</span> {
          <span class="hljs-keyword">await</span> createUserWithEmailAndPassword(auth, email, password);
          alert(<span class="hljs-string">'User created successfully'</span>);
        } <span class="hljs-keyword">catch</span> (err) {
          <span class="hljs-built_in">console</span>.error(err);
        }
      };

      <span class="hljs-comment">// ... (rest of your SignUp component)</span>
    };
</code></pre>
<p>    In the return statement, I will use a form, so we need to import the <code>useState()</code> Hook to manage and track changes in the form's input fields.</p>
<pre><code class="lang-javascript">    &lt;div&gt;
      <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Register your Account<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span></span>
      <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">onSubmit</span>=<span class="hljs-string">{handleCreateUser}</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span>Name<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
            <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span>
            <span class="hljs-attr">id</span>=<span class="hljs-string">"name"</span>
            <span class="hljs-attr">name</span>=<span class="hljs-string">"name"</span>
            <span class="hljs-attr">value</span>=<span class="hljs-string">{name}</span>
            <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setName(e.target.value)}
          /&gt;
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">"email"</span>&gt;</span>Email<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
            <span class="hljs-attr">type</span>=<span class="hljs-string">"email"</span>
            <span class="hljs-attr">id</span>=<span class="hljs-string">"email"</span>
            <span class="hljs-attr">name</span>=<span class="hljs-string">"email"</span>
            <span class="hljs-attr">value</span>=<span class="hljs-string">{email}</span>
            <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setEmail(e.target.value)}
          /&gt;
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">"password"</span>&gt;</span>Password<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
            <span class="hljs-attr">type</span>=<span class="hljs-string">"password"</span>
            <span class="hljs-attr">id</span>=<span class="hljs-string">"password"</span>
            <span class="hljs-attr">name</span>=<span class="hljs-string">"password"</span>
            <span class="hljs-attr">value</span>=<span class="hljs-string">{password}</span>
            <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setPassword(e.target.value)}
          /&gt;
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">"confirm_password"</span> <span class="hljs-attr">className</span>=<span class="hljs-string">{styles.label}</span>&gt;</span>
            Confirm Password
          <span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
            <span class="hljs-attr">type</span>=<span class="hljs-string">"password"</span>
            <span class="hljs-attr">id</span>=<span class="hljs-string">"confirm_password"</span>
            <span class="hljs-attr">name</span>=<span class="hljs-string">"confirm_password"</span>
            <span class="hljs-attr">value</span>=<span class="hljs-string">{confirmPassword}</span>
            <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setConfirmPassword(e.target.value)}
          /&gt;
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"checkbox"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"terms"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"terms"</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"mr-2"</span> /&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">"terms"</span>&gt;</span>
              I agree to the <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"#"</span>&gt;</span>Terms and Conditions<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
            <span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
          <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"submit"</span>&gt;</span>Register<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span></span>
    &lt;/div&gt;
</code></pre>
<p>    Putting all code together (<strong>Sign-up.jsx</strong>):</p>
<pre><code class="lang-javascript">
    <span class="hljs-keyword">import</span> { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;
    <span class="hljs-keyword">import</span> { auth } <span class="hljs-keyword">from</span> <span class="hljs-string">'../../config/firebase'</span>;
    <span class="hljs-keyword">import</span> { createUserWithEmailAndPassword } <span class="hljs-keyword">from</span> <span class="hljs-string">'firebase/auth'</span>;

    <span class="hljs-keyword">const</span> SignUp = <span class="hljs-function">() =&gt;</span> {
      <span class="hljs-keyword">const</span> [name, setName] = useState(<span class="hljs-string">''</span>);
      <span class="hljs-keyword">const</span> [email, setEmail] = useState(<span class="hljs-string">''</span>);
      <span class="hljs-keyword">const</span> [password, setPassword] = useState(<span class="hljs-string">''</span>);
      <span class="hljs-keyword">const</span> [confirmPassword, setConfirmPassword] = useState(<span class="hljs-string">''</span>);

      <span class="hljs-keyword">const</span> handleCreateUser = <span class="hljs-keyword">async</span> (e) =&gt; {
        e.preventDefault();
        <span class="hljs-keyword">try</span> {
          <span class="hljs-keyword">await</span> createUserWithEmailAndPassword(auth, email, password);
          alert(<span class="hljs-string">'User created successfully'</span>);
        } <span class="hljs-keyword">catch</span> (error) {
          <span class="hljs-built_in">console</span>.log(error);
        }
      };

      <span class="hljs-keyword">return</span> (
        <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Register your Account<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">onSubmit</span>=<span class="hljs-string">{handleCreateUser}</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span>Name<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
                <span class="hljs-attr">type</span>=<span class="hljs-string">'text'</span>
                <span class="hljs-attr">id</span>=<span class="hljs-string">'name'</span>
                <span class="hljs-attr">name</span>=<span class="hljs-string">'name'</span>
                <span class="hljs-attr">value</span>=<span class="hljs-string">{name}</span>
                <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setName(e.target.value)}
              /&gt;
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

            <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">'email'</span>&gt;</span>Email<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
                <span class="hljs-attr">type</span>=<span class="hljs-string">'email'</span>
                <span class="hljs-attr">id</span>=<span class="hljs-string">'email'</span>
                <span class="hljs-attr">name</span>=<span class="hljs-string">'email'</span>
                <span class="hljs-attr">value</span>=<span class="hljs-string">{email}</span>
                <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setEmail(e.target.value)}
              /&gt;
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

            <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">'password'</span>&gt;</span>Password<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
                <span class="hljs-attr">type</span>=<span class="hljs-string">'password'</span>
                <span class="hljs-attr">id</span>=<span class="hljs-string">'password'</span>
                <span class="hljs-attr">name</span>=<span class="hljs-string">'password'</span>
                <span class="hljs-attr">value</span>=<span class="hljs-string">{password}</span>
                <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setPassword(e.target.value)}
              /&gt;
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

            <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">'confirm_password'</span>&gt;</span>
                Confirm Password
              <span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
                <span class="hljs-attr">type</span>=<span class="hljs-string">'password'</span>
                <span class="hljs-attr">id</span>=<span class="hljs-string">'confirm_password'</span>
                <span class="hljs-attr">name</span>=<span class="hljs-string">'confirm_password'</span>
                <span class="hljs-attr">value</span>=<span class="hljs-string">{confirmPassword}</span>
                <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setConfirmPassword(e.target.value)}
              /&gt;
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

            <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
                  <span class="hljs-attr">type</span>=<span class="hljs-string">'checkbox'</span>
                  <span class="hljs-attr">id</span>=<span class="hljs-string">'terms'</span>
                  <span class="hljs-attr">name</span>=<span class="hljs-string">'terms'</span>
                  <span class="hljs-attr">className</span>=<span class="hljs-string">'mr-2'</span>
                /&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">'terms'</span>&gt;</span>
                  I agree to the{' '}
                  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">'#'</span>&gt;</span>
                    Terms and Conditions
                  <span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
                <span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
              <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

            <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'submit'</span>&gt;</span>Register<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
          <span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
      );
    };

    <span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> SignUp;
</code></pre>
<p>    Now that you've created the sign-up function, it's time to add a sign-in function so users can log into your app.</p>
<p>    Here's how to create a simple sign-in function:</p>
<ul>
<li><p>In your project, create a new file named <strong>sign-in.jsx</strong>.</p>
</li>
<li><p>Import the initialized <code>auth</code> instance from <strong>firebase.js</strong> into <strong>sign-in.jsx</strong>.</p>
</li>
<li><p>Use the <code>signInWithEmailAndPassword</code> function from Firebase to allow users to sign in.</p>
</li>
</ul>
<p>Here’s the structure for the sign-in function:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;
<span class="hljs-keyword">import</span> { auth } <span class="hljs-keyword">from</span> <span class="hljs-string">'../../config/firebase'</span>;
<span class="hljs-keyword">import</span> { signInWithEmailAndPassword } <span class="hljs-keyword">from</span> <span class="hljs-string">'firebase/auth'</span>;

<span class="hljs-keyword">const</span> SignIn = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">const</span> [email, setEmail] = useState(<span class="hljs-string">''</span>);
  <span class="hljs-keyword">const</span> [password, setPassword] = useState(<span class="hljs-string">''</span>);

  <span class="hljs-keyword">const</span> handleSignIn = <span class="hljs-keyword">async</span> (e) =&gt; {
    e.preventDefault();
    <span class="hljs-keyword">try</span> {
      <span class="hljs-keyword">await</span> signInWithEmailAndPassword(auth, email, password);
      alert(<span class="hljs-string">'Signed in successfully'</span>);
    } <span class="hljs-keyword">catch</span> (error) {
      <span class="hljs-built_in">console</span>.error(error);
    }
  };

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Sign In<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">onSubmit</span>=<span class="hljs-string">{handleSignIn}</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">"email"</span>&gt;</span>Email<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
            <span class="hljs-attr">type</span>=<span class="hljs-string">"email"</span>
            <span class="hljs-attr">value</span>=<span class="hljs-string">{email}</span>
            <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setEmail(e.target.value)}
          /&gt;
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">"password"</span>&gt;</span>Password<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
            <span class="hljs-attr">type</span>=<span class="hljs-string">"password"</span>
            <span class="hljs-attr">value</span>=<span class="hljs-string">{password}</span>
            <span class="hljs-attr">onChange</span>=<span class="hljs-string">{(e)</span> =&gt;</span> setPassword(e.target.value)}
          /&gt;
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"submit"</span>&gt;</span>Sign In<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
};

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> SignIn;
</code></pre>
<p>The visual display of the result from the code above both sign-up and sign-in</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1727813072045/5a91493d-69a0-4a90-98b2-61905b23e460.gif" alt="Visual Result of signup and signin put together" class="image--center mx-auto" width="1920" height="971" loading="lazy"></p>
<h2 id="heading-authentication-method-using-google">Authentication Method Using Google</h2>
<p>As mentioned earlier, you can collect users' emails directly through a form before they use your app and other ways to authenticate the users.</p>
<p><strong>To use Google authentication:</strong></p>
<ul>
<li><p>In the Firebase console, navigate to "Authentication" in the left-hand menu.</p>
</li>
<li><p>Click on the "Sign-in method" tab.</p>
</li>
<li><p>Enable "Google" under the "Sign-in providers" section (for this tutorial, we'll stick with Google, though you can choose other providers).</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1727813344687/f1838b83-9af9-42a7-bf98-6a7d617cedc3.gif" alt="Enabling Google Auth" class="image--center mx-auto" width="1920" height="971" loading="lazy"></p>
<p>Now that you've enabled Google authentication, you can create a Google sign-up and sign-in function for your app.</p>
<p>Let's go through how to set up a Google sign-up function:</p>
<ul>
<li><p>First, create a file named <strong>Google.jsx</strong> in your project.</p>
</li>
<li><p>Import <code>auth</code> and <code>GoogleAuthProvider</code> from the <strong>firebase.js</strong> file</p>
</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-comment">// Import the functions you need from the SDKs you need</span>
<span class="hljs-keyword">import</span> { initializeApp } <span class="hljs-keyword">from</span> <span class="hljs-string">'firebase/app'</span>;
<span class="hljs-keyword">import</span> { getAuth, GoogleAuthProvider } <span class="hljs-keyword">from</span> <span class="hljs-string">'firebase/auth'</span>;


<span class="hljs-keyword">const</span> firebaseConfig = {
  <span class="hljs-attr">apiKey</span>: ....,
  <span class="hljs-attr">authDomain</span>: ....,
  <span class="hljs-attr">projectId</span>:.... ,
  <span class="hljs-attr">storageBucket</span>: .... ,
  <span class="hljs-attr">messagingSenderId</span>: .... ,
  <span class="hljs-attr">appId</span>: ....,
  <span class="hljs-attr">measurementId</span>: ....,
};
<span class="hljs-comment">// Initialize Firebase</span>
<span class="hljs-keyword">const</span> app = initializeApp(firebaseConfig);
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> auth= getAuth(app);
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> googleProvider = <span class="hljs-keyword">new</span> GoogleAuthProvider(app);
</code></pre>
<ul>
<li>Initialize the Google provider and export it for use in other parts of your application.</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { auth, googleProvider } <span class="hljs-keyword">from</span> <span class="hljs-string">'./firebase'</span>;  <span class="hljs-comment">// Adjust the path to your Firebase config file</span>
<span class="hljs-keyword">import</span> { signInWithPopup } <span class="hljs-keyword">from</span> <span class="hljs-string">'firebase/auth'</span>;
</code></pre>
<ul>
<li>Import the necessary Firebase function to authenticate a user. Use the <code>signInWithPopup</code> method to authenticate users with Google.</li>
</ul>
<p>While there are other authentication methods available, <code>signInWithPopup</code> is preferable as it keeps users within the app, avoiding the need to open a new browser tab.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> signInWithGoogle = <span class="hljs-keyword">async</span> () =&gt; {
  <span class="hljs-keyword">try</span> {
    <span class="hljs-keyword">await</span> signInWithPopup(auth, googleProvider);
    alert(<span class="hljs-string">'Signed in successfully with Google'</span>);
  } <span class="hljs-keyword">catch</span> (error) {
    <span class="hljs-built_in">console</span>.error(<span class="hljs-string">'Error signing in with Google'</span>, error);
  }
};
</code></pre>
<ul>
<li>In your return statement, create a button to trigger the Google sign-in.</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">return</span> (
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{signInWithGoogle}</span>&gt;</span>Sign in with Google<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
);
</code></pre>
<p>The visual display of the result from the code above:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1727813634035/14c00c73-f289-480a-a396-3abd839b3a75.gif" alt="Using signInWithPop()" class="image--center mx-auto" width="1920" height="971" loading="lazy"></p>
<p>Firebase allows you to sign users out of your application easily. Here's how you can implement a sign-out function:</p>
<ul>
<li><p>First, import the <code>signOut</code> function from Firebase.</p>
</li>
<li><p>Once imported, you can call <code>signOut</code> to log the user out of the app.</p>
</li>
</ul>
<p>Here’s a simple example:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { auth } <span class="hljs-keyword">from</span> <span class="hljs-string">'./config/firebase'</span>; <span class="hljs-comment">// Adjust the path based on your file structure</span>
<span class="hljs-keyword">import</span> { signOut } <span class="hljs-keyword">from</span> <span class="hljs-string">'firebase/auth'</span>;

<span class="hljs-keyword">const</span> handleSignOut = <span class="hljs-keyword">async</span> () =&gt; {
  <span class="hljs-keyword">try</span> {
    <span class="hljs-keyword">await</span> signOut(auth);
    alert(<span class="hljs-string">'User signed out successfully'</span>);
  } <span class="hljs-keyword">catch</span> (error) {
    <span class="hljs-built_in">console</span>.error(<span class="hljs-string">'Error signing out:'</span>, error);
  }
};
</code></pre>
<p>With this function, users can easily log out of the app.</p>
<p>In the return statement, you'll typically have a button that triggers the <strong>handleSignOut</strong> function when clicked.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">return</span> (
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Welcome to the app!<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{handleSignOut}</span>&gt;</span>Sign Out<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
</code></pre>
<p>The visual display of the result from the code above</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1727813736679/21c2162b-b376-43b7-87cb-242d78acef38.gif" alt="signOut() visual display" class="image--center mx-auto" width="1920" height="971" loading="lazy"></p>
<p>Make sure your Firebase project is configured to handle authentication correctly, including Google sign-in, to ensure a smooth sign-in and sign-out experience.</p>
<h2 id="heading-step-5-how-to-upload-to-github"><strong>Step 5: How to Upload to GitHub</strong></h2>
<p>Before pushing your project to GitHub, make sure to store your Firebase API key in an environment variable to keep it secure. This will prevent sensitive information from being exposed in your shared code.</p>
<p><strong>Creating a .env file</strong></p>
<ul>
<li>At the root of your application, create a <strong>.env</strong> file.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1727813941388/5e647b8c-c76b-4671-b44b-21ac4dcddc89.png" alt="Storing the API keys in .env file" class="image--center mx-auto" width="1920" height="1079" loading="lazy"></p>
<ul>
<li><p>Add your Firebase API key to the <strong>firebase.js</strong> file.</p>
</li>
<li><p>Use <code>import</code> or <code>process.env</code> to access your Firebase API key. Since the app was created with Vite, I used <code>import</code>.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1727814253953/514db02f-44f8-44fc-b03c-4cf77cb5c4ba.png" alt="Firebase file" class="image--center mx-auto" width="1920" height="1079" loading="lazy"></p>
<ul>
<li>Finally, update your <strong>.gitignore</strong> file to include the <strong>.env</strong> file. This step also protects other sensitive files and directories, like <strong>node_modules</strong>.</li>
</ul>
<pre><code class="lang-javascript"># Logs
logs
node_modules
.env
</code></pre>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In conclusion, this guide explains how to integrate Firebase Authentication into your app. Firebase simplifies adding authentication features such as email/password and Google login.</p>
<p>By setting up a Firebase project, installing, and initializing it in your app, you can efficiently build secure user sign-up and sign-in functionalities without the need to start from scratch or set up a server.</p>
<p>If you found this article helpful, share it with others who may also find it interesting.</p>
<p>Stay updated with my projects by following me on <a target="_blank" href="https://https//twitter.com/ijaydimples">Twitter</a>, <a target="_blank" href="https://www.linkedin.com/in/ijeoma-igboagu/">LinkedIn</a> and <a target="_blank" href="https://github.com/ijayhub">GitHub</a>.</p>
<p>The code I used for this tutorial article can be found on my <a target="_blank" href="https://github.com/ijayhub/authentication-example-tutorial">GitHub</a>.</p>
<p>Thank you for reading.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Get Your MongoDB URL to Connect to Your Node.js Application – A Step-by-Step Guide ]]>
                </title>
                <description>
                    <![CDATA[ In my previous article about building a Node.js application, I didn’t fully explain how to obtain the MongoDB URL, as I wanted to keep the article concise. However, I realized that this information is essential for saving data to MongoDB. In this art... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/get-mongodb-url-to-connect-to-a-nodejs-application/</link>
                <guid isPermaLink="false">66ba7ce339eb4776cdcacc56</guid>
                
                    <category>
                        <![CDATA[ Node.js ]]>
                    </category>
                
                    <category>
                        <![CDATA[ MongoDB ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Developer ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ijeoma Igboagu ]]>
                </dc:creator>
                <pubDate>Mon, 12 Aug 2024 21:21:39 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1723497228942/b766b557-8230-4bef-8392-d3f4f020c1f4.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In my <a target="_blank" href="https://www.freecodecamp.org/news/how-to-build-an-event-app-with-node-js/">previous article about building a Node.js application</a>, I didn’t fully explain how to obtain the MongoDB URL, as I wanted to keep the article concise. However, I realized that this information is essential for saving data to MongoDB.</p>
<p>In this article, I will guide you through the process of getting your MongoDB URL so you can connect your application effectively. By the end of this tutorial, you’ll have a clear understanding of how to retrieve your MongoDB URL.</p>
<h2 id="heading-lets-get-started">Let's get started! 🚀</h2>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/08/drum-roll-3.gif" alt="A drum indicating let's get started" width="600" height="400" loading="lazy"></p>
<h2 id="heading-step-1-search-for-mongodb-or-visit-their-website">Step 1:  Search for MongoDB or Visit their Website</h2>
<p>To begin, head to the <a target="_blank" href="https://www.mongodb.com">MongoDB</a> website.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/08/mongodb-website.png" alt="Mongodb website" width="600" height="400" loading="lazy"></p>
<h2 id="heading-step-2-click-on-the-sign-in-button-on-their-website">Step 2: Click on the Sign In button on their website.</h2>
<p>This will redirect you to the MongoDB login page. If you don’t have an account yet, you can create one by selecting the <strong>Sign Up</strong> option instead. Since I already have an account, I will log in to access my MongoDB dashboard.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/08/sigin-mongodb.gif" alt="Redirection to login or signup page of mongodb" width="600" height="400" loading="lazy"></p>
<h2 id="heading-step-3-access-the-dashboard">Step 3: Access the Dashboard</h2>
<p>Once you log in, you'll have access to the dashboard. But first, you need to create a project folder.</p>
<h3 id="heading-why-do-you-need-a-project-folder">Why Do You Need a Project Folder?</h3>
<p>This is for organizational purposes, helping you keep track of which projects you are working on.</p>
<p><strong>To create a project folder</strong></p>
<ul>
<li><p>Click on the <strong>Projects</strong> section at the top, indicated by a folder icon. This will reveal a dropdown menu.</p>
</li>
<li><p>From the dropdown, click on <strong>New Project</strong>. This will redirect you to a page where you can create your new project.</p>
</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/08/use-mongodb.gif" alt="Create a new project" width="600" height="400" loading="lazy"></p>
<ul>
<li>Click the <strong>Next</strong> button to proceed to the project creation page.</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/08/create-project.png" alt="Creating a project continues" width="600" height="400" loading="lazy"></p>
<p>After creating your project, you will be redirected back to your dashboard, where you will see your newly created project folder. You can now start working on this specific project.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/08/project-created-mongodb-1.png" alt="Going back to the dashboard" width="600" height="400" loading="lazy"></p>
<h2 id="heading-step-4-creating-a-cluster">Step 4: Creating a Cluster</h2>
<p>To obtain the MongoDB connection URL, it is essential to create a <strong>Cluster</strong>.</p>
<h3 id="heading-what-is-a-cluster">What is a cluster?</h3>
<p>A cluster in MongoDB is a group of servers that work together to store and manage your data, providing high availability and scalability.</p>
<p><strong>To create a cluster:</strong></p>
<ol>
<li><p>On your dashboard, click on the <strong>Clusters</strong> button as shown in the picture of <strong>Step 3</strong> above.</p>
</li>
<li><p>Next, this will direct you to a page called "<strong>Deploy your cluster</strong>" where you get to create your cluster.</p>
</li>
</ol>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/08/cluster-mongoDB.gif" alt="Creating a cluster" width="600" height="400" loading="lazy"></p>
<h2 id="heading-step-5-create-a-username-for-your-connection-url">Step 5: Create a Username for Your Connection URL</h2>
<p>After creating a cluster, you will be taken to a page where you need to create a username and password for the connection URL. The password can be autogenerated, or you can create your own.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/08/creating-a-username-for-mongodb.png" alt="Creating Username and password" width="600" height="400" loading="lazy"></p>
<h3 id="heading-why-do-i-have-to-create-a-username">Why Do I Have to Create a Username?</h3>
<p>Creating a username is essential for managing access to your MongoDB cluster. A username, along with a password, ensures that only authorized users can access your database. This adds a layer of security, protecting your data from unauthorized access.</p>
<h3 id="heading-benefits-of-creating-a-username">Benefits of creating a username:</h3>
<ul>
<li><p><strong>Security:</strong> Ensures that your database is only accessible to those with the correct credentials.</p>
</li>
<li><p><strong>Management:</strong> You can track who is accessing your database and manage permissions.</p>
</li>
<li><p><strong>Accountability:</strong> Helps in auditing and monitoring activities within your database.</p>
</li>
</ul>
<h2 id="heading-step-6-auto-generation-of-the-mongodb-connection-url">Step 6: Auto Generation  of The MongoDB Connection URL</h2>
<p>Once you click the <strong>Create User</strong> button, you will be redirected to a page where your connection URL is automatically generated. Copy this URL and paste it into your <code>.env</code> file to establish a connection to your database. Alternatively, you can paste it directly into your <code>app.js</code> or <code>server.js</code> file, as I <a target="_blank" href="https://www.freecodecamp.org/news/how-to-build-an-event-app-with-node-js/">explained in my previous article</a>.</p>
<p>Feel free to let me know if you need assistance!</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/08/getting-the-strringt-fot-conn.png" alt="Automatic generation of the URL" width="600" height="400" loading="lazy"></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>By following the steps outlined in this article, you should now understand how to obtain your MongoDB connection URL. Remember, creating a username and password for your database access is crucial for ensuring the security and management of your data.</p>
<p>If you encounter any challenges along the way, don't hesitate to refer back to this guide, ask questions or better still consult the official <a target="_blank" href="https://www.mongodb.com/resources/products/fundamentals/basics">MongoDB documentation</a> for further assistance.</p>
<p>If you found this article helpful, share it with others who may also find it interesting.</p>
<p>Stay updated with my projects by following me on <a target="_blank" href="https://https//twitter.com/ijaydimples">Twitter</a>, <a target="_blank" href="https://www.linkedin.com/in/ijeoma-igboagu/">LinkedIn</a> and <a target="_blank" href="https://github.com/ijayhub">GitHub</a>.</p>
<p>Thank you for reading💖.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Build an Application With Node.js ]]>
                </title>
                <description>
                    <![CDATA[ Node.js it’s a runtime environment that allows you to run JavaScript code on the server side for building server-side applications. It works well for creating fast and scalable applications. In this article, I will use a simple event management app a... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-build-an-event-app-with-node-js/</link>
                <guid isPermaLink="false">66b9f47353d7ef738812303f</guid>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ node js ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ijeoma Igboagu ]]>
                </dc:creator>
                <pubDate>Mon, 05 Aug 2024 17:56:13 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1741114813767/a2786471-5a6a-4450-bdb1-f7d1162c2a90.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Node.js it’s a runtime environment that allows you to run JavaScript code on the server side for building server-side applications. It works well for creating fast and scalable applications.</p>
<p>In this article, I will use a simple event management app as an example to show you how to build an application using Node.js, Express.js, and MongoDB.</p>
<p>By the end, you’ll know how to set up a Node.js project, create a server with Express.js, show dynamic pages with embedded JavaScript, and connect to a MongoDB database to handle your data.</p>
<h3 id="heading-what-youll-learn">What You'll Learn</h3>
<ul>
<li><p>Setting up a Node.js project</p>
</li>
<li><p>Creating a server with Express.js</p>
</li>
<li><p>Rendering dynamic pages with ejs</p>
</li>
<li><p>Connecting to a MongoDB database</p>
</li>
<li><p>Creating models and schemas for your data</p>
</li>
<li><p>Handling HTTP requests and responses</p>
</li>
</ul>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><p><a class="post-section-overview" href="#step-1-set-up-your-development-environment%22">Set Up Your Development Environment</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-2-set-up-the-server">Set Up the Server</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-3-install-and-set-up-expressjs">Install and Set Up Express.js</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-4-create-a-dynamic-template">Create a Dynamic Template</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-5-save-your-data-to-mongodb">Save Your Data to MongoDB</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-6-connect-to-the-database">Connect to the Database</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-7-create-the-model-for-the-document-structure">Create the Model for the Document Structure</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-8-create-html-pages">Create HTML Pages</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-9-create-partials">Create Partials</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-10-create-an-environment-variable-file-env">Create an Environment Variable File</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-further-steps">Further Steps</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/07/image-56.png" alt="Let's get started 🚀" width="600" height="400" loading="lazy"></p>
<p><em>Let's get started 🚀</em></p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<ul>
<li><p><a target="_blank" href="https://nodejs.org/en">Node.js</a> installed on your system.</p>
</li>
<li><p>A good understanding of <a target="_blank" href="https://www.mongodb.com/">MongoDB</a>.</p>
</li>
<li><p>A code editor that you prefer, such as <a target="_blank" href="https://code.visualstudio.com/">Visual Studio Code</a> or <a target="_blank" href="https://www.sublimetext.com/download">Sublime Text</a>.</p>
</li>
</ul>
<h2 id="heading-step-1-set-up-your-development-environment">Step 1: Set Up Your Development Environment</h2>
<h3 id="heading-install-nodejs-and-npm">Install Node.js and npm</h3>
<p>First, you'll need to download and install Node.js from <a target="_blank" href="https://nodejs.org/">nodejs.org</a>. Then you can verify the installation by running: <code>node -v</code> and <code>npm -v</code>.</p>
<h3 id="heading-initialize-a-new-project">Initialize a New Project</h3>
<p>Create a new directory for your project. Then initialize the project with npm: <code>npm init -y</code> in your terminal.</p>
<pre><code class="lang-js">mkdir event-app
cd event-app
npm init -y
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/07/ShareX_OnHiLv8GvS-1.gif" alt="Initializing the project" width="600" height="400" loading="lazy"></p>
<p><em>Initializing the project</em></p>
<p>Running <code>npm init -y</code> creates the <code>package.json</code> file, as shown above. This file is crucial. It stores and tracks all third-party libraries (dependencies) needed for your application.</p>
<h2 id="heading-step-2-set-up-the-server">Step 2: Set Up the Server</h2>
<p>To set up your server, create a file called <code>server.js</code> or <code>app.js</code>. These are common names. They are used for their descriptive nature. But, you can name the file whatever you prefer.</p>
<p>The <code>server.js</code> file will be used to create a server which will be used to manage, control, and route to the necessary page in our application.</p>
<h2 id="heading-step-3-install-and-set-up-expressjs">Step 3: Install and Set Up Express.js</h2>
<p>Express.js is a popular web application framework for Node.js and a third-party library that we use in our application.</p>
<p>Express simplifies the handling and definition of various routes for HTTP requests. It enables you to manage the application's routing and connect it to the server.</p>
<h3 id="heading-to-use-express">To use Express:</h3>
<p>Install Express.js by running the following command in your terminal:</p>
<pre><code class="lang-javascript">npm install express
</code></pre>
<p>Require Express in your <code>server.js</code> file.</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> express = <span class="hljs-built_in">require</span>(<span class="hljs-string">'express'</span>)
</code></pre>
<p>Initialize Express so you can use it in your application.</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> app = express()
</code></pre>
<p>Create a routing path to get the HTTP request.</p>
<pre><code class="lang-javascript"><span class="hljs-comment">//routing path</span>
app.get(<span class="hljs-string">'/'</span>, <span class="hljs-function">(<span class="hljs-params">req, res</span>) =&gt;</span> {
  res.send(<span class="hljs-string">'Hello World!'</span>);
});
</code></pre>
<p>Lastly, we need to ensure that the connection to the server is set up correctly. When we start the server in the terminal, it will open in the browser.</p>
<p>To do this, use the <code>listen()</code> method.</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// Start the server</span>
app.listen(<span class="hljs-number">3000</span>, <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Server started on port 3000'</span>);
});
</code></pre>
<p>This method will <code>listen()</code> to requests from the server.</p>
<p><strong>Here's the complete code process:</strong></p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> express = <span class="hljs-built_in">require</span>(<span class="hljs-string">'express'</span>);


<span class="hljs-comment">// Next initialize the application</span>
<span class="hljs-keyword">const</span> app = express();

<span class="hljs-comment">// routing path</span>
app.get(<span class="hljs-string">'/'</span>, <span class="hljs-function">(<span class="hljs-params">req, res</span>) =&gt;</span> {
  res.send(<span class="hljs-string">'Hello World!'</span>);
});

<span class="hljs-comment">// Start the server</span>
app.listen(<span class="hljs-number">3000</span>, <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Server started on port 3000'</span>);
});
</code></pre>
<p><strong>Note:</strong> The routing path above was only for testing purposes to confirm that the server is working and connected. We will provide a different file for the event app we are creating.</p>
<p>With Express.js installed in your application, you can now create a server that will handle all your routing and connections.</p>
<p>To start the server, go to your terminal.</p>
<p>Use the keyword <code>node</code>, then type <code>--watch</code>, a flag to start and automatically restart the server whenever you make changes:</p>
<pre><code class="lang-javascript">node --watch server.js
</code></pre>
<p>Or you can install <code>[nodemon](https://www.npmjs.com/package/nodemon)</code> for the same purpose. <code>Nodemon</code> detects changes in the directory and restarts your application.</p>
<pre><code class="lang-javascript">npm install -g nodemon
</code></pre>
<p>Then run your server with:</p>
<pre><code class="lang-javascript">nodemon server.js
</code></pre>
<h2 id="heading-step-4-create-a-dynamic-template">Step 4: Create a Dynamic Template</h2>
<p>We need a templating engine to render <code>HTML</code> code in the browser using Node.js. We'll use ejs <strong>(Embedded JavaScript)</strong> for this tutorial but there are others such as <a target="_blank" href="https://pugjs.org/api/getting-started.html">Pug (formerly known as Jade)</a> and <a target="_blank" href="https://www.npmjs.com/package/express-handlebars">Express Handlebar</a>, which also render HTML on the server.</p>
<p><code>ejs</code> allows you to embed JavaScript in HTML to create dynamic web pages.</p>
<p>To install <code>ejs</code>, run:</p>
<pre><code class="lang-bash">npm install ejs
</code></pre>
<p>To set up <code>ejs</code> in <code>server.js</code>, require and set <code>ejs</code> as the templating engine:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/07/image-51.png" alt="requiring ejs template in our application" width="600" height="400" loading="lazy"></p>
<p><em>Requiring</em> <code>ejs</code> template in your application</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> express = <span class="hljs-built_in">require</span>(<span class="hljs-string">'express'</span>);
<span class="hljs-keyword">const</span> app = express();

app.set(<span class="hljs-string">'view engine'</span>, <span class="hljs-string">'ejs'</span>);
</code></pre>
<p>With this setup, you can now enable dynamic rendering of <code>HTML</code> code in your Node.js application.</p>
<h2 id="heading-step-5-save-your-data-to-mongodb">Step 5: Save Your Data to MongoDB</h2>
<p>To save the data you create for your application, you will use MongoDB.</p>
<p>MongoDB is a "Not Only SQL" (NoSQL) database that's designed for storing document collections. Traditional SQL databases organize data into tables, but MongoDB is optimised for handling large volumes of data.</p>
<p>To read more about this, <a target="_blank" href="https://www.mongodb.com/resources/basics/databases/nosql-explained">check out this article</a>.</p>
<h2 id="heading-step-6-connect-to-the-database">Step 6: Connect to the Database</h2>
<p>Now we need to connect to the database which will be MongoDB for this tutorial.</p>
<p>Using MongoDB provides you with a Uniform Resource Locator (URL) to connect to your application. This URL connect you and acts as a communicator between the database and your application.</p>
<h3 id="heading-how-to-get-the-url">How to get the URL</h3>
<p>To get the URL, follow these simple steps:</p>
<ol>
<li><p><strong>Sign Up/Log In</strong>: Go to the <a target="_blank" href="https://www.mongodb.com/">MongoDB website</a> and sign up for an account or log in if you already have one.</p>
</li>
<li><p><strong>Create a Cluster</strong>: Once logged in, create a new cluster. This will set up your database.</p>
</li>
<li><p><strong>Connect to Your Cluster</strong>: After your cluster is created, click the "Connect" button.</p>
</li>
<li><p><strong>Choose a Connection Method</strong>: Select "Connect your application".</p>
</li>
<li><p><strong>Copy the Connection String</strong>: MongoDB will provide a connection string (URL) like this:</p>
</li>
</ol>
<pre><code class="lang-js">mongodb+srv:<span class="hljs-comment">//&lt;username&gt;:&lt;password&gt;@cluster0.mongodb.net/&lt;dbname&gt;?retryWrites=true&amp;w=majority</span>
</code></pre>
<ol start="6">
<li><strong>Replace the Placeholders</strong>: Replace <code>&lt;username&gt;</code>, <code>&lt;password&gt;</code>, and <code>&lt;dbname&gt;</code> with your actual username, password, and database name.</li>
</ol>
<p>Now that you have the URL, you can easily connect to your database.</p>
<p>To make this connection easier, we will use a tool called Mongoose.</p>
<h3 id="heading-what-is-mongoose">What is Mongoose?</h3>
<p><a target="_blank" href="https://mongoosejs.com/">Mongoose</a> is a JavaScript library that makes it easier to work with MongoDB in a Node.js environment. It provides a simple way to model your data. You can define schemas, do data validation, and build queries as well.</p>
<h3 id="heading-how-to-make-a-connection">How to make a connection</h3>
<p>MongoDB has already provided you with a URL for connection. Now you'll use Mongoose to send your documents to the database.</p>
<p>To use Mongoose in your project, follow these steps:</p>
<p>Install Mongoose using npm.</p>
<pre><code class="lang-js">npm i mongoose
</code></pre>
<p>In your <code>server.js</code> file, you need to require Mongoose to use it as a connector to the database.</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> mongoose = <span class="hljs-built_in">require</span>(<span class="hljs-string">'mongoose'</span>);
</code></pre>
<p>After you require Mongoose, you need to define the connection <code>URl</code> provided in your <code>server.js</code> file.</p>
<p><code>server.js</code>:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> mongoose = <span class="hljs-built_in">require</span>(<span class="hljs-string">'mongoose'</span>);

<span class="hljs-comment">// Replace &lt;username&gt;, &lt;password&gt;, and &lt;dbname&gt; with your actual credentials</span>
<span class="hljs-keyword">const</span> dbURL = <span class="hljs-string">'mongodb+srv://&lt;username&gt;:&lt;password&gt;@cluster0.mongodb.net/&lt;dbname&gt;?retryWrites=true&amp;w=majority'</span>;

mongoose
  .connect(process.env.dbURL)
  .then(<span class="hljs-function">(<span class="hljs-params">result</span>) =&gt;</span> {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Connected to MongoDB'</span>);
    app.listen(<span class="hljs-number">3000</span>, <span class="hljs-function">() =&gt;</span> {
      <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Server started on port 3000'</span>);
    });
  })
  .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
    <span class="hljs-built_in">console</span>.error(<span class="hljs-string">'Could not connect to MongoDB:'</span>, err);
  });
</code></pre>
<p>This setup ensures that Mongoose acts as the connector. It connects your application to the MongoDB database.</p>
<h2 id="heading-step-7-create-the-model-for-the-document-structure">Step 7: Create the Model for the Document Structure</h2>
<p>Next, we need to create a model document called a Schema so that when you post data to your database it will be saved accordingly.</p>
<p>To create this model:</p>
<ol>
<li><p>Create a folder named <code>models</code> to keep your application organized.</p>
</li>
<li><p>Inside the <code>model's</code> folder, create a file called <code>event.js</code>.</p>
</li>
</ol>
<p>In the<code>event.js</code> file, you will use Mongoose to define the schema for the event documents. You'll specify the structure and data types for the documents you will send to your database.</p>
<p>Here's the <code>event.js</code> file created inside the <code>model</code> folder:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> mongoose = <span class="hljs-built_in">require</span>(<span class="hljs-string">'mongoose'</span>);

<span class="hljs-comment">// Schema</span>
<span class="hljs-keyword">const</span> EventSchema = <span class="hljs-keyword">new</span> mongoose.Schema(
  {
    <span class="hljs-attr">title</span>: {
      <span class="hljs-attr">type</span>: <span class="hljs-built_in">String</span>,
      <span class="hljs-attr">required</span>: <span class="hljs-literal">true</span>,
    },
    <span class="hljs-attr">date</span>: {
      <span class="hljs-attr">type</span>: <span class="hljs-built_in">Date</span>,
      <span class="hljs-attr">required</span>: <span class="hljs-literal">true</span>,
    },
    <span class="hljs-attr">organizer</span>: {
      <span class="hljs-attr">type</span>: <span class="hljs-built_in">String</span>,
      <span class="hljs-attr">required</span>: <span class="hljs-literal">true</span>,
    },
    <span class="hljs-attr">price</span>: {
      <span class="hljs-attr">type</span>: <span class="hljs-built_in">String</span>,
      <span class="hljs-attr">required</span>: <span class="hljs-literal">true</span>,
    },
    <span class="hljs-attr">time</span>: {
      <span class="hljs-attr">type</span>: <span class="hljs-built_in">String</span>,
      <span class="hljs-attr">required</span>: <span class="hljs-literal">true</span>,
    },
    <span class="hljs-attr">location</span>: {
      <span class="hljs-attr">type</span>: <span class="hljs-built_in">String</span>,
      <span class="hljs-attr">required</span>: <span class="hljs-literal">true</span>,
    },
    <span class="hljs-attr">description</span>: {
      <span class="hljs-attr">type</span>: <span class="hljs-built_in">String</span>,
      <span class="hljs-attr">required</span>: <span class="hljs-literal">true</span>,
    },
  },
  { <span class="hljs-attr">timestamps</span>: <span class="hljs-literal">true</span> }
);

<span class="hljs-keyword">const</span> Event = mongoose.model(<span class="hljs-string">'event'</span>, EventSchema);

<span class="hljs-built_in">module</span>.exports = Event;
</code></pre>
<p>When this is done, export so you can use it in your <code>server.js</code> file by simply using the <strong>require keyword</strong>.</p>
<p>With the schema created, it can now be exported to the <code>server.js</code> file.</p>
<p>Your <code>server.js</code> will look like this:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> express = <span class="hljs-built_in">require</span>(<span class="hljs-string">'express'</span>);
<span class="hljs-keyword">const</span> ejs = <span class="hljs-built_in">require</span>(<span class="hljs-string">'ejs'</span>);
<span class="hljs-keyword">const</span> mongoose = <span class="hljs-built_in">require</span>(<span class="hljs-string">'mongoose'</span>);
<span class="hljs-keyword">const</span> Event = <span class="hljs-built_in">require</span>(<span class="hljs-string">'../models/Events'</span>);<span class="hljs-comment">// the event.js file</span>
</code></pre>
<h2 id="heading-step-8-create-html-pages">Step 8: Create HTML Pages</h2>
<p>As we talked about earlier, we're using <code>ejs</code> in step 4 to render <code>HTML</code> code, allowing us to view the code in the browser.</p>
<h3 id="heading-form-page">Form Page</h3>
<p>First, let's create a form page. With the form page created, you'll be able to make POST requests which will enable you to send data to your MongoDB database.</p>
<p>To create a basic form, ensure it includes:</p>
<ul>
<li><p>An <code>action</code> attribute which specifies the route to send the data.</p>
</li>
<li><p>A <code>method</code> attribute which specifies the HTTP request method – in this case, the POST request.</p>
</li>
</ul>
<p>A basic form:</p>
<pre><code class="lang-js">&lt;form action=<span class="hljs-string">"/submit-event"</span> method=<span class="hljs-string">"POST"</span>&gt;
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Event Creation Form<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span></span>
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"title"</span>&gt;</span>Title<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span></span>
  &lt;input type="text" id="title" name="title" required&gt;

  &lt;label for="date"&gt;Date&lt;/label&gt;
  &lt;input type="date" id="date" name="date" required&gt;

  &lt;label for="organizer"&gt;Organizer&lt;/label&gt;
  &lt;input type="text" id="organizer" name="organizer" required&gt;

  &lt;label for="price"&gt;Price&lt;/label&gt;
  &lt;input type="text" id="price" name="price" required&gt;

  &lt;label for="time"&gt;Time&lt;/label&gt;
  &lt;input type="text" id="time" name="time" required&gt;

  &lt;label for="location"&gt;Location&lt;/label&gt;
  &lt;input type="text" id="location" name="location" required&gt;

  &lt;label for="description"&gt;Description&lt;/label&gt;
  &lt;textarea id="description" name="description" rows="4" required&gt;&lt;/textarea&gt;

  &lt;button type="submit"&gt;Submit&lt;/button&gt;
&lt;/form&gt;
</code></pre>
<p>NB: Make sure to add the <strong>name</strong> attribute to each input, or it won't post.</p>
<p>The form created above will let you post data to the specified route. You will then process and store it in your database.</p>
<p><strong>Here's the result:</strong></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/07/image-53.png" alt="The form page" width="600" height="400" loading="lazy"></p>
<p><em>The form page</em></p>
<p>After creating the form page, we need to go back to the <code>server.js file</code> and create a POST request to handle the form submission.</p>
<p><code>server.js</code> file:</p>
<pre><code class="lang-js"><span class="hljs-comment">// posting a data</span>

app.post(<span class="hljs-string">'/submit-event'</span>, <span class="hljs-function">(<span class="hljs-params">req, res</span>) =&gt;</span> {
  <span class="hljs-keyword">const</span> event = <span class="hljs-keyword">new</span> Event(req.body);
  event.save()
    .then(<span class="hljs-function">(<span class="hljs-params">result</span>) =&gt;</span> {
      res.redirect(<span class="hljs-string">'/'</span>);
    })
    .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
      <span class="hljs-built_in">console</span>.error(err);
    });
});
</code></pre>
<h3 id="heading-the-homepage">The Homepage</h3>
<p>Now that the form can post data to the database, we can create the homepage to display the created events in the browser.</p>
<p>First, in your <code>server.js</code> file, you need to create a function. It will fetch all the events posted from the form and stored in the database.</p>
<p>Here’s how to set it up:</p>
<p>This is a function created at <code>server.js</code> to fetch all data from the database:</p>
<pre><code class="lang-js"><span class="hljs-comment">// To get all the event</span>

router.get(<span class="hljs-string">'/'</span>, <span class="hljs-function">(<span class="hljs-params">req, res</span>) =&gt;</span> {
  Event.find()
    .then(<span class="hljs-function">(<span class="hljs-params">result</span>) =&gt;</span> {
      res.render(<span class="hljs-string">'index'</span>, { <span class="hljs-attr">title</span>: <span class="hljs-string">'All event'</span>, <span class="hljs-attr">events</span>: result })
    })
    .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
      <span class="hljs-built_in">console</span>.error(err); 
  })
})
</code></pre>
<p>Next, we will dynamically loop through each part using a <code>forEach</code> loop in the homepage file. Since we are using <code>ejs</code>, the <code>HTML</code> file extension will be <code>.ejs</code>.</p>
<pre><code class="lang-js">&lt;div&gt;
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>All events<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span></span>
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">%</span> <span class="hljs-attr">if</span> (<span class="hljs-attr">events.length</span> &gt;</span> 0) { %&gt;
      <span class="hljs-tag">&lt;<span class="hljs-name">%</span> <span class="hljs-attr">events.forEach</span>(<span class="hljs-attr">event</span> =&gt;</span> { %&gt;
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">h3</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">%=</span> <span class="hljs-attr">event.title</span> %&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h3</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">%=</span> <span class="hljs-attr">event.description</span> %&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"/event/&lt;%= event.id %&gt;"</span>&gt;</span>
            Read More
          <span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">%</span> }) %&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">%</span> } <span class="hljs-attr">else</span> { %&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>No events available at the moment.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">%</span> } %&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
&lt;/div&gt;
</code></pre>
<p>Here is an explanation of what each part of the code does:</p>
<ul>
<li><p><strong>Heading (</strong><code>&lt;h2&gt;All events&lt;/h2&gt;</code>): Displays "All events" as a heading.</p>
</li>
<li><p><strong>Event List (</strong><code>&lt;div&gt;</code>): Container for displaying a list of events.</p>
</li>
<li><p><strong>Conditional Check (</strong> <code>&lt;% if (events.length &gt; 0) { %&gt; ... &lt;% } else { %&gt; ... &lt;% } %&gt;</code>): Checks if there are any events (<code>events.length &gt; 0</code>). If events exist, it loops through each event (<code>events.forEach</code>) to display its details.</p>
</li>
<li><p>For each event, it creates a <code>&lt;div&gt;</code> containing the event's title (<code>event.title</code>) in a<code>&lt;h3&gt;</code> tag, the event's description (<code>event.description</code>) in a <code>&lt;p&gt;</code> tag, and a link (<code>&lt;a&gt;</code>) to view more details about the event (<code>Read More</code>). The link directs to <code>/event/event.id</code>, where <code>event.id</code> is the unique identifier of the event.</p>
</li>
<li><p><strong>No Events Message (</strong><code>&lt;% } else { %&gt; ... &lt;% } %&gt;</code>): If no events are present (<code>events.length &lt;= 0</code>), it displays a message saying "No events available at the moment."</p>
</li>
</ul>
<h2 id="heading-step-9-create-partials">Step 9: Create Partials</h2>
<p>Remember that you installed <code>ejs</code> into your application to facilitate more dynamic components. It allows you to break your code down further to be more dynamic.</p>
<p>To further organize your code, you'll use something called <strong>Partials</strong>.</p>
<p>Partials let you break down your code into scalable, modular, and manageable parts, keeping your HTML organized.</p>
<p>First, let's create a partial for the navbar.</p>
<h3 id="heading-how-to-create-a-partial">How to Create a Partial:</h3>
<ul>
<li><p>Inside your <code>views</code> folder, create a new folder named <code>partials</code></p>
</li>
<li><p>Inside the <code>partials</code> folder, create a new file called <code>nav.ejs</code>.</p>
</li>
<li><p>Cut out the navbar code from your homepage file and paste it into <code>nav.ejs</code>.</p>
</li>
</ul>
<h3 id="heading-example">Example:</h3>
<p>First, create the Partials folder and file:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/07/partial.png" alt="nav partial" width="600" height="400" loading="lazy"></p>
<p><em>nav partial</em></p>
<p>Use the <code>&lt;%- include() %&gt;</code> syntax from <code>ejs</code> to include the <code>nav.ejs</code> partial across pages in your application where you want the navbar to appear.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/07/include.png" alt="Include ()" width="600" height="400" loading="lazy"></p>
<p><em>Include () syntax</em></p>
<p>Here's the code:</p>
<pre><code class="lang-js">&lt;!DOCTYPE html&gt;
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"en"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">%-</span> <span class="hljs-attr">include</span>('<span class="hljs-attr">.</span>/<span class="hljs-attr">partial</span>/<span class="hljs-attr">head.ejs</span>') %&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">%-</span> <span class="hljs-attr">include</span>('<span class="hljs-attr">.</span>/<span class="hljs-attr">partial</span>/<span class="hljs-attr">nav.ejs</span>') %&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">main</span>&gt;</span>
      hello
    <span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">%-</span> <span class="hljs-attr">include</span>('<span class="hljs-attr">.</span>/<span class="hljs-attr">partial</span>/<span class="hljs-attr">footer.ejs</span>') %&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span></span>
</code></pre>
<p>With this setup, your HTML code will be organized. It will be easy to manage and update components like the navbar across different pages. You can use this approach on other parts of your application. For example, the head tag, footer tag, and other reusable components.</p>
<h2 id="heading-step-10-create-an-environment-variable-file-env">Step 10: Create an Environment Variable File (.Env)</h2>
<p>In this tutorial, we'll upload the project to GitHub. You'll protect your port number and MongoDB URL with secure storage. You'll also use an environment variable file, a configuration file known as .env. This file keeps sensitive information safe. It includes passwords and API URLs and prevents exposure.</p>
<p>Here's how to set it up using Node.js:</p>
<p>First, install the <code>[dotenv](https://www.npmjs.com/package/dotenv)</code> package.</p>
<pre><code class="lang-js">npm i dotenv
</code></pre>
<p>Then create a <code>.env</code> file. Inside it, add your PORT number and MongoDB URL. It should look something like this:</p>
<pre><code class="lang-plaintext">PORT=3000
dbURl='mongodb+srv://&lt;username&gt;:&lt;password&gt;@cluster0.mongodb.net/&lt;dbname&gt;?retryWrites=true&amp;w=majority';
</code></pre>
<p>Then update your <code>.gitignore</code> file:</p>
<pre><code class="lang-plaintext">
/node_modules
.env
</code></pre>
<p>Adding .env to your .gitignore ensures that it is not included in your GitHub repository. This tells Git to ignore the .env file when uploading your code.</p>
<p>Then in your <code>server.js</code> file, require the <code>dotenv</code> package. Load the variables with this line at the top of the file:</p>
<p>To require it, simply type:</p>
<pre><code class="lang-js"><span class="hljs-built_in">require</span>(<span class="hljs-string">'dotenv'</span>).config();
</code></pre>
<p>This way, you don't need to hardcode the PORT number and MongoDB URL in your <code>server.js</code> file. Instead, you can access them using <code>process.env.PORT</code> and <code>process.env.dbURl</code>.</p>
<p>So your <code>server.js</code> file will be cleaner and not messy 😵‍💫</p>
<pre><code class="lang-js"><span class="hljs-built_in">require</span>(<span class="hljs-string">'dotenv'</span>).config();
<span class="hljs-keyword">const</span> express = <span class="hljs-built_in">require</span>(<span class="hljs-string">'express'</span>);
<span class="hljs-keyword">const</span> ejs = <span class="hljs-built_in">require</span>(<span class="hljs-string">'ejs'</span>);
<span class="hljs-keyword">const</span> mongoose = <span class="hljs-built_in">require</span>(<span class="hljs-string">'mongoose'</span>);

mongoose
  .connect(process.env.dbURL)
  .then(<span class="hljs-function">(<span class="hljs-params">result</span>) =&gt;</span> {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Connected to MongoDB'</span>);
    app.listen(<span class="hljs-number">3000</span>, <span class="hljs-function">() =&gt;</span> {
      <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Server started on port 3000'</span>);
    });
  })
  .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
    <span class="hljs-built_in">console</span>.error(<span class="hljs-string">'Could not connect to MongoDB:'</span>, err);
  });
</code></pre>
<h2 id="heading-further-steps">Further Steps</h2>
<p>To expand on this basic application, consider adding features such as:</p>
<ul>
<li><p>User authentication</p>
</li>
<li><p>Event search and filter functionality</p>
</li>
<li><p>Event editing and deletion</p>
</li>
<li><p>Notifications for upcoming events</p>
</li>
</ul>
<h3 id="heading-how-to-style-the-application">How to Style the Application</h3>
<p>If you want to add some styling to your application, follow these steps:</p>
<p>First, create a <code>public</code> folder. Inside this folder, create a <code>style.css</code> file where you will write your custom CSS.</p>
<p>Then in your <code>HTML</code> file, link the <code>style.css</code> file in the <code>&lt;head&gt;</code> tag as you normally would:</p>
<pre><code class="lang-js">&lt;link rel=<span class="hljs-string">"stylesheet"</span> href=<span class="hljs-string">"/style.css"</span>&gt;
</code></pre>
<p>To ensure your CSS file is served correctly, add the following line to your <code>server.js</code> file:</p>
<pre><code class="lang-js">app.use(express.static(<span class="hljs-string">'public'</span>));
</code></pre>
<p>This application uses Tailwind CSS for styling. But using Tailwind is optional. You can use any CSS framework or write custom CSS to achieve your desired layout.</p>
<h3 id="heading-how-to-include-images">How to Include Images</h3>
<p>All images should be stored in the <code>public</code> folder and referenced in your HTML files. You should also ensure that the <code>public</code> folder is correctly set up in your <code>server.js</code> file to serve static files.</p>
<p>Here's an example of how to serve static files in <code>server.js</code>:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> express = <span class="hljs-built_in">require</span>(<span class="hljs-string">'express'</span>);
<span class="hljs-keyword">const</span> app = express();


<span class="hljs-comment">// Serve static files from the 'public' folder</span>
app.use(express.static(<span class="hljs-string">'public'</span>));
</code></pre>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Congratulations! You've built a simple application using Node.js, Express.js, ejs, and MongoDB. With these fundamentals, you can expand and enhance your application to meet more specific needs and features.</p>
<p>Feel free to share your progress or ask questions if you encounter any issues.</p>
<p>If you found this article helpful, share it with others who may also find it interesting.</p>
<p>Stay updated with my projects by following me on <a target="_blank" href="https://https//twitter.com/ijaydimples">Twitter</a>, <a target="_blank" href="https://www.linkedin.com/in/ijeoma-igboagu/">LinkedIn</a> and <a target="_blank" href="https://github.com/ijayhub">GitHub</a></p>
<p>Thank you for reading 💖.</p>
<p>Happy coding!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Zustand vs useState – How to Manage State in React Apps ]]>
                </title>
                <description>
                    <![CDATA[ State management in React applications has evolved a lot in recent years, especially with the advancement of functional state and the introduction of hooks. Developers have more flexibility and state management has generally become simpler. But as ap... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/zustand-vs-usestate-how-to-manage-state-in-react/</link>
                <guid isPermaLink="false">66b9f4874515ecc0455cf4d2</guid>
                
                    <category>
                        <![CDATA[ React ]]>
                    </category>
                
                    <category>
                        <![CDATA[ React ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ijeoma Igboagu ]]>
                </dc:creator>
                <pubDate>Wed, 15 May 2024 09:28:40 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/05/Add-a-heading--1-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>State management in React applications has evolved a lot in recent years, especially with the advancement of functional state and the introduction of hooks.</p>
<p>Developers have more flexibility and state management has generally become simpler. But as applications grow, they become more complex to manage – and you may find yourself needing a more robust state management solution.</p>
<p>React hooks provide built-in solutions to managing the state of your applications – for example, with the <code>useState()</code> hook. But there are other libraries like <a target="_blank" href="https://mobx.js.org/README.html">MobX</a>, <a target="_blank" href="https://www.npmjs.com/package/zustand">Zustand</a>, and <a target="_blank" href="https://recoiljs.org/">Recoil</a> that ca help make state management easier.</p>
<p>In this article, I’ll focus on <code>Zustand</code> and compare it with the <code>useState()</code> hook. You can check out a comparison of <a target="_blank" href="https://www.freecodecamp.org/news/usestate-vs-redux-state-management/">useState() and Redux here</a> if you want to learn more about Redux and how it compares to <code>useState()</code>.</p>
<p>To get started, I want to make sure you understand how both <code>useState()</code> and <code>Zustand</code> work. Then we'll compare them to see which is a better solution for your project.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>Before you begin coding, please ensure you have the following:</p>
<ul>
<li><p><a target="_blank" href="https://nodejs.org/en">Node.js</a> installed on your system.</p>
</li>
<li><p>A basic understanding of <a target="_blank" href="https://react.dev/">React.js</a>.</p>
</li>
<li><p>A code editor that you prefer, such as <a target="_blank" href="https://code.visualstudio.com/">Visual Studio Code,</a> or <a target="_blank" href="https://www.sublimetext.com/download">Sublime Text</a>.</p>
</li>
</ul>
<h2 id="heading-how-to-use-usestate-for-state-management">How to Use <code>useState()</code> for State Management</h2>
<h3 id="heading-overview-of-usestate-hook">Overview of useState hook</h3>
<p><code>useState()</code> is a built-in React Hook that allows functional components to manage state without using class components. It provides a simple way to declare state variables and update them within functional components.</p>
<p>For more information on the <code>useState()</code> hook, <a target="_blank" href="https://www.freecodecamp.org/news/usestate-hook-3-different-examples/">you can check out this tutorial</a>. It will provide you with detailed insights and examples related to <code>useState()</code> in React.</p>
<h3 id="heading-basic-usage-and-syntax">Basic usage and syntax</h3>
<p>The syntax for <code>useState()</code> is straightforward. It takes an initial state as an argument and returns an array with the current state value and a function to update that value.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> [text, setText] = useState();
</code></pre>
<p>Let's look at an example of how to use <code>useState()</code>.</p>
<p>Initial state of the application:</p>
<pre><code class="lang-javascript">

<span class="hljs-keyword">const</span> Usestate = <span class="hljs-function">() =&gt;</span> {


  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'container'</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>
       State management using useState()
      <span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'input'</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
          <span class="hljs-attr">type</span>=<span class="hljs-string">'text'</span>
          <span class="hljs-attr">className</span>=<span class="hljs-string">'input'</span>
        /&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span>
          Change Color
        <span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> Usestate;
</code></pre>
<p>In the above code, we have a React component named <code>Usestate</code>. It renders a simple interface with a heading "State management using useState()", a text input field, and a button labeled "Change color".</p>
<p>Here's the result of that code:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/05/useState---zustand.png" alt="An example showing initial state of the application" width="600" height="400" loading="lazy"></p>
<p><em>Initial state of the application</em></p>
<p>Now, let's add <code>useState()</code> and making it functional. Here's the code:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;

<span class="hljs-keyword">const</span> Usestate = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">const</span> [text, setText] = useState(<span class="hljs-string">'black'</span>);
  <span class="hljs-keyword">const</span> [color, setColor] = useState(<span class="hljs-string">'black'</span>); <span class="hljs-comment">// Another state to store the chosen color by the user</span>

  <span class="hljs-keyword">const</span> handleInputChange = <span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> {
    setText(e.target.value);
  };

  <span class="hljs-comment">// A function has been declared</span>
  <span class="hljs-keyword">const</span> handleButtonClick = <span class="hljs-function">() =&gt;</span> {
    setColor(text); <span class="hljs-comment">// it updates the chosen color when the button is clicked</span>
  };

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'container'</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h1</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{{color:color}}</span>&gt;</span>
        State management using useState()
      <span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'input'</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
          <span class="hljs-attr">type</span>=<span class="hljs-string">'text'</span>
          <span class="hljs-attr">className</span>=<span class="hljs-string">'input'</span>
          <span class="hljs-attr">value</span>=<span class="hljs-string">{text}</span>
          <span class="hljs-attr">onChange</span>=<span class="hljs-string">{handleInputChange}</span>
        /&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'btn'</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{handleButtonClick}</span>&gt;</span>
          Change Color
        <span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> Usestate;
</code></pre>
<p>In the above code, the state variable <code>text</code> is set to the initial state (color) using <code>useState()</code>. The <code>setText</code> function is set to update the value of color when the button is clicked.</p>
<p>The second state defined stores the color update from the user. So the <code>text</code> color remains unchanged until the button is clicked. Once the button is clicked, the color state updates with <code>text</code> value, changing <code>text</code> color to what the user types.</p>
<p>Here's the result:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/05/useState---zustand.gif" alt="Addition of useState() to the application" width="600" height="400" loading="lazy"></p>
<p><em>Addition of useState() to the application</em></p>
<h3 id="heading-pros-and-cons-of-usestate">Pros and cons of <code>useState()</code></h3>
<p>Pros:</p>
<ul>
<li><p>Built-in to React, so no need for additional dependencies.</p>
</li>
<li><p>Simple and intuitive API, easy to understand and use.</p>
</li>
</ul>
<p>Cons:</p>
<ul>
<li><p>Limited to managing local component state.</p>
</li>
<li><p>Can lead to <a target="_blank" href="https://www.freecodecamp.org/news/avoid-prop-drilling-in-react/">prop drilling</a> in deeply nested components which can cause confusion if you don't understand prop drilling.</p>
</li>
<li><p>Complex state management scenarios may require additional logic to handle.</p>
</li>
</ul>
<p>To learn more about <code>useState()</code> and other functional hooks check out this article: <a target="_blank" href="https://ijaycent.hashnode.dev/simplify-your-react-programming-effortlessly-with-these-8-amazing-hooks">Simplify your React programming effortlessly with these 8 amazing hooks</a>.</p>
<h2 id="heading-how-to-use-the-zustand-library-for-state-management">How to Use the Zustand Library for State Management</h2>
<h3 id="heading-overview-of-zustand">Overview of Zustand</h3>
<p><code>Zustand</code> is a handy state management tool for managing state in React apps. It's small, works quickly, and grows with your needs.</p>
<p>With <code>Zustand</code>, you can create and update states globally that can be easily shared between different parts of your app. It's like having a central hub for your app's information, making it simple to organize and access data from anywhere in your application.</p>
<h3 id="heading-zustand-basic-usage-and-syntax">Zustand basic usage and syntax</h3>
<p>To get started with Zustand, follow these steps:</p>
<p>First, start by installing Zustand in your React application using the command:</p>
<pre><code class="lang-javascript">npm install zustand
<span class="hljs-comment">// or</span>
yarn add zustand
</code></pre>
<p>Next, in your React application, navigate to the <code>src</code> directory and create a new folder called <code>store</code>.</p>
<p>Inside the <code>store</code> folder, create a file named <code>color.js</code> (or any preferred name). This a JavaScript file to define your state.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/05/zustand-color.js-1.png" alt="Architecture of your React application" width="600" height="400" loading="lazy"></p>
<p><em>Architecture of your React application</em></p>
<p>Then, in that <code>color.js</code> file, import the <code>create</code> function from Zustand to begin setting up your state management:</p>
<pre><code class="lang-plaintext">import { create } from zustand
</code></pre>
<p>We're going to use the <code>create</code> function to build a custom hook, which acts as the main access point to our store.</p>
<p>The <code>color.js</code> file is where we'll keep all our state values and the actions. Think of actions as the updated values. It's similar to how you use <code>useState()</code>.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { create } <span class="hljs-keyword">from</span> <span class="hljs-string">'zustand'</span>;

<span class="hljs-comment">// Create a custom hook called useColor</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> useColor = create(<span class="hljs-function">(<span class="hljs-params">set</span>) =&gt;</span> ({
  <span class="hljs-comment">// Initial state: text and color both set to 'black'</span>
  <span class="hljs-attr">text</span>: <span class="hljs-string">'black'</span>,
  <span class="hljs-attr">color</span>: <span class="hljs-string">'black'</span>,

  <span class="hljs-comment">// Function to update text state</span>
  <span class="hljs-attr">setText</span>: <span class="hljs-function">(<span class="hljs-params">text</span>) =&gt;</span> set({ text }),

  <span class="hljs-comment">// Function to update color state</span>
  <span class="hljs-attr">setColor</span>: <span class="hljs-function">(<span class="hljs-params">color</span>) =&gt;</span> set({ color }),
}));
</code></pre>
<p>Let's go over what this code is doing:</p>
<ul>
<li><p>This code creates a special tool (a hook) called <code>useColor</code> using Zustand.</p>
</li>
<li><p>The <code>useColor</code> tool helps keep track of two things: the text and the color.</p>
</li>
<li><p>At the start, both the text and the color are set to "black".</p>
</li>
<li><p>There are two other tools inside <code>useColor</code>: <code>setText</code>, which is used to change the text to whatever we want, and <code>setColor</code>, which is used to change the color to any color we choose.</p>
</li>
</ul>
<p>Creating this store involves defining it in a file. This makes it reusable throughout your whole app and makes it global. It removes the need to worry about passing props.</p>
<p>Then you need to pass it to your component to be used:</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// First we will import useColor from a folder named 'store'</span>
<span class="hljs-keyword">import</span> { useColor } <span class="hljs-keyword">from</span> <span class="hljs-string">'../store/color'</span>;


<span class="hljs-keyword">const</span> UseZustand = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-comment">// we will bring in the functions we defined in color.js and destructure it so we can use it in our component</span>
    <span class="hljs-comment">// pass a state into the custom hook we created; this state will now be used to set and update the values</span>
  <span class="hljs-keyword">const</span> { text, color, setText, setColor } = useColor(<span class="hljs-function">(<span class="hljs-params">state</span>) =&gt;</span> ({
    <span class="hljs-attr">text</span>: state.text,
    <span class="hljs-attr">color</span>: state.color,
    <span class="hljs-attr">setText</span>: state.setText,
    <span class="hljs-attr">setColor</span>: state.setColor,
  }));


  <span class="hljs-keyword">const</span> handleInputChange = <span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> {
    setText(e.target.value);
  };


<span class="hljs-comment">//Function defined for the button</span>
<span class="hljs-comment">// When the button is clicked, we use setColor to change the color to what we typed</span>
  <span class="hljs-keyword">const</span> handleButtonClick = <span class="hljs-function">() =&gt;</span> {
    setColor(text);
  };


  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'container'</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h1</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{{</span> <span class="hljs-attr">color:</span> <span class="hljs-attr">color</span> }}&gt;</span>
        State management using Zustand
      <span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'input'</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
          <span class="hljs-attr">type</span>=<span class="hljs-string">'text'</span>
          <span class="hljs-attr">className</span>=<span class="hljs-string">'input'</span>
          <span class="hljs-attr">value</span>=<span class="hljs-string">{text}</span>
          <span class="hljs-attr">onChange</span>=<span class="hljs-string">{handleInputChange}</span>
        /&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'btn'</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{handleButtonClick}</span>&gt;</span>
          Change Color
        <span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
};


<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> UseZustand;
</code></pre>
<p>In summary:</p>
<ul>
<li><p>We're using a tool called <code>useColor</code> to keep track of text and color.</p>
</li>
<li><p>Inside our app section <code>UseZustand</code>), we allow users to type something and change its color by clicking a button.</p>
</li>
</ul>
<p>Here what the final output looks like:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/05/applying-zustand.gif" alt="Applying zustand to the application" width="600" height="400" loading="lazy"></p>
<p><em>Applying zustand to the application</em></p>
<h3 id="heading-pros-and-cons-of-zustand">Pros and cons of Zustand</h3>
<p>Pros:</p>
<ul>
<li><p>Global state management without prop drilling.</p>
</li>
<li><p>Simple and concise for defining and accessing state.</p>
</li>
<li><p>Built-in support for middleware and devtools.</p>
</li>
</ul>
<p>Cons:</p>
<ul>
<li><p>Requires additional dependency compared to useState.</p>
</li>
<li><p>May introduce a learning curve for developers new to the library.</p>
</li>
</ul>
<h2 id="heading-how-does-zustand-differ-from-usestate">How Does Zustand Differ from useState?</h2>
<p>Unlike <code>useState()</code>, Zustand allows developers to create and manage global state that can be accessed from any component in the application without prop drilling.</p>
<p>It offers a more centralized approach to state management.</p>
<h3 id="heading-factors-to-consider-when-choosing-between-zustand-and-usestate">Factors to consider when choosing between Zustand and useState</h3>
<p>Here are some simple things to think about when choosing between Zustand and useState:</p>
<ul>
<li><p><strong>State Complexity</strong>: If your app's state is simple, useState might be fine. But for more complex state needs, Zustand could be better.</p>
</li>
<li><p><strong>Speed</strong>: Zustand is known for being fast, which is great if your app needs to be quick.</p>
</li>
<li><p><strong>Team Skills</strong>: If your team already knows how to use React Hooks, useState might be easier. But if they're open to learning something new, Zustand could be worth a try.</p>
</li>
<li><p><strong>App Growth</strong>: Consider how your app might grow over time. Zustand's centralized approach can make it easier to handle state as your app gets bigger.</p>
</li>
<li><p><strong>Community Support:</strong> See what resources and help are available for Zustand and useState. A strong community can be helpful.</p>
</li>
</ul>
<p>Thinking about these things should help you decide. It will show you which state management option is best for your project.</p>
<h3 id="heading-what-are-the-differences-between-these-two-state-management-tools">What Are the Differences Between These Two State Management Tools?</h3>
<p>The difference in the two tools lies in their feature with this you can make an informed decision.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Feature</td><td>useState</td><td>Zustand</td></tr>
</thead>
<tbody>
<tr>
<td><strong>Complexity Handling</strong></td><td>Good for simple state in one component</td><td>Better for complex state shared across many components</td></tr>
<tr>
<td><strong>State Scope</strong></td><td>Local to one component</td><td>Global state that can be used by any component</td></tr>
<tr>
<td><strong>Performance</strong></td><td>Works well for small tasks</td><td>Designed to reduce re-renders</td></tr>
<tr>
<td><strong>Ease of Use</strong></td><td>Very simple to start with, no setup needed</td><td>Needs a bit more setup, more features but a bit harder to learn</td></tr>
<tr>
<td><strong>Scalability</strong></td><td>Can get tricky as the app grows, often needs other tools for big apps</td><td>Handles growth well, easier to manage state in big apps</td></tr>
<tr>
<td><strong>Support and Tools</strong></td><td>Part of React, lots of help and info available, no extra libraries needed</td><td>Separate library, good support, not as much info as useState but still good</td></tr>
<tr>
<td><strong>Learning Curve</strong></td><td>useState is easier to learn</td><td>Zustand has a slightly steeper learning curve due to its store creation process.</td></tr>
</tbody>
</table>
</div><h3 id="heading-use-cases">Use Cases</h3>
<ol>
<li><p>For simple state management, useState() is often enough.</p>
</li>
<li><p>Zustand offers advantages like centralized state and reducing prop drilling in complex apps.</p>
</li>
<li><p>Regarding performance, Zustand is built to be fast and efficient. It's made to reduce unneeded re-renders of your components. These can make your app run smoother.</p>
</li>
</ol>
<p>Don't know what to build with <code>useState()</code> or <code>zustand</code>? You can check out this very simple application built with React: <a target="_blank" href="https://ijayhub.github.io/Birthday-reminder/">Birthday Reminder</a>. And here it is on my <a target="_blank" href="https://github.com/ijayhub/Birthday-reminder">GitHub</a>.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In conclusion, <code>Zustand</code> and <code>useState()</code> are both useful for managing state in React. They serve different purposes based on your project's requirements and scale. You should understand the strengths and weaknesses of each approach in order to choose the best state management option for your app.</p>
<p>Have you used <code>Zustand</code> or <code>useState()</code> before? Share your experiences, insights, and tips on <a target="_blank" href="https://https//twitter.com/ijaydimples">Twitter</a>! Your input could make a real difference for other developers grappling with state management in React.</p>
<p>You can read the <a target="_blank" href="https://docs.pmnd.rs/zustand/getting-started/introduction">Zustand documentation</a> to learn more.</p>
<p>If you found this article helpful, share it with others who may also find it interesting.</p>
<p>Stay updated with my projects by following me on <a target="_blank" href="https://https//twitter.com/ijaydimples">Twitter</a> and <a target="_blank" href="https://www.linkedin.com/in/ijeoma-igboagu/">LinkedIn</a> or check out my <a target="_blank" href="https://www.biodrop.io/ijayhub">BioDrop</a>.</p>
<p>If you enjoy what I do and want to show your support or want to <a target="_blank" href="https://selar.co/showlove/httpsselarcow43744">show some💖</a>, consider b<a target="_blank" href="https://www.buymeacoffee.com/ijewriter">uying me a coffee</a>☕ or checking out my e-B<a target="_blank" href="https://selar.co/w43744">ook</a> for kids! Your support means a lot to me!</p>
<p>Keep learning, keep sharing, and happy coding!</p>
<p>Thank you for reading💖.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ AI Tools You Can Use in Visual Studio Code Besides GitHub Copilot ]]>
                </title>
                <description>
                    <![CDATA[ AI tools have become quite popular recently. Developers use these tools to help generate ideas, create simple code examples, and so on.  In 2023, ChatGPT and other Large Language Models found their way into many of our toolkits. And we can use them t... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/ai-tools-to-use-in-vs-code/</link>
                <guid isPermaLink="false">66b9f47068badebf96ed5f95</guid>
                
                    <category>
                        <![CDATA[ AI ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Artificial Intelligence ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Visual Studio Code ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ijeoma Igboagu ]]>
                </dc:creator>
                <pubDate>Mon, 22 Jan 2024 19:56:13 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/01/ai-tool-cover-2-1.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>AI tools have become quite popular recently. Developers use these tools to help generate ideas, create simple code examples, and so on. </p>
<p>In 2023, ChatGPT and other Large Language Models found their way into many of our toolkits. And we can use them to be more productive and save time on repetitive tasks.</p>
<p>In this article, you'll discover other helpful tools besides GitHub Copilot.</p>
<p>Before we discuss alternatives, let's go over what GitHub Copilot is and what it does.</p>
<h2 id="heading-what-is-github-copilot">What is GitHub Copilot?</h2>
<p>GitHub Copilot helps developers write code more quickly and efficiently. It's a tool developed by GitHub and OpenAI that employs a strong AI and Codex.</p>
<p><a target="_blank" href="https://www.freecodecamp.org/news/how-to-use-github-copilot-with-visual-studio-code/">GitHub Copilot works with a variety of code editors, including Visual Studio Code</a>, NeoVim, and JetBrains.</p>
<p>GitHub Copilot uses machine learning. It doesn't autocomplete – it suggests entire code snippets as you work in your text editor. It can also help you debug and refactor old code. The goal is to improve coding efficiency, decrease time spent on repetitive tasks, and increase productivity.</p>
<p>But GitHub Copilot has a downside: after the trial period, it costs $10 per month, which some users may consider too high.</p>
<p>So now let's look at some alternatives which are free to use.</p>
<h2 id="heading-synk-deepcode">Synk (DeepCode)</h2>
<p>Synk, formerly known as DeepCode, is a tool that helps you keep your code safe. It works directly with your project file or repository, making it simple for teams to <a target="_blank" href="https://snyk.io/platform/deepcode-ai/">find and fix any security issues in their code</a>, dependencies, containers, and infrastructure.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/image-44.png" alt="Synk (DeepCode) Homepage" width="600" height="400" loading="lazy">
<em>Synk(DeepCode) Homepage</em></p>
<h3 id="heading-use-cases">Use Cases</h3>
<ul>
<li>Ideal for early-stage security reviews.</li>
<li>Effective bug detection and resolution.</li>
</ul>
<h3 id="heading-features-of-synk">Features of Synk</h3>
<ul>
<li>Scans your code early in development to help it pass security reviews. This helps avoid costly fixes later in the development cycle.</li>
<li>Scans for vulnerabilities and presents results with security issues.</li>
<li>Finds possible bugs in your code, helping you catch and fix issues early.</li>
<li>Suggests how to make your code run better.</li>
<li>Gets smarter by learning from different code examples. It gives better suggestions over time using algorithms.</li>
</ul>
<h3 id="heading-limitations-of-synk">Limitations of Synk</h3>
<p>While Snyk is a powerful too, it has a couple limitations as well. First, it examines whole codebases, which could demand significant computing power, affecting the performance.</p>
<p>To help mitigate this issue, you can break down large codebases into smaller, manageable modules.</p>
<p>Also, there might be a bit of a learning curve for developers to understand how to get the most out of the tool.</p>
<p>But your team can offer training sessions or documentation to help you and other developers better understand how to use Synk effectively. Also, encourage your team to provide support resources, such as forums or documentation, to address common issues and questions.</p>
<h3 id="heading-price">Price</h3>
<p>Using Synk in Visual Studio Code for individual code security testing is entirely free. This allows for checking your code's security before deploying it to production. </p>
<p>To collaborate within a team or for business purposes, upgrading the plan is necessary. You can find more information about the pricing plan <a target="_blank" href="https://snyk.io/plans/">here</a>.</p>
<h3 id="heading-how-to-set-up-synk-in-visual-studio-code">How to set up Synk in Visual Studio Code</h3>
<p>To set up Snyk, select the "View" option in your text to reveal a dropdown menu.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/image-45.png" alt="view in the editor" width="600" height="400" loading="lazy">
<em>Select the "view" option in the editor</em></p>
<p>Then click on the "Extensions" option in that dropdown, and it will take you to the Visual Studio Code Marketplace.</p>
<p>In the marketplace,  type "Synk Security" and hit enter, then go ahead and install it.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/image-46.png" alt="Marketplace" width="600" height="400" loading="lazy">
<em>Marketplace</em></p>
<h3 id="heading-how-to-authenticate-in-snyk">How to authenticate in Snyk</h3>
<p>After you've installed Snyk, you'll need to authenticate.</p>
<p>Click on the Synk icon in your editor. This will take you to the authentication page.</p>
<p>Click on the button to authenticate and connect. Once you're authenticated, go back to your editor. That's it!</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/authenticate-synk.gif" alt="Authenticate and connect to so it works with your visual studio code" width="600" height="400" loading="lazy">
<em>Authenticate and connect to so it works with your visual studio code</em></p>
<p>After completing this step, you can now use Snyk to examine, understand, and analyze your code before sending it in for production.</p>
<h3 id="heading-example-use-case">Example use case</h3>
<p>To scan for possible vulnerabilities in the project file, just click on the sync icon on the left panel. This will analyze the code and highlight any potential issues that need attention.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/synk-example-in-action.gif" alt="example Synk in action" width="600" height="400" loading="lazy">
<em>Example Synk in action</em></p>
<p>If you take a closer look, you'll see some letters indicating how vulnerable codes written is.</p>
<ul>
<li>"H" means it's really high and needs fixing ASAP.</li>
<li>"M" means it's at the maximum vulnerability level.</li>
<li>"L" means it's at a low vulnerability level.</li>
</ul>
<p>If you click on a vulnerability, you'll get suggestions on how to fix it, which are displayed on the right side of the editor.</p>
<h2 id="heading-swimm-ai">Swimm AI</h2>
<p>Swimm is a <a target="_blank" href="https://swimm.io/">coding assistance tool</a> that helps you understand complex and large code bases. </p>
<p>Swimm, acting as an intelligent guide for developers, simplifies the process of understanding complex code by delivering quick insights. It also excels at automatically correcting and augmenting any documentation gaps that may emerge, resulting in a complete and well-documented development environment. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/homepage-of-swimm.gif" alt="Homepage of Swimm AI" width="600" height="400" loading="lazy">
<em>Homepage of Swimm AI</em></p>
<h3 id="heading-use-cases-1">Use Cases</h3>
<ul>
<li>Document Creation.</li>
<li>Workflow Organization.</li>
<li>Automatic Generation of Code Snippet Explanations.</li>
</ul>
<h3 id="heading-features-of-swimm-ai">Features of Swimm AI</h3>
<ul>
<li>Simplifies document creation.</li>
<li>Transforms pull requests into user-friendly documents for easy knowledge sharing.</li>
<li>Enhances workflow organization with rules for document visibility.</li>
<li>Improves communication clarity through guided documentation enhancement, making information more understandable and accessible.</li>
<li>Analyzes your code from multiple perspectives, creating easy-to-understand documents for complex code flows.</li>
<li>Continuously updated knowledge base, that is it auto-syncs automatically to align your documentation and latest code changes.</li>
</ul>
<h3 id="heading-limitations-of-swimm-ai">Limitations of Swimm AI</h3>
<p>As always when using AI tools, you should always double-check before finalizing your decisions based off the AI's output. </p>
<h3 id="heading-price-1">Price</h3>
<p>When Swimm is incorporated into your development environment, it is free to use. But larger businesses might consider <a target="_blank" href="https://swimm.io/pricing">upgrading</a> because enhanced plans give unlimited user access. </p>
<h3 id="heading-how-to-set-up-swimm-ai-in-visual-studio-code"><strong>How to set up</strong> Swimm AI <strong>in Visual Studio Code</strong></h3>
<p>Visit your Integrated Development Environment (IDE)'s marketplace, type "swimm," and hit Enter. </p>
<p>Then, proceed with the installation from the marketplace, or you can go to their <a target="_blank" href="https://swimm.io/integrations">website to integrate</a> it into your IDE.</p>
<p>Click the VSCode icon to initiate it. Then you'll need to login or sign-up – click the button that appears. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/swimm-sign-in.gif" alt="Clicking of the icon to reveal login and signup button" width="600" height="400" loading="lazy">
<em>Clicking of the icon</em></p>
<p>To sign up, simply follow the instructions provided by the website.</p>
<p>Since you are authenticated, you can now log in and use the application.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/Login-swimm.gif" alt="Login direction" width="600" height="400" loading="lazy">
<em>Login direction</em></p>
<p>When the external website opens, synchronize your Integrated Development Environment (IDE). </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/sync-swmm.gif" alt="Authorizing with your IDE" width="600" height="400" loading="lazy">
<em>Authorizing with your IDE</em></p>
<p>Now let's go ahead and see how it works with a practical example.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/Code_Jj8izaMNGF.gif" alt="Example" width="600" height="400" loading="lazy">
<em>Swimm AI example</em></p>
<h2 id="heading-cody-ai">Cody AI</h2>
<p>Cody AI is a <a target="_blank" href="https://sourcegraph.com/cody">smart coding assistant</a> that uses advanced AI to understand and analyze your code. It helps you code more quickly and also improves your understanding of the codebase. It goes beyond basic functions, identifying patterns and suggesting improvements, making your coding experience more efficient and insightful.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/image-49.png" alt="Cody Homepage" width="600" height="400" loading="lazy">
<em>Cody Homepage</em></p>
<h3 id="heading-use-cases-for-cody-ai">Use Cases for Cody AI</h3>
<ul>
<li>Facilitating creativity in tasks and brainstorming. </li>
<li>Resolving common issues with digital tools. </li>
<li>Strengthening teamwork through quick information sharing.</li>
</ul>
<h3 id="heading-features-of-codyai">Features of CodyAI</h3>
<ul>
<li>Provides immediate responses to inquiries.</li>
<li>Allows you to upload various data types to build a customized knowledge base.</li>
<li>Cody's responses all have adequate source citations.</li>
<li>Can help with email authoring, document translation, and marketing material generation.</li>
<li>Assists teams in using digital technologies to diagnose and resolve problems.</li>
<li>Based on previous encounters and contextual history, it makes suggestions and thoughts.</li>
</ul>
<h3 id="heading-limitations-of-cody-ai">Limitations of Cody AI</h3>
<p>As with any tool, there are limitations. First of all, the search capability of the AI isn't as powerful. It analyzes user queries using available information. As a result, the AI may give answers that lack your desired depth or specificity at times.</p>
<p>Also, Cody AI Bots can't do math or handle tables well. This means the AI might not give accurate answers when dealing with numbers or complex data.</p>
<p>Lastly, Cody AI Bots can't understand pictures, diagrams, or anything visual in documents. It only uses text to come up with responses, so it's not great at dealing with visual elements.</p>
<p>To help mitigate these issues, make sure you're as clear and specific as possible when formulating your queries to help Cody better understand your intentions.</p>
<p>You can also break down complex questions into simpler components to improve the chances of accurate responses.</p>
<h3 id="heading-price-2">Price</h3>
<p>Installing Cody in your integrated development environment is free for personal use. However, for professionals or businesses looking to leverage Cody's capabilities, <a target="_blank" href="https://meetcody.ai/pricing/">an upgrade is required</a>.</p>
<h3 id="heading-how-to-set-up-cody-in-visual-studio-code">How to set up Cody in Visual Studio Code</h3>
<p>First, select the "View" option in your text editor to reveal a dropdown menu as shown above.</p>
<p>Click "Extensions", and it will take you to the Visual Studio Code Marketplace.</p>
<p>In the marketplace, type "Cody" and hit enter, then go ahead and install it.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/image-50.png" alt="Installing Cody AI" width="600" height="400" loading="lazy">
<em>Cody Plugin</em></p>
<p>Now that the installation is complete, you can begin utilizing Cody in your editor. </p>
<p>Cody provides different command prompts to assist you with your code:</p>
<ul>
<li>It can help you generate documentation for your code</li>
<li>If you're contributing to an open-source project and find the codebase confusing, Cody AI can provide explanations.</li>
<li>It can tell you which programming language a piece of code is written in.</li>
<li>You can ask Cody questions without leaving your coding environment.</li>
<li>Cody can make edits to your code based on given instructions.</li>
</ul>
<p>Now, I'll illustrate how Cody can help explain parts of your code with an example:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/explain-cody-example.gif" alt="One command prompt of Cody AI" width="600" height="400" loading="lazy">
<em>One command prompt of Cody AI</em></p>
<h2 id="heading-tabnine">Tabnine</h2>
<p>Tabnine is a powerful AI assistant designed for developers, providing AI-driven <a target="_blank" href="https://www.tabnine.com/">code completions and suggestions</a> to boost productivity. </p>
<p>It is compatible with a wide range of programming languages and major Integrated Development Environments (IDEs), enabling developers to leverage its smart code recommendations effectively.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/image-52.png" alt="TabNine Homepage" width="600" height="400" loading="lazy">
<em>Tabnine Homepage</em></p>
<h3 id="heading-use-cases-2">Use cases</h3>
<ul>
<li>Speeding up Software Development: Facilitates faster and more efficient code writing.</li>
<li>Ensuring Code Consistency: Maintains a consistent coding style among different team members.</li>
</ul>
<h3 id="heading-features-of-tabnine">Features of Tabnine</h3>
<ul>
<li>Learns from the code you type and adjusts its suggestions to match your coding style.</li>
<li>Cares about your privacy. It only learns from open-source and permissive code, so you always own your code.</li>
<li>Awesome for developers because it works with many programming languages. It's like a handy tool for different tech stuff!</li>
<li>Makes coding easier by giving smart suggestions, helping developers save time.</li>
<li>It works well with popular code editors like Visual Studio code. Developers can  use it in their coding environments.</li>
</ul>
<h3 id="heading-limitations-of-tabnine">Limitations of Tabnine</h3>
<p>Tabnine learns from how you code over time, so it might take a little time to match your coding style. It helps if you actively use the tool and provide consistent input to help it learn your coding style faster.</p>
<p>Tabnine also suggests code, but it doesn't create entire sections. While this may seem like a limitation, it's actually best for code quality. </p>
<p>Finally, it might suggest code that is not quite right. Developers should double-check the suggestions for accuracy. To help Tabnine suggest better code, you can regularly review and accept/reject suggestions to fine-tune its understanding of your preferences.</p>
<p>You should also always double-check the suggested code for correctness and adherence to coding standards before finalizing it.</p>
<h3 id="heading-price-3">Price</h3>
<p>Installation comes at no monthly cost, making it free. However, for larger organizations, it's recommended to consider upgrading. Upgraded plans for larger organizations provide unlimited user access while prioritizing security and privacy.</p>
<h3 id="heading-how-to-set-up-tabnine-in-visual-studio-code">How to set up Tabnine in Visual Studio Code</h3>
<p>To begin, select the "View" option in your text editor to reveal a dropdown menu as shown above.</p>
<p>Click "Extensions" and it will take you to the Visual Studio Code Marketplace.</p>
<p>In the marketplace, type "Tabnine" and hit enter, then go ahead and install it.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/use-tabnine-cover.png" alt="Extension (marketplace in IDE)" width="600" height="400" loading="lazy">
<em>Extension (marketplace in IDE)</em></p>
<p>Now that we've got it installed, you can start using Tabnine in your editor. Here's an example:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/use-tabnine-example.gif" alt="Example in the editor" width="600" height="400" loading="lazy">
<em>Example in the editor</em></p>
<p>And here's the code:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> add = <span class="hljs-function">(<span class="hljs-params">a, b</span>) =&gt;</span> {

 <span class="hljs-keyword">return</span> a + b;

}

<span class="hljs-built_in">console</span>.log(add(<span class="hljs-number">5</span>,<span class="hljs-number">9</span>))<span class="hljs-comment">// output 14</span>
</code></pre>
<h2 id="heading-code-whisperer">Code Whisperer</h2>
<p>CodeWhisperer is a smart helper for coding. It uses AI to suggest bits of code or whole functions as you work in your coding environment. Made by <a target="_blank" href="https://aws.amazon.com/codewhisperer/">AWS</a>, it makes coding easier with features like autocomplete and code restructuring.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/image-56.png" alt="Code Whisperer Homepage" width="600" height="400" loading="lazy">
<em>Code Whisperer Homepage</em></p>
<h3 id="heading-features-of-code-whisperer">Features of Code Whisperer</h3>
<ul>
<li>Code Whisperer suggests code in real-time as you write.</li>
<li>Integrates with your Integrated Development Environment (IDE).</li>
<li>Helps enhance code readability and efficiency by assisting in improving and restructuring.</li>
<li>Supports a diverse range of programming languages.</li>
<li>Offers valuable help in generating and understanding code documentation.</li>
</ul>
<h3 id="heading-limitations-of-code-whisperer">Limitations of Code Whisperer</h3>
<p>CodeWhisperer might find it hard to handle new coding tasks that need creativity.</p>
<p>Also, errors in its training data/models may lead to inaccurate code suggestions.</p>
<p>With these in mind, you should primarily use CodeWhisperer as a tool for generating routine or repetitive code, leaving more complex and creative tasks to human expertise.</p>
<p>Also make sure to review and verify any suggestions from CodeWhisperer often and don't just take the information at face value.</p>
<h3 id="heading-how-to-set-up-code-whisperer-in-visual-studio-code">How to set up Code Whisperer in Visual Studio Code</h3>
<p>First, select the "View" option in your text editor to reveal a dropdown.</p>
<p>Click on "Extensions" and it will take you to the Visual Studio Code Marketplace.</p>
<p>In the marketplace, type "AWS Toolkit" and hit enter, then go ahead and install it.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/image-58.png" alt="Image" width="600" height="400" loading="lazy">
<em>Extension(marketplace in IDE)</em></p>
<p>Now that the extension is installed, let's put it to use in our Integrated Development Environment (IDE).</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/example-code-whisper.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Here's the code:</p>
<pre><code class="lang-js"><span class="hljs-comment">// create a greet function</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">greet</span>(<span class="hljs-params">name</span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-string">"Hello "</span> + name;
}
<span class="hljs-comment">// export the greet function</span>
<span class="hljs-built_in">module</span>.exports = greet;
</code></pre>
<h2 id="heading-codegeex-ai">CodeGeex AI</h2>
<p>CodeGeeX is a <a target="_blank" href="https://codegeex.cn/en-US">helpful tool for coding</a> that creates comments, suggests code, and provides AI-powered chat help. It can also translate your code into different languages and works well with many programming languages and tools. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/chrome_4C9oZTEpBe.png" alt="Image" width="600" height="400" loading="lazy">
<em>CodeGeex Homepage</em></p>
<h3 id="heading-use-cases-3">Use Cases</h3>
<ul>
<li>Make coding faster.</li>
<li>Guides new developers through big code with auto comments and explanations.</li>
</ul>
<h3 id="heading-features-of-codegeex-ai">Features of CodeGeex AI</h3>
<ul>
<li>Great at finishing code. It helps by autocompleting and generating lines based on existing code or comments.</li>
<li>Creates comments for both methods and lines in the code, saving time and making it easy to understand unfamiliar code.</li>
<li>Helps change code from one programming language to another – like turning Python into Java.</li>
<li>Developers can ask CodeGeeX coding questions and get quick answers without searching the web.</li>
<li>CodeGeeX does more than suggesting code. It can interpret selected code, fix bugs, summarize code, and more.</li>
</ul>
<h3 id="heading-limitations-of-codegeex-ai">Limitations of CodeGeeX AI</h3>
<p>When you're using CodeGeeX, keep in mind that it's a research prototype, so it might not always create perfect code for every situation.</p>
<p>It also might misunderstand some language descriptions or code snippets, leading to possible mistakes.</p>
<p>As always, make sure you carefully verify the generated code for accuracy and adherence to coding standards.</p>
<p>Also, when providing language descriptions or code snippets, be as clear and detailed as possible.</p>
<h3 id="heading-price-4">Price</h3>
<p>CodeGeex is free to install on Visual Studio Code, and for an upgrade, it starts at $9/month.</p>
<h3 id="heading-how-to-set-up-codegeex-ai-in-visual-studio-code">How to set up CodeGeeX AI in Visual Studio Code</h3>
<p>Select the "View" option in your text editor to unveil a dropdown menu.</p>
<p>Click on "Extensions" in your text editor, and it will take you to the Visual Studio Code Marketplace.</p>
<p>In the marketplace,  type "CodeGeex" and hit enter, then proceed to install it.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/image-61.png" alt="Install CodeGeex" width="600" height="400" loading="lazy">
<em>Install CodeGeex</em></p>
<p>After installation, click on the icon, and it will take you back to a page where you can log in or sign up.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/image-62.png" alt="Login page in CodeGeex" width="600" height="400" loading="lazy">
<em>Login page in CodeGeex</em></p>
<p>Once you've completed this step, you'll be able to interact with the AI in your IDE.</p>
<p>To trigger it, navigate to your IDE, highlight the desired code, and right-click. A dropdown menu will appear, allowing you to choose the specific command you want the AI to execute for you.</p>
<p>Here's an example:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/use-codegeex.gif" alt="Image" width="600" height="400" loading="lazy">
<em>Example of using CodeGeex</em></p>
<p>The GIF example showed one thing CodeGeex AI can do. </p>
<p>To learn more about its abilities, visit the docs: <a target="_blank" href="https://marketplace.visualstudio.com/items?itemName=aminer.codegeex">CodeGeeX: AI Code AutoComplete, Chat, Auto Commen</a>t.</p>
<p>Code:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> colors = [<span class="hljs-string">'pink'</span>, <span class="hljs-string">'blue'</span>, <span class="hljs-string">'purple'</span>, <span class="hljs-string">'green'</span>];

colors.forEach(<span class="hljs-function"><span class="hljs-params">color</span> =&gt;</span> {
    <span class="hljs-built_in">console</span>.log(color);
});
</code></pre>
<h2 id="heading-codeium">Codeium</h2>
<p>Codeium is a <a target="_blank" href="https://codeium.com/">free and powerful tool</a> that makes coding faster using advanced AI. It's like a superhero for coding, with a tool that helps you complete code in over 70 languages. It's super speedy and gives top-notch suggestions, making coding much more efficient. You can use Codeium as a <a target="_blank" href="https://chromewebstore.google.com/detail/codeium-ai-code-autocompl/hobjkcpmjhlegmobgonaagepfckjkceh">Google Chrome extension</a>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/image-64.png" alt="Codeium Homepage" width="600" height="400" loading="lazy">
<em>Codeium Homepage</em></p>
<p>Just keep in mind that, because of its power, using Codeium makes it easy to over-rely on AI-generated suggestions. This could lead to errors in your code if you're not vigilant and don't keep up your skills. So make sure you still check/run your code, learn new topics as you need to, and keep your own code-writing abilities sharp. </p>
<p>You can <a target="_blank" href="https://ai-review.com/code-assistant/codeium/">read more about Codeium here</a>.</p>
<h3 id="heading-price-5">Price</h3>
<p>The AI is initially free to install in your Integrated Development Environment (IDE) but may require an upgrade which starts at <a target="_blank" href="https://codeium.com/pricing">$12/month with team usage</a>.</p>
<h3 id="heading-how-to-set-up-codeium-in-visual-studio-code">How to set up Codeium in Visual Studio Code</h3>
<p>To start, visit Codeium's <a target="_blank" href="https://codeium.com/">website</a> and select the sign-in option.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/image-66.png" alt="Sign-in user" width="600" height="400" loading="lazy">
<em>Sign-in user</em></p>
<p>Clicking on this will redirect you to the login page.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/image-67.png" alt="Login page" width="600" height="400" loading="lazy">
<em>Login page</em></p>
<p>Sign in using either your email or Google account.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/image-68.png" alt="Image" width="600" height="400" loading="lazy">
<em>Authenticate</em></p>
<p>Once you've completed the login, you'll encounter various integrated development environments (IDEs). Choose the one that aligns with your preferences – for instance, I use Visual Studio Code.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/choose-ide-codeium.gif" alt="Image" width="600" height="400" loading="lazy">
<em>Choosing your IDE</em></p>
<p>Go ahead and install it in your Visual Studio Code IDE.</p>
<p>After installation, click on the account sign-in option in Visual Studio Code to authenticate with the website.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/use-codeium-authentication-1.gif" alt="Image" width="600" height="400" loading="lazy">
<em>Authenticate</em></p>
<p>Once completed, you can now use Codeium within your IDE.</p>
<p>Now, let's see a practical example:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/result-from-codium.gif" alt="Example" width="600" height="400" loading="lazy">
<em>Codeium example</em></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>The article discusses various AI tools that you can use to speed up development. Some developers think only about GitHub Copilot. But there are other AI tools with different features that can help you too.</p>
<p>If you've found value in this tutorial, consider sharing it with fellow developers who might also benefit. </p>
<p>To stay updated with my latest projects by following me on <a target="_blank" href="https://https//twitter.com/ijaydimples">Twitter</a> and <a target="_blank" href="https://www.linkedin.com/in/ijeoma-igboagu/">LinkedIn</a> or check out my <a target="_blank" href="https://www.biodrop.io/ijayhub">BioDrop</a>. </p>
<p>If you'd like to show your support, you can also <a target="_blank" href="https://www.buymeacoffee.com/ijewriter">Buy me a coffee</a>☕</p>
<p>Thank you for taking the time to read💖  </p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Fetch API Data in React ]]>
                </title>
                <description>
                    <![CDATA[ When developing applications, you often need to get data from an API. This lets you deliver dynamic and often-updated content within your application. You'll want to retrieve this data as you may need to interact with external services, communicate w... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-fetch-api-data-in-react/</link>
                <guid isPermaLink="false">66b9f478d7bbeb190f7fd1ed</guid>
                
                    <category>
                        <![CDATA[ api ]]>
                    </category>
                
                    <category>
                        <![CDATA[ React ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ijeoma Igboagu ]]>
                </dc:creator>
                <pubDate>Thu, 14 Dec 2023 10:18:47 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/12/Effective-Ways-for-Retrieving-API-Data-in-React-and-Python--1-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>When developing applications, you often need to get data from an API. This lets you deliver dynamic and often-updated content within your application.</p>
<p>You'll want to retrieve this data as you may need to interact with external services, communicate with a distant server, or access a database.</p>
<p>In this article, I'll show you different methods of fetching data using React as an example.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<ul>
<li>Install <a target="_blank" href="https://nodejs.org/en">Node.js</a></li>
<li>Ensure you have at least a basic understanding of <a target="_blank" href="https://react.dev/">React.js</a>.</li>
<li>A text editor</li>
</ul>
<h2 id="heading-what-is-an-api">What is an API?</h2>
<p>API stands for Application Programming Interface. It enables the exchange of information and functionality between different systems, such as between a website and a server or between different software applications.</p>
<p>You can think of an API as being like a restaurant waiter. You don't go inside the kitchen to prepare your meal when you dine at a restaurant. Rather, you inform the waiter of your preferences, and they will take your order to the kitchen team. The kitchen team prepares the food and returns it to the waiter, who then delivers it to your table.</p>
<p>An API functions as a waiter for software applications. It is a set of rules that lets one program ask another for something it needs. It serves as a bridge for software apps to communicate and interact.</p>
<h3 id="heading-why-are-apis-important-in-web-development">Why are APIs important in web development?</h3>
<p>There are a few reasons why APIs are important in web development. Let's go over some of them below:</p>
<ul>
<li>Web applications need APIs to get data from various sources, like databases or websites.</li>
<li>APIs are a scalable option for managing high data or request volumes.</li>
<li>Developers use APIs to leverage existing features and services. This saves them from reinventing the wheel.</li>
<li>They keep things safe by ensuring that only authorized individuals or programs can use them.</li>
<li>An API makes a website or mobile app more enjoyable to use by integrating data.</li>
</ul>
<h2 id="heading-what-is-a-hypertext-transfer-protocol-http-request">What is a Hypertext Transfer Protocol (HTTP) request?</h2>
<p>When a web browser or a mobile app sends a message to a server, it's known as an <code>HTTP</code> request. A <code>HTTP</code> request involves asking the server for specific data or an action and getting a response. The server responds by interacting with web pages and services.</p>
<p>Using APIs in software development makes things more flexible and efficient. It also enhances security and enables different software systems to work well together.</p>
<h3 id="heading-types-of-http-requests">Types of HTTP Requests</h3>
<p>We use various <code>HTTP</code> request methods, such as <code>get</code>, <code>post</code>, <code>put</code>, and <code>delete</code>, to get and store data in our database. But the most common requests made are the <code>get</code> and <code>post</code> requests.</p>
<p>Let's discuss the meaning of these <code>HTTP</code> request methods:</p>
<ul>
<li><strong>GET:</strong> This method retrieves data from a specific endpoint. Think of it as asking for information.</li>
<li><strong>POST:</strong> This method sends data to a specific endpoint. For example, you can send a message or submit a form. The information will be added to the database.</li>
<li><strong>PUT:</strong> This method is used to update a record or data value at a designated endpoint. You're making changes to existing information.</li>
<li><strong>DELETE:</strong> This method erases data from a specific endpoint. It's like discarding unnecessary things.</li>
</ul>
<p>One widely adopted way of checking APIs is through the browser.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/12/image-35.png" alt="Getting a response from an API" width="600" height="400" loading="lazy">
<em>Getting a response from an API</em></p>
<p>To learn more ways to get data, check out this article: <a target="_blank" href="https://ijaycent.hashnode.dev/getting-started-with-application-programming-interface-api">Getting Started with Application Programming Interfaces (APIs)</a>.</p>
<h2 id="heading-how-to-fetch-data-in-react">How to Fetch Data in React</h2>
<p>There are various ways to fetch data in React. Before we begin, let’s start by writing some React boilerplate code or by creating a template in our editor.</p>
<p>Here's the command to do that:</p>
<pre><code class="lang-js">npx create-react-app ./ or npx create-vite@latest ./
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/12/image-36.png" alt="creating template for our project" width="600" height="400" loading="lazy">
<em>creating template for our project</em></p>
<p>After this, type the following command:</p>
<pre><code class="lang-js">npm run dev
</code></pre>
<p>This will start the development server.</p>
<p>In the image above, you'll notice that I added a period (.) immediately following the command.</p>
<p>This is a convenient shorthand for creating the template within the current directory.</p>
<h2 id="heading-different-ways-to-fetch-data-in-react">Different Ways to Fetch Data in React</h2>
<h3 id="heading-1-use-the-stale-while-revalidate-swr-method">1. Use the stale-while-revalidate (SWR) method</h3>
<p>This method is used to fetch data from a server and is used in React. It manages any issues that may arise when obtaining the data and helps you manage its storage. <code>SWR</code> includes <code>useState()</code> and <code>useEffect()</code>, so  there is no need to import them.</p>
<h4 id="heading-the-advantages-of-swr">The advantages of SWR</h4>
<ol>
<li><code>SWR</code> speeds up your app's loading time by showing older data while fetching the latest information.</li>
<li>It reduces the server burden by minimizing the number of requests.</li>
<li>Even if there is a bad connection, or no connection at all, SWR can still display previously fetched data.</li>
<li>SWR handles data acquisition and maintenance without the use of sophisticated coding.</li>
<li>It knows what to do if something goes wrong while gathering data.</li>
<li>You can change how SWR operates to better suit your app.</li>
<li>It provides a consistent approach to collecting and saving data across your app.</li>
</ol>
<h4 id="heading-how-to-use-swr-to-get-data">How to use <code>SWR</code> to get data</h4>
<ul>
<li>In your application, create a file.</li>
<li>Then install the package <a target="_blank" href="https://swr.vercel.app/">SWR</a> into your application with the following command:</li>
</ul>
<pre><code class="lang-js">npm i swr
</code></pre>
<ul>
<li>Import <code>useSWR</code>, which is a hook that has both <code>useState()</code> and <code>useEffect()</code>, into your application.</li>
<li>Then define a constant variable on top called <code>fetcher</code> and assign it a function. </li>
</ul>
<p>This function is capable of receiving any number of arguments, denoted by the <code>...args</code> syntax.</p>
<p>The function looks like this:<br><code>const fetcher = (...args) =&gt; fetch(...args).then(res =&gt; res.json())</code></p>
<p>Here is how then<code>Swr.jsx</code> should look like:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> useSWR <span class="hljs-keyword">from</span> <span class="hljs-string">'swr'</span>;

<span class="hljs-comment">// Import useSWR from swr package</span>

<span class="hljs-comment">// created function to handle API request</span>
<span class="hljs-keyword">const</span> fetcher = <span class="hljs-function">(<span class="hljs-params">...args</span>) =&gt;</span> fetch(...args).then(<span class="hljs-function">(<span class="hljs-params">res</span>) =&gt;</span> res.json());

<span class="hljs-keyword">const</span> Swr = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">const</span> {
    <span class="hljs-attr">data</span>: countries,
    error,
    isValidating,
  } = useSWR(<span class="hljs-string">'https://restcountries.com/v2/all'</span>, fetcher);

  <span class="hljs-comment">// Handles error and loading state</span>
  <span class="hljs-keyword">if</span> (error) <span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'failed'</span>&gt;</span>failed to load<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>;
  <span class="hljs-keyword">if</span> (isValidating) <span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"Loading"</span>&gt;</span>Loading...<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>;

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      {countries &amp;&amp;
        countries.map((country, index) =&gt; (
          <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">key</span>=<span class="hljs-string">{index}</span> <span class="hljs-attr">src</span>=<span class="hljs-string">{country.flags.png}</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">'flag'</span> <span class="hljs-attr">width</span>=<span class="hljs-string">{100}</span> /&gt;</span>
        ))}
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
};

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> Swr;
</code></pre>
<p>Let's see what's going on in the above code:</p>
<ul>
<li>The first thing we did was import the <code>SWR</code> library.</li>
<li>Next, we defined a function to handle the API request.</li>
<li>In return, we used the <code>map()</code> method to iterate through the list of nations.</li>
<li>We put a <code>&amp;&amp;</code> line to ensure that if there are no issues and the data has been correctly received (meaning the <code>countries</code> variable is not null or undefined), it will proceed to map over the data and show an <code>image</code> element for each nation.</li>
<li>Finally, we exported the component to the application's root <code>App.jsx</code> or <code>Index.jsx</code> so it could be viewed in the browser.</li>
</ul>
<p>Here's the result:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/12/chrome_0YIvgfhfCl.gif" alt="Using Swr" width="600" height="400" loading="lazy">
<em>The result of using Swr</em></p>
<h3 id="heading-2-use-the-javascript-fetch-method">2. Use the JavaScript <code>Fetch()</code> method</h3>
<p>The <code>fetch()</code> method is well-known for retrieving data from APIs. It is recognized as the simplest and most used approach. </p>
<h4 id="heading-the-advantages-of-using-the-fetch-method">The advantages of using the <code>fetch()</code> method</h4>
<ol>
<li>The <code>fetch()</code> method makes it simple to get information from the internet using JavaScript.</li>
<li>It lets you send extra details to the server, like who you are or what kind of data you want.</li>
<li>It's designed to work well in most of the newer web browsers.</li>
<li>The <code>fetch()</code> method supports different <code>HTTP</code> methods. These methods include get, post, put, and delete. They give you flexibility in interacting with APIs.</li>
<li>The <code>fetch()</code> method is a native JavaScript method. You can use it without any external libraries or dependencies. This makes it lightweight and efficient.</li>
</ol>
<h4 id="heading-how-to-use-fetch-to-get-data">How to use <code>fetch()</code> to get data</h4>
<ul>
<li>In your application, create a file.</li>
<li>Then import <code>useState()</code> for <a target="_blank" href="https://ijaycent.hashnode.dev/simplify-your-react-programming-effortlessly-with-these-8-amazing-hooks">state management in React.</a></li>
<li>Next, import <code>[useEffect](https://www.freecodecamp.org/news/react-useeffect-absolute-beginners/)()</code>, as it will make the data from the API render.</li>
</ul>
<p>Here is how the <code>Fetch.jsx</code> should look like:</p>
<pre><code class="lang-javascript">
<span class="hljs-keyword">import</span> { useState, useEffect } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;
<span class="hljs-keyword">const</span> Fetch = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">const</span> [photos, setPhotos] = useState([]);
  useEffect(<span class="hljs-function">() =&gt;</span> {
    fetch(<span class="hljs-string">'https://jsonplaceholder.typicode.com/photos'</span>)
      .then(<span class="hljs-function">(<span class="hljs-params">res</span>) =&gt;</span> {
        <span class="hljs-keyword">return</span> res.json();
      })
      .then(<span class="hljs-function">(<span class="hljs-params">data</span>) =&gt;</span> {
        <span class="hljs-built_in">console</span>.log(data);
        setPhotos(data);
      });
  }, []);
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>

      {photos.map((photo) =&gt; (
        <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">key</span>=<span class="hljs-string">{photo.id}</span> <span class="hljs-attr">src</span>=<span class="hljs-string">{photo.url}</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">{photo.title}</span> <span class="hljs-attr">width</span>=<span class="hljs-string">{100}</span> /&gt;</span>
      ))}
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
};
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> Fetch;
</code></pre>
<p>Inside <code>useEffect()</code>, we fetch our data by sending a request with the API key. The response comes back in JSON (JavaScript Object Notation).</p>
<p>In the return statement, we process the received photos by utilizing a <a target="_blank" href="https://www.w3schools.com/jsref/jsref_map.asp"><code>map()</code></a> function to iterate through each item.</p>
<p>In our specific scenario, we are only interested in the photos. We render them in the browser by displaying them in the main file of the application, or root. The main file could be <code>App.jsx</code> or <code>Index.js</code>.</p>
<p>Here is how the <code>App.jsx</code> file looks:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/12/image-38.png" alt="Image" width="600" height="400" loading="lazy">
<em>The root of the application</em></p>
<p>And here's the result:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/12/image-39.png" alt="Image" width="600" height="400" loading="lazy">
<em>using fetch()</em></p>
<h3 id="heading-3-use-the-react-query-library">3. Use the <code>React Query</code> library</h3>
<p><code>React Query</code>, also known as <code>TanStack Query</code>, is useful for managing data in React applications. The difference between the two names is  the version.</p>
<p>Using React Query is easy and makes handling data in your app feel almost automatic, like it's taking care of things for you. For instance, fetching, caching, synchronizing, and updating server states in your applications.</p>
<h4 id="heading-advantages-of-the-react-query-method">Advantages of the <code>React Query</code> method</h4>
<ol>
<li>The data retrieved from APIs is cached by <code>React Query</code>. You can retrieve the same data from the cache again. This saves time by avoiding a new network request.</li>
<li>The program can automatically re-fetch data when specific conditions are met. These conditions include regaining focus or a set time passing.</li>
<li><code>React Query</code> has optimistic updates that can update the UI. It shows the expected outcome of a mutation without server confirmation. A smoother user experience is achieved as a result.</li>
<li>It is made to work with React, making use of its component-based architecture to enable smooth integration.</li>
<li><code>React Query</code> includes DevTools that offer insights into query, mutation, and caching state. These tools help with debugging and optimizing performance.</li>
</ol>
<h4 id="heading-how-to-use-react-query-to-get-data">How to use <code>React Query</code> to get data</h4>
<p>To begin, use this command to install the React-Query library (TanStack Query) into your application:</p>
<pre><code class="lang-js">npm i @tanstack/react-query
</code></pre>
<p>To make things work, use <code>QueryClientProvider</code> from <code>@tanstack/react-query</code>.</p>
<p>Wrap your application, which is the <code>Main.jsx</code> component, with it and pass <code>queryClient</code> as a prop. It comes automatically from the initialized <code>QueryClient</code>.</p>
<p>Here is how the <a target="_blank" href="https://www.freecodecamp.org/news/p/2cdb9f65-0c70-4a9c-832b-b073c0a83856/Main.jsx"><code>Main.jsx</code></a> file should look like:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>
<span class="hljs-keyword">import</span> ReactDOM <span class="hljs-keyword">from</span> <span class="hljs-string">'react-dom/client'</span>
<span class="hljs-keyword">import</span> App <span class="hljs-keyword">from</span> <span class="hljs-string">'./App.jsx'</span>
<span class="hljs-keyword">import</span> <span class="hljs-string">'./index.css'</span>
<span class="hljs-keyword">import</span> { QueryClient, QueryClientProvider } <span class="hljs-keyword">from</span> <span class="hljs-string">'@tanstack/react-query'</span>;

<span class="hljs-keyword">const</span> queryClient = <span class="hljs-keyword">new</span> QueryClient();

ReactDOM.createRoot(<span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'root'</span>)).render(
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">React.StrictMode</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">QueryClientProvider</span> <span class="hljs-attr">client</span>=<span class="hljs-string">{queryClient}</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">App</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">QueryClientProvider</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">React.StrictMode</span>&gt;</span></span>
)
</code></pre>
<p>Now that we have done this, we can fetch the data:</p>
<ul>
<li>In your application, create a file. </li>
<li>Import  the hook from <code>@tanstack/react-query</code> at the top of your file:</li>
</ul>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> { useQuery } <span class="hljs-keyword">from</span> <span class="hljs-string">'@tanstack/react-query'</span>;
</code></pre>
<ul>
<li>The <code>useQuery hook</code> is defined with two crucial parameters in object form. These parameters are <code>queryFn</code> and <code>queryKey</code>.</li>
<li><code>queryFn</code> handles fetching data from the endpoint.</li>
<li><code>queryKey</code> serves as the unique identifier for the data obtained.</li>
</ul>
<p>As mentioned earlier, <code>React Query</code> simplifies and manages loading states and errors. You don't need a separate <code>useState() hook</code>.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { useQuery } <span class="hljs-keyword">from</span> <span class="hljs-string">'@tanstack/react-query'</span>;
<span class="hljs-keyword">const</span> Query = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">const</span> { <span class="hljs-attr">data</span>: comments, isLoading, error } = useQuery({
    <span class="hljs-attr">queryFn</span>: <span class="hljs-function">() =&gt;</span>
      fetch(<span class="hljs-string">'https://jsonplaceholder.typicode.com/comments?_limit=10'</span>).then(
        <span class="hljs-function">(<span class="hljs-params">res</span>) =&gt;</span> res.json()
      ),
    <span class="hljs-attr">queryKey</span>: [<span class="hljs-string">'comments'</span>],
  });

  <span class="hljs-comment">// Show a loading message while data is fetching</span>
  <span class="hljs-keyword">if</span> (isLoading) {
    <span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Loading...<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span></span>;
  }

  <span class="hljs-comment">// to handle error</span>
  <span class="hljs-keyword">if</span> (error) {
    <span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"error"</span>&gt;</span>Error: error fetching<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  }

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h1</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'title'</span>&gt;</span>Email address of users<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
      {comments.map((comment) =&gt; (
        <span class="hljs-tag">&lt;<span class="hljs-name">h2</span> <span class="hljs-attr">key</span>=<span class="hljs-string">{comment.id}</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"users"</span>&gt;</span>
          {comment.id}.  
            {comment.email}
        <span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
      ))}
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
};
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> Query;
</code></pre>
<p>Here's the result:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/12/chrome_bj4mya9YSt-1.gif" alt="The result from the endpoint" width="600" height="400" loading="lazy">
<em>The result from the endpoint</em></p>
<p>As previously mentioned, <code>useQuery()</code> manages the loading and error states as long as it's defined. </p>
<p>When your internet service is bad, the browser may show these conditions because it couldn't get the data.</p>
<p>Here's an example:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/12/chrome_iPqmAfOUXF.gif" alt="Loading and Error state" width="600" height="400" loading="lazy">
<em>Loading and Error state</em></p>
<h3 id="heading-4-use-the-axios-library">4. Use the <code>Axios</code> Library</h3>
<p>Axios is a third library package that we can add to our program to retrieve information from an API. Because Axios is used in both web browsers and server-side JavaScript, it is useful for a wide range of tasks.</p>
<h4 id="heading-advantages-of-the-axios-library">Advantages of the <code>Axios</code> Library</h4>
<ol>
<li>Axios is simple and easy to understand. It's a clear and straightforward way to get data from an API.</li>
<li>It's designed to work well in most of the newer web browsers.</li>
<li>You don't have to add anything extra to your code to use Axios. It's ready to go as part of JavaScript.</li>
</ol>
<h4 id="heading-how-to-use-axios-library-to-get-data">How to use Axios Library to get data</h4>
<ul>
<li>In your application, create a file.</li>
<li>Install the package <a target="_blank" href="https://www.npmjs.com/package/axios"><code>Axios</code></a> into your application like this:</li>
</ul>
<pre><code class="lang-js">npm i axios
</code></pre>
<ul>
<li>Import <code>Axios</code> library into your application.</li>
<li>Import <code>useState()</code>, which <a target="_blank" href="https://ijaycent.hashnode.dev/simplify-your-react-programming-effortlessly-with-these-8-amazing-hooks">enables state management in React.</a> </li>
<li>Then import <code>[useEffect](https://www.freecodecamp.org/news/react-useeffect-absolute-beginners/)()</code> which facilitates the rendering of data from the API.</li>
</ul>
<p>Here is what the <a target="_blank" href="https://www.freecodecamp.org/news/p/2cdb9f65-0c70-4a9c-832b-b073c0a83856/Axios.jsx"><code>Axios.jsx</code></a> file should look like:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { useEffect, useState } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>
<span class="hljs-keyword">import</span> axios <span class="hljs-keyword">from</span> <span class="hljs-string">'axios'</span>
<span class="hljs-keyword">const</span> Axios = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">const</span> [meals, setMeals] = useState([])
  useEffect(<span class="hljs-function">() =&gt;</span> {
    axios.get(<span class="hljs-string">'https://www.themealdb.com/api/json/v1/1/random.php'</span>)
      .then(<span class="hljs-function">(<span class="hljs-params">res</span>) =&gt;</span> {
        setMeals(res.data.meals);
      })
  }, [])

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      {meals.map((meal) =&gt; (
      <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">key</span>=<span class="hljs-string">{meal.idMeal}</span> <span class="hljs-attr">src</span>=<span class="hljs-string">{meal.strMealThumb}</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">{meal.strMeal}</span> <span class="hljs-attr">width</span>=<span class="hljs-string">{400}/</span>&gt;</span>
      ))}
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
</code></pre>
<p>Inside <code>useEffect()</code> we fetch our data by sending a request with the API key. The response comes back in JSON (JavaScript Object Notation).</p>
<p>We use a <code>map()</code> function in the return statement. The <code>map()</code> function helps us process the meals. It iterates through each piece of information.</p>
<p>In our specific scenario, we are only interested in the images of each meal.</p>
<p>To display them in the browser, we render them in the root of the application, which could be <code>App.jsx</code> or <code>Index.js</code>.</p>
<p>Here's the result:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/12/chrome_NB3f9HtpPL.gif" alt="code" width="600" height="400" loading="lazy">
<em>using axios library (Result)</em></p>
<h3 id="heading-5-use-the-usefetch-custom-hook-from-react-fetch-hook">5. Use the <code>useFetch</code> custom hook from react-fetch-hook</h3>
<p>A custom hook in React is a JavaScript function. It is reusable and leverages React's built-in hooks. The purpose is to encapsulate and share logic across multiple components. This promotes code modularity and maintainability.</p>
<p>A custom hook allows us to reuse the fetching logic in various components of our app.</p>
<p>In React, custom hooks are often named with a convention, such as <code>useFetch</code>. Typically, any custom hook follows a naming pattern that starts with the keyword <code>use</code>.</p>
<h4 id="heading-advantages-of-a-custom-hook">Advantages of a custom hook</h4>
<ol>
<li>Custom hooks make the reusability of logic across multiple components easy.</li>
<li>Custom hooks make the code readable, concise, and maintainable by abstracting complex logic.</li>
<li>Custom hooks allow you to test code independently, ensuring they work as expected before using them in components.</li>
<li>Custom hooks allow you to build bigger features with less code. They prevent complexity in your main code.</li>
</ol>
<h4 id="heading-how-to-get-data-using-a-custom-hook">How to get data using a custom hook</h4>
<ul>
<li>Open the terminal in your application. </li>
<li>Type this command to install the required package.</li>
</ul>
<pre><code class="lang-js">npm install react-fetch-hook
</code></pre>
<ul>
<li>Once the installation is complete, navigate to the start of your application's file. Add the following line to import the <code>useFetch hook</code>:</li>
</ul>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> useFetch <span class="hljs-keyword">from</span> <span class="hljs-string">"react-fetch-hook"</span>;
</code></pre>
<p>Now, you can use the <code>useFetch</code> hook to interact with an API. </p>
<ol>
<li>Create variables to keep track of errors, loading states, and data by using destructuring.</li>
<li>In your application, make API calls using the <code>useFetch hook</code>. Update the variables.</li>
</ol>
<p>Code example:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> useFetch <span class="hljs-keyword">from</span> <span class="hljs-string">"react-fetch-hook"</span>;

<span class="hljs-keyword">const</span> UseFetch = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">const</span> { <span class="hljs-attr">data</span>: posts, isLoading, error } = useFetch(<span class="hljs-string">'https://jsonplaceholder.typicode.com/posts'</span>);

  <span class="hljs-comment">// Show a loading message while data is fetching</span>
  <span class="hljs-keyword">if</span> (isLoading) {
    <span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Loading...<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span></span>;
  }

  <span class="hljs-comment">// Handle error</span>
  <span class="hljs-keyword">if</span> (error) {
    <span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"error"</span>&gt;</span>Error: error fetching<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>;
  }

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h1</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'title'</span>&gt;</span>Post of users<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
      {posts.map((post) =&gt; (
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">key</span>=<span class="hljs-string">{post.id}</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"card"</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">h2</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'users'</span>&gt;</span>{post.title}<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>{post.body}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
      ))}
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
};
</code></pre>
<p>Here's the result:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/12/chrome_Rx7VMtOqLZ.gif" alt="Data called using the custom hook" width="600" height="400" loading="lazy">
<em>Data called using the custom hook</em></p>
<p>## </p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>This article talks about different ways and tools to fetch API data in React.Understanding these methods will assist you in creating advanced applications. </p>
<p>Utilizing React to construct dynamic applications and obtain data from APIs is vital. Many apps rely on data from APIs, so developers need to know the best and quickest ways to get that data. </p>
<p>Whether you're a beginner or experienced developer, every method has its benefits. These benefits can improve your programming skills. They can also help you create reliable apps that use data.</p>
<p>If you found this tutorial helpful, please share it with other developers. They may also find it interesting. You can also stay updated on my latest projects by following me on <a target="_blank" href="https://https//twitter.com/ijaydimples">Twitter</a> and <a target="_blank" href="https://www.linkedin.com/in/ijeoma-igboagu/">LinkedIn</a>.</p>
<p>Thank you for reading💖</p>
<h3 id="heading-resource">Resource</h3>
<ul>
<li><a target="_blank" href="https://ijaycent.hashnode.dev/public-apis-developers-can-use-in-their-projects">Public APIs Developers can use in their project</a></li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Deploy Your Websites and Apps – User-Friendly Deployment Strategies ]]>
                </title>
                <description>
                    <![CDATA[ Deploying your application is a key aspect of software development. Typically, having an app on your local system isn't enough – it needs to be accessible online. So choosing a suitable and user-friendly hosting and deployment plan is vital. The key ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-deploy-websites-and-applications/</link>
                <guid isPermaLink="false">66b9f47675413b5a1215b325</guid>
                
                    <category>
                        <![CDATA[ deployment ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Applications ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ website development, ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ijeoma Igboagu ]]>
                </dc:creator>
                <pubDate>Wed, 09 Aug 2023 14:23:41 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/08/cover-friendly-deploy.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Deploying your application is a key aspect of software development. Typically, having an app on your local system isn't enough – it needs to be accessible online. So choosing a suitable and user-friendly hosting and deployment plan is vital.</p>
<p>The key to making the right decision lies in understanding the goal of your application. Perhaps it’s a simple website, a one-page app, or it requires serverless or cloud functions. Having clarity about these aspects will significantly ease the deployment process.</p>
<p>In this article, we will look at a few popular methods for deploying your application that will help tackle these challenges.</p>
<h2 id="heading-what-well-cover">What we'll cover:</h2>
<ol>
<li><p><a class="post-section-overview" href="#heading-what-to-consider-when-deploying-to-a-hosting-platform">What to consider when deploying a hosting platform</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-deploy-a-website-or-app-with-render">How to deploy a website or app with Render</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-deploy-a-website-or-app-with-surge">How to deploy a website or app with Surge</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-deploy-a-website-or-app-with-vercel">How to deploy a website or app with Vercel</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-deploy-a-website-or-app-with-github-pages">How to deploy a website or app with GitHub Pages</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-deploy-a-website-or-app-with-netlify">How to deploy a website or app with Netlify</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ol>
<h2 id="heading-what-to-consider-when-deploying-to-a-hosting-platform">What to Consider when Deploying to a Hosting Platform</h2>
<p>There are several factors to take into account when selecting a hosting platform:</p>
<ol>
<li><p><strong>Purpose</strong>: Before you host your application, consider the technologies you used to build it and how much storage the platform can handle.</p>
</li>
<li><p><strong>Interface</strong>: A good interface is essential for a hosting platform. Look for a control panel or dashboard that allows you to easily administer your website.</p>
</li>
<li><p><strong>Reviews</strong>: Look at the hosting service's reviews and read what other clients have to say.</p>
</li>
<li><p><strong>Security</strong>: To safeguard your website and data, it is essential to have the right security measures in place.</p>
</li>
<li><p><strong>Support</strong>: You should always have someone there to help you out when you need it.</p>
</li>
</ol>
<h3 id="heading-why-is-deploying-an-application-important">Why is Deploying an Application Important?</h3>
<p>If you've built an app, there are various reasons you may want or need to deploy it, such as:</p>
<ol>
<li><p>It showcases professionalism and credibility to users.</p>
</li>
<li><p>It increases the accessibility of the application to a broader audience.</p>
</li>
<li><p>It enables user interaction and feedback.</p>
</li>
<li><p>It facilitates data analysis and provides insights for informed decision-making.</p>
</li>
<li><p>It identifies areas for improvement in the application.</p>
</li>
</ol>
<h3 id="heading-whats-the-benefit-of-choosing-a-user-friendly-deployment-method">What's the Benefit of Choosing a User-Friendly Deployment Method?</h3>
<p>Opting for a more approachable deployment method brings significant advantages:</p>
<ol>
<li><p><strong>Collaboration</strong>: When working together as a team, it’s useful to have straightforward methods to deploy your application. This makes collaboration and teamwork easy. These will encourage cooperation throughout the deployment process.</p>
</li>
<li><p><strong>Efficiency</strong>: A user-friendly deployment method simplifies the process.</p>
</li>
<li><p><strong>Simplicity</strong>: Choosing a hosting platform that is easy to understand will benefit everyone involved.</p>
</li>
<li><p><strong>Reliability</strong>: easy to use deployment methods ensure a more reliable application and minimise potential disruptions.</p>
</li>
</ol>
<h2 id="heading-how-to-deploy-a-website-or-app-with-render">How to Deploy a Website or App with Render</h2>
<p>Render provides an interface for quick and straightforward publishing of static web content. Let's now go through how to deploy an app to Render step by step.</p>
<p>Step 1: First, ensure you have deployed your work or code from your editor to your GitHub account.</p>
<p>Step 2: Open a new browser tab and navigate to the <a target="_blank" href="https://render.com/">Render website</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743002851078/4bf085d2-7c38-432b-93bf-95f2b02368e7.gif" alt="render website" class="image--center mx-auto" width="1920" height="920" loading="lazy"></p>
<p><em>Render website</em></p>
<p>Step 3: Select the “GET STARTED” button on Render's home page to get going.</p>
<ul>
<li><p>You can use your GitHub, GitLab, or Bitbucket account when signing up. Choose the GitHub option and follow the steps to grant Render access to your GitHub account.</p>
</li>
<li><p>If you already have a Render account, click the “Sign in” button to be redirected to the Sign-in page. You can sign in via email and authenticate using your Google account or your GitHub account.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743002894595/542d8097-4fcc-409a-bc80-a599656152c9.gif" alt="Render sign in page" class="image--center mx-auto" width="1920" height="991" loading="lazy"></p>
<p><em>Sign in page</em></p>
<p>Step 4: Once you access the dashboard, click the “New” button.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743002941009/36239b95-8cf3-4633-9b27-fb966a133270.png" alt="Render dashboard" class="image--center mx-auto" width="1704" height="536" loading="lazy"></p>
<p><em>Dashboard of Render</em></p>
<p>Step 5: Upon doing so, a drop-down menu will appear. It'll show you a comprehensive list of services provided by Render.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743003263069/d8053161-5ef1-4c1b-a047-c635c75df2eb.png" alt="List of services offered by render" class="image--center mx-auto" width="1600" height="481" loading="lazy"></p>
<p><em>List of Services offered by render</em></p>
<p>Step 6: Clicking “Static Site” from the drop-down menu will lead you to the “Create a New Static Site” page. From there, you can select the repository you wish to host.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743003315411/fe9a7eb8-2303-48ad-b83a-fb471e821e05.png" alt="Create a new static site page" class="image--center mx-auto" width="1600" height="826" loading="lazy"></p>
<p><em>Create a New Static Site</em></p>
<p>Step 7: After selecting the repository you wish to host, you will be directed to the deployment platform. There, you can provide the necessary information to host the application and click the “Create Static Site” button for it to deploy.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743003358045/c37346e8-5793-40a3-95fc-17c388b110ed.png" alt="Render deployment" class="image--center mx-auto" width="1838" height="1292" loading="lazy"></p>
<p><em>Deploying the app using Render</em></p>
<p>Here's what the final output should look like:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743003407878/76f120fe-8754-4e7c-8746-6107f47d7425.png" alt="Hosted application" class="image--center mx-auto" width="893" height="759" loading="lazy"></p>
<p><em>Hosted application</em></p>
<h3 id="heading-pros-of-deploying-with-render">Pros of Deploying With Render</h3>
<ul>
<li><p>Render has a free tier for hosting basic static websites.</p>
</li>
<li><p>It provides a flexible price structure that ensures transparency and cost-effectiveness.</p>
</li>
<li><p>It makes deployment easy. They provide an interface and connection with standard development tools and platforms. It also supports a wide range of programming languages, frameworks, and databases.</p>
</li>
<li><p>It delivers a variety of integrated features that improve the hosting experience.</p>
</li>
<li><p>It has good customer service support.</p>
</li>
</ul>
<h3 id="heading-cons-of-deploying-with-render">Cons of Deploying With Render</h3>
<ul>
<li><p>Render specializes in static websites, Docker containers, and serverless functions.</p>
</li>
<li><p>For more complex/bigger applications, there's a paid plan. You'll need to go through their price structure and understand the charges related to your usage.</p>
</li>
<li><p>There is a learning curve, especially for newcomers to the platform.</p>
</li>
</ul>
<h2 id="heading-how-to-deploy-a-website-or-app-with-surge">How to Deploy a Website or App with Surge</h2>
<p>This friendly platform and tool make it quick and easy to deploy static websites online.</p>
<p>Deploying your static files to <a target="_blank" href="https://https//surge.sh/">surge.sh</a> is easy using the command-line interface (CLI).</p>
<p>This command-line interface (CLI) streamlines the process of hosting and distributing your online projects.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743003449591/4825b5da-69a7-4780-924c-8c2206c82a96.png" alt="Surge website" class="image--center mx-auto" width="1600" height="825" loading="lazy"></p>
<p><em>Surge website</em></p>
<h3 id="heading-steps-to-deploy-your-site-using-surge">Steps to Deploy Your Site Using Surge</h3>
<p>First, in the terminal of your project, type the command <code>npm i -g surge</code>.</p>
<p>Then type the command <code>surge</code>.</p>
<p>And that's it! You can deploy your app without logging in into your GitHub account.</p>
<p>To see what you have deployed, first copy the successful link in the terminal. Then paste it into your browser. You should see something like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743003506734/70e7d551-2aa9-4023-980c-53a8fdd34d2d.png" alt="Hosted site with Surge" class="image--center mx-auto" width="1231" height="467" loading="lazy"></p>
<p><em>Hosted site with Surge</em></p>
<p>Like I mentioned before, Surge doesn't need extra code. You can easily deploy your app right from your editor's terminal by typing the command <code>surge</code>.</p>
<h3 id="heading-pros-of-deploying-with-surge">Pros of Deploying with Surge</h3>
<ul>
<li><p><strong>Easy to Use:</strong> Surge provides a simple deployment for static websites.</p>
</li>
<li><p><strong>Fast Deployment:</strong> It has a quick deployment time.</p>
</li>
<li><p><strong>Custom Domains:</strong> It allows you to use your domain name for your website.</p>
</li>
<li><p><strong>SSL Support:</strong> It provides free SSL certificates.</p>
</li>
<li><p><strong>Support for Single-Page Applications (SPAs):</strong> It's well-suited for deploying single-page applications.</p>
</li>
</ul>
<h3 id="heading-cons-of-deploying-with-surge">Cons of Deploying with Surge</h3>
<ul>
<li><p><strong>Limited Functions:</strong> Surge is designed for static websites.</p>
</li>
<li><p><strong>No Custom Server Configurations:</strong> It streamlines the deployment process by abstracting away server configurations.</p>
</li>
<li><p><strong>Premium Features:</strong> This platform offers free hosting for basic usage, but you'll have to pay for more features.</p>
</li>
</ul>
<h2 id="heading-how-to-deploy-a-website-or-app-with-vercel">How to Deploy a Website or App with Vercel</h2>
<p>Vercel is a hosting and deployment platform that specializes in modern web applications.</p>
<p>It is particularly well-suited for single-page applications, serverless operations, and static websites. It integrates with popular frameworks like Next.js and Gatsby.js, making deployments fast and simple.</p>
<h3 id="heading-steps-to-deploy-your-site-using-vercel">Steps to Deploy Your Site Using Vercel</h3>
<p>First, ensure that you have deployed your work or code from your editor to your GitHub account.</p>
<p>Then open a new browser tab and navigate to <a target="_blank" href="https://vercel.com/">Vercel’s website</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743003556995/7c48e8dc-6955-45c2-a068-c6c1b0e15cf6.png" alt="Vercel website" class="image--center mx-auto" width="1600" height="818" loading="lazy"></p>
<p><em>Vercel website</em></p>
<p>Head to the Vercel website and click the “Sign up” button on the homepage.</p>
<ul>
<li><p>Sign up using your GitHub account and follow the steps to grant Vercel access to your GitHub account. If you already have a Vercel account, click the “Login” button and enter your login information.</p>
</li>
<li><p>After signing up or logging in, Vercel will request access to specific information from your GitHub account. Review the required permissions and permit Vercel to proceed.</p>
</li>
</ul>
<p>Next, click on “Add New…” on the Vercel dashboard. This action will reveal a drop-down menu. From the menu, select “Project,” which will navigate you to the next page.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743003587862/a04db892-e3fe-4218-a60f-ed134e143006.gif" alt="Vercel add new project" class="image--center mx-auto" width="1920" height="991" loading="lazy"></p>
<p><em>Add New Project</em></p>
<p>On the next page, you will import your repository for deployment.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743003630267/265499e1-d1cd-4083-a05c-68dc4c9e9741.gif" alt="Vercel deployment" class="image--center mx-auto" width="1920" height="991" loading="lazy"></p>
<p><em>Vercel Deployment</em></p>
<p>Here's what the final output should look like:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743003666437/b418d602-42ca-4610-ae43-dc69bed0d954.gif" alt="Vercel hosted site" class="image--center mx-auto" width="1920" height="991" loading="lazy"></p>
<p><em>Hosted site</em></p>
<p>When deploying your application to Vercel, you may encounter some errors, often caused by routing issues.</p>
<p><strong>To fix this:</strong></p>
<ul>
<li><p>Create a file under the root of your application called <code>vercel.json</code>.</p>
</li>
<li><p>Inside the file, write the following code:</p>
</li>
</ul>
<p><code>vercel.json</code></p>
<pre><code class="lang-bash">{ <span class="hljs-string">"rewrites"</span>: [{ <span class="hljs-string">"source"</span>: <span class="hljs-string">"/(.*)"</span>, <span class="hljs-string">"destination"</span>: <span class="hljs-string">"/"</span> }] }
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743003723518/6c44d496-331e-4d09-b221-f3c3dc6c688c.png" alt="Vercel error fix" class="image--center mx-auto" width="1743" height="826" loading="lazy"></p>
<p><em>Inside your editor</em></p>
<h3 id="heading-pros-of-deploying-with-vercel">Pros of Deploying With Vercel</h3>
<ul>
<li><p><strong>Collaboration:</strong> Vercel offers tools for effective teamwork, access control, and cooperative deployments.</p>
</li>
<li><p><strong>Simple Deployment:</strong> it simplifies delivering your web apps with ease.</p>
</li>
<li><p><strong>Preview Deployments:</strong> it allows you to share and review changes before they go live. This promotes collaboration and ensures a smooth and efficient workflow.</p>
</li>
<li><p><strong>Scalability and Performance:</strong> It still guarantees great performance even with a large number of people using it.</p>
</li>
<li><p><strong>Git Integration:</strong> it makes Git integration easy.</p>
</li>
</ul>
<h3 id="heading-cons-of-deploying-with-vercel">Cons of Deploying With Vercel</h3>
<ul>
<li><p>If you are new to Vercel, you must understand how to deploy and configure your application. Reading <a target="_blank" href="https://vercel.com/docs">Vercel’s documentation</a> can help you get up to speed.</p>
</li>
<li><p>Vercel is great for small to medium-sized projects, but it may not be the best fit for large-scale applications with complex backend needs. In such cases, developers may need a hosting solution that offers more customization and scalability.</p>
</li>
</ul>
<h2 id="heading-how-to-deploy-a-website-or-app-with-github-pages">How to Deploy a Website or App with GitHub Pages</h2>
<p>GitHub Pages is a straightforward and cost-free hosting service. You can use it to host static web pages or documentation.</p>
<p>You can publish your site using GitHub Pages by submitting your code to a GitHub account and setting up a repository. Let's go through the process now.</p>
<h3 id="heading-steps-to-deploy-your-site-using-github-pages">Steps to Deploy Your Site Using GitHub Pages</h3>
<p>To use GitHub Pages to host your website, follow these simple steps:</p>
<p>First, go to GitHub's <a target="_blank" href="https://https//github.com/">website</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743003758359/0d8d7328-a8ad-4b79-a814-3a55b3a04bb1.png" alt="GitHub landing page" class="image--center mx-auto" width="1835" height="483" loading="lazy"></p>
<p><em>Github website</em></p>
<p>Then create a GitHub repository. If you don’t have a GitHub account, you'll need to click on “sign up”, or just click “sign in” if you already have an account.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743003801213/5362aa34-2ec8-430f-8809-01b42f574495.png" alt="Github signin button and signup buttons" class="image--center mx-auto" width="233" height="127" loading="lazy"></p>
<p><em>Github sign in button and sign up buttons</em></p>
<p>Create a new repository by clicking the New button in the upper-right corner of your GitHub profile.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743003843884/8c918dbf-64bf-40c8-8f32-25fa6fef157d.png" alt="Creating a new repo" class="image--center mx-auto" width="594" height="428" loading="lazy"></p>
<p><em>Creating a new repository</em></p>
<p>Give your repository a name that reflects your website.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743003887101/51f0ab61-14b5-420c-95fb-27926b4dc566.gif" alt="Entering repo name on GitHub" class="image--center mx-auto" width="1920" height="991" loading="lazy"></p>
<p><em>Repository name</em></p>
<p>Once you have finished the previous step, go back to your Editor. Copy the generated code and paste it into your editor.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743003942149/3c063b52-2bc2-4897-84af-e30ca8da18cd.png" alt="Code generated from new repository" class="image--center mx-auto" width="1600" height="142" loading="lazy"></p>
<p><em>Code generated from new repository</em></p>
<p>The code in the image above is generated when creating a new repository.</p>
<p>Go to the settings page of the newly created repository.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743003981000/6a55ae7c-2b69-44bd-bbe2-deaa695b63a5.png" alt="GitHub repo settings" class="image--center mx-auto" width="1600" height="766" loading="lazy"></p>
<p><em>Clicking on settings</em></p>
<p>Click on the settings option to redirect to the settings section. Locate and click on “Pages” in the left-hand side menu.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743004028760/9130f72b-0e6a-4a18-a72a-da948eb67fec.gif" alt="Settings section GitHub pages" class="image--center mx-auto" width="1920" height="920" loading="lazy"></p>
<p><em>GitHub pages section on the settings page</em></p>
<p>To access GitHub Pages, click on the “Pages” section. Once you’re on the GitHub Pages section, click in the drop-down menu and choose either the “master” or “main” branch. Remember to save your selection.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743004108894/40fa0220-afba-4932-8900-1106046cf9e0.gif" alt="Enabling GitHub Pages to host your site" class="image--center mx-auto" width="1920" height="920" loading="lazy"></p>
<p><em>Enabling GitHub Pages to host your site</em></p>
<p>Refresh the page to find the link leading to your published website.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743004156941/3364fd42-d47e-40ea-b147-0fc0fa4f25c6.gif" alt="GitHub seeing your hosted site" class="image--center mx-auto" width="1920" height="920" loading="lazy"></p>
<p><em>Seeing your hosted site</em></p>
<h3 id="heading-pros-of-deploying-with-github-pages">Pros of Deploying With GitHub Pages</h3>
<ul>
<li><p>GitHub Pages are simple to set up – and you can build your website there.</p>
</li>
<li><p>It's free.</p>
</li>
<li><p>GitHub’s version control system makes it simple to keep track of changes and work with others.</p>
</li>
<li><p>GitHub Pages updates your website’s code whenever you make changes to it.</p>
</li>
<li><p>It offers collaboration on projects with other developers.</p>
</li>
<li><p>It ensures your website is safe through <code>HTTPS</code> (Hyper Text Transfer Protocol) encryption.</p>
</li>
</ul>
<h3 id="heading-cons-of-deploying-with-github-pages">Cons of Deploying With GitHub Pages</h3>
<p>While GitHub Pages offer many advantages, there are a few considerations to keep in mind:</p>
<ul>
<li><p>If your website becomes too large due to file size, this can cause some performance issues.</p>
</li>
<li><p>GitHub Pages may only support simple functions.</p>
</li>
<li><p>Understanding Git, the version control system used by GitHub, is essential for managing your website’s code.</p>
</li>
</ul>
<h2 id="heading-how-to-deploy-a-website-or-app-with-netlify">How to Deploy a Website or App with Netlify</h2>
<p>Netlify integrates with Git repositories and works well with static web pages and single-page apps.</p>
<h3 id="heading-steps-to-deploy-your-site-using-netlify">Steps to Deploy Your Site Using Netlify</h3>
<p>First, you'll need to make sure that you have deployed your work or code from your editor to your GitHub account.</p>
<p>Then, open a new browser tab and navigate to the <a target="_blank" href="https://www.netlify.com/">Netlify website</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743004199311/04a14b1c-d034-4274-8657-1a9eeaaf1839.png" alt="Netlify website" class="image--center mx-auto" width="1600" height="825" loading="lazy"></p>
<p><em>Netlify website</em></p>
<p>Head to the Netlify website and click the “Sign up” button on the homepage.</p>
<ul>
<li><p>Create an account by signing up with your GitHub, GitLab, or Bitbucket credentials.</p>
</li>
<li><p>Select the GitHub option and follow the steps to grant Netlify access to your GitHub account.</p>
</li>
<li><p>If you already have a Netlify account, click the “Login” button and enter your login information. After signing up or logging in, Netlify will request access to specific information from your GitHub account. Review the required permissions and permit Netlify to proceed.</p>
</li>
</ul>
<p>Once you have finished registering, go to the dashboard where you will host your repository.</p>
<p>Netlify has two ways to host your project:</p>
<ol>
<li><p>Drag-n-drop</p>
</li>
<li><p>Importing the source code from your repository to the site.</p>
</li>
</ol>
<h4 id="heading-using-the-drag-n-drop-feature">Using the Drag-n-Drop feature:</h4>
<p>Once you have logged in, navigate to the left-hand side of the dashboard and select the “site” option.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743004230273/ef1debf2-c475-4cd1-8930-4b5c0fd2c412.png" alt="Netlify dashboard" class="image--center mx-auto" width="1600" height="766" loading="lazy"></p>
<p><em>Netlify dashboard</em></p>
<p>Before deploying your project, it’s important to include an “index.html” file. Netlify recognizes this file as the main folder for hosting your project.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743004285308/0387adf5-f015-44e0-bb91-1fb718bfdc04.png" alt="Root index.html file" class="image--center mx-auto" width="1485" height="620" loading="lazy"></p>
<p><em>Root</em> <code>index.html</code> <em>file</em></p>
<p>Go back to the website click on “site” and scroll down, you will see the drag-n-drop zone where you can drag and drop your file or you upload the folder.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743004356707/d7285059-51a0-4802-af41-1d81b560754f.png" alt="Netlify drag and drop" class="image--center mx-auto" width="1872" height="567" loading="lazy"></p>
<p><em>Netlify drag and drop</em></p>
<p>By using this feature your project will be deployed.</p>
<h4 id="heading-importing-the-source-code-from-your-repository-to-the-site">Importing the source code from your repository to the site:</h4>
<p>First, upload your code to GitHub.</p>
<p>Then access the Netlify dashboard.</p>
<p>To access the option (drop-down) menu, click on “Add New Site”. Select “Import existing project.”</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743004398011/0de1ad8d-3f36-47e9-8faa-626b399fb27e.png" alt="Netlify import existing project" class="image--center mx-auto" width="1600" height="812" loading="lazy"></p>
<p><em>Import existing project</em></p>
<p>When you click on “Import existing project,” the system will direct you to a new page. Then you can import your repository from your GitHub account or any other storage account where you stored your source code.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743004440693/669cf508-588e-47f9-8542-24552c073009.png" alt="Netlify connect to Git provider" class="image--center mx-auto" width="1600" height="825" loading="lazy"></p>
<p><em>Connect to Git provider</em></p>
<p>When you click on this button, it will navigate you to the next page where you can choose the desired repository from the available options.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743004493978/578f1241-8b07-432d-a40a-ed6549aecb53.png" alt="578f1241-8b07-432d-a40a-ed6549aecb53" class="image--center mx-auto" width="1920" height="990" loading="lazy"></p>
<p><em>Choosing repository from Netlify</em></p>
<p>After selecting the repository, the next step is configuring and deploying your site.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743004531244/4f5d1691-6cd7-4c86-8be8-fa423a6e8772.gif" alt="Deploying from Netlify" class="image--center mx-auto" width="1920" height="920" loading="lazy"></p>
<p><em>Deploying from Netlify</em></p>
<p>Here's the result:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743004569842/d7f6c8cf-855e-4d12-847b-9ec22b6bc177.gif" alt="Netlify hosted app" class="image--center mx-auto" width="1920" height="920" loading="lazy"></p>
<p><em>Hosted App</em></p>
<p>When deploying your application to Netlify, you may encounter errors, often caused by routing issues.</p>
<p><strong>To fix this:</strong></p>
<p>Create a file called <code>_redirects</code>, and inside write the following code:</p>
<p><code>_redirect file</code></p>
<pre><code class="lang-bash">/* /index.html 200
</code></pre>
<p><strong>Example</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743004628305/2fa06275-812f-42ed-8bf0-b30765a0a821.png" alt="Encounter error during deployment which is caused by routing issue" class="image--center mx-auto" width="1280" height="491" loading="lazy"></p>
<p><em>Encounter error during deployment which is caused by routing issue</em></p>
<h3 id="heading-pros-of-deploying-with-netlify">Pros of Deploying with Netlify</h3>
<ul>
<li><p><strong>Form handling capabilities:</strong> Netlify makes handling forms on your websites easy. It has a simple API that allows you to collect and process form submissions. It also integrates with popular form providers like Zapier, Mailchimp, and Slack.</p>
</li>
<li><p><strong>It’s easy to configure custom domains for your websites</strong>: it makes it simple to manage your website’s domain and security. It also ensures that your websites are secure with <code>HTTPS</code>.</p>
</li>
<li><p><strong>Web Hosting:</strong> Netlify helps you host your websites and applications. It offers static site hosting, allowing you to deploy <code>HTML</code>, <code>CSS</code>, and <code>JavaScript</code> files straight from a Git repository or by drag-and-drop.</p>
</li>
<li><p><strong>Simple Deployment:</strong> it makes deploying your website or web app straightforward. When you connect your repository, it will deploy any changes you make.</p>
</li>
<li><p><strong>Continuous Deployment:</strong> When you make updates to your source code, Netlify builds and publishes your website for you. This ensures that your website always reflects the latest changes you’ve made.</p>
</li>
</ul>
<h3 id="heading-cons-of-deploying-with-netlify">Cons of Deploying With Netlify</h3>
<ul>
<li><p><strong>Project size:</strong> This hosting platform is an excellent choice for small to medium-sized projects. But you should explore other hosting and deployment options as your website or app grows.</p>
</li>
<li><p><strong>Limited Backend Capabilities:</strong> Netlify prioritizes front-end development and static websites. Although it does have some backend functions, it may not be the best option for projects that need complex server-side processing.</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In conclusion, deploying an application is crucial so that users can access it and others can see your work. User-friendly deployment methods offer significant benefits, including collaboration, efficiency, simplicity, and reliability.</p>
<p>Here's a quick review of what we've covered here:</p>
<ul>
<li><p>Render offers a simple interface, affordable pricing, and built-in features.</p>
</li>
<li><p>Surge offers fast deployment speeds, making deploying static websites a breeze.</p>
</li>
<li><p>Vercel is an expert in creating cutting-edge web apps with scalability and preview deployments.</p>
</li>
<li><p>If you’re looking for an easy-to-use option, consider GitHub Pages. It provides several advantages, including simplicity, free hosting, version control, and <code>HTTPS</code> encryption. But, it has limited functionality and technological limitations for more sophisticated applications.</p>
</li>
<li><p>Netlify is a user-friendly platform that's great for quickly deploying static websites and web apps. It's perfect for projects that want easy setup, automatic deployment, and modern development features</p>
</li>
</ul>
<p>What you choose will depend on the particular needs and objectives of your application and the technical know-how of the developers working on it.</p>
<p>And if you want to improve your Git skills, you can read this Git Command article.</p>
<p>If you found this tutorial helpful, please share it with fellow developers who may also find it interesting. You can also stay updated on my latest projects by following me on <a target="_blank" href="https://https//twitter.com/ijaydimples">Twitter</a> and <a target="_blank" href="https://https//www.linkedin.com/in/ijeoma-igboagu/">LinkedIn</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Manage State in Your Applications – useState() vs Redux ]]>
                </title>
                <description>
                    <![CDATA[ State management is crucial for handling an application's data, how users interact with it, and how different parts of the app behave.  And it's not something you'll use only in React.js, but also in other popular tools like Angular.js, Vue.js, and N... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/usestate-vs-redux-state-management/</link>
                <guid isPermaLink="false">66b9f48468badebf96ed5f9a</guid>
                
                    <category>
                        <![CDATA[ React ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Redux ]]>
                    </category>
                
                    <category>
                        <![CDATA[ State Management  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ijeoma Igboagu ]]>
                </dc:creator>
                <pubDate>Mon, 31 Jul 2023 21:35:43 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/07/cover-react-redux.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>State management is crucial for handling an application's data, how users interact with it, and how different parts of the app behave. </p>
<p>And it's not something you'll use only in <a target="_blank" href="https://react.dev/">React.js</a>, but also in other popular tools like <a target="_blank" href="https://angularjs.org/">Angular.js,</a> <a target="_blank" href="https://vuejs.org/">Vue.js,</a> and <a target="_blank" href="https://nextjs.org/">Next.j</a>s.</p>
<p>There are two common ways to manage a state: useState and Redux.  But there are also other options like <a target="_blank" href="https://mobx.js.org/README.html">MobX</a>, <a target="_blank" href="https://www.npmjs.com/package/zustand">Zustand</a>, and <a target="_blank" href="https://recoiljs.org/">Recoil</a>.</p>
<p>In this article, we'll learn about state management and why it's important. We'll also explore common state management methods and understand how they work.</p>
<p> After reading this article, you'll be able to pick the best state management method for your app.</p>
<h3 id="heading-prerequisites">Prerequisites</h3>
<ul>
<li>Have an understanding of React.</li>
<li>Make sure you install <a target="_blank" href="https://nodejs.org/en">Node.js</a> on your system.</li>
</ul>
<h2 id="heading-what-is-state-management-and-why-is-it-important">What is State Management and Why Is It Important?</h2>
<p>State management is a crucial part of application development. It lets programmers control how the app responds to different events and user actions. </p>
<p>It helps you create dynamic and interactive interfaces, making the user experience better.</p>
<h3 id="heading-what-sort-of-sitesapps-use-state-management">What Sort of Sites/Apps Use State Management?</h3>
<p>State management is used in lots of websites and apps, from simple to complex ones. </p>
<p>React and frameworks like Angular.js, Vue.js, and Next.js often use state management to handle data and control how components behave.</p>
<h3 id="heading-what-to-consider-when-choosing-a-state-management-strategy">What to Consider When Choosing a State Management Strategy</h3>
<ol>
<li><strong>The application's complexity</strong>: For simple apps with few components, use <code>useState()</code>. For complex apps with extensive state interactions, choose <code>Redux</code>.</li>
<li><strong>Team size and skill level:</strong> <code>useState()</code> is okay for smaller teams or developers new to state management because it's easy to understand. <code>Redux</code> can be good for larger teams with experienced developers.</li>
<li><strong>Sharing State:</strong> <code>Redux</code> centralized state management is easier to use in some cases than <code>useState()</code>.</li>
<li><strong>Scalability:</strong> <code>Redux</code>  offers advanced features that help manage complex states.</li>
</ol>
<h2 id="heading-state-management-examplesusestate-vs-redux">State Management Examples:<code>useState()</code> vs <code>Redux</code></h2>
<p>To understand state management better, let's check out a practical example that shows how <code>useState()</code> and <code>Redux</code> work in React.</p>
<h3 id="heading-setting-up-the-project">Setting Up the Project</h3>
<p>First, go to the project folder. Create a React boilerplate using the create-react-app command or the Vite tool.</p>
<p>I prefer <strong><a target="_blank" href="https://vitejs.dev/">vite</a></strong> (and this is what the React document currently recommends), because it's faster for development and easier to configure. Vite is also more versatile and supports other front-end frameworks such as Svelte. But if you prefer, create-react-app is still an option.</p>
<p>Next, in the terminal of your editor, type this command:</p>
<pre><code class="lang-javascript">npx create-react-app ./ or npx create-vite@latest ./
</code></pre>
<p><code>./</code> creates the React boilerplate for you right inside the created folder or directory.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/07/Code_Vp1nLXqZqd.gif" alt="Creating the react boilerplate (template) " width="600" height="400" loading="lazy">
<em>Creating the react boilerplate (template)</em></p>
<h3 id="heading-option-1-managing-state-with-usestate">Option 1: Managing State with <code>useState()</code></h3>
<p><code>useState()</code> is a built-in hook in React. It manages the state of React applications <strong>locally.</strong> </p>
<p><code>useState()</code> introduces state management capabilities in functional components. This means you can now use stateful logic within functional components.</p>
<p>In React, you have access to various other hooks that you can import and use in your applications. These hooks make your app more dynamic and efficient.</p>
<p>Check out this article to learn more: <a target="_blank" href="https://ijaycent.hashnode.dev/simplify-your-react-programming-effortlessly-with-these-8-amazing-hooks">Simplify your React programming effortlessly with these 8 amazing hooks</a>.</p>
<p>For more information on the <code>useState()</code> hook, <a target="_blank" href="https://www.freecodecamp.org/news/usestate-hook-3-different-examples/">you can check out this tutorial</a>. It will provide you with detailed insights and examples related to <code>useState()</code> in React.</p>
<h3 id="heading-pros-of-using-the-usestate-hook-in-a-react-application">Pros of Using the <code>useState()</code> Hook in a React Application</h3>
<ol>
<li><code>useState()</code> has a smaller footprint than external state management libraries like <code>Redux</code>. This reduces the application's bundle size and improves performance.</li>
<li>It allows for more clear and intuitive state management within functional components.</li>
</ol>
<h3 id="heading-cons-of-using-the-usestate-hook-in-a-react-application">Cons of Using the <code>useState()</code> Hook in a React Application</h3>
<ol>
<li>It is cumbersome to manage the state of complex components with many variables.</li>
<li>Due to its limited capabilities, it leads to issues like prop drilling, which can be a bit confusing if not understood.</li>
<li>It triggers a re-render of the component impacting performance.</li>
</ol>
<h3 id="heading-how-to-use-usestate-in-react-applications">How to Use  <code>useState()</code> in React Applications</h3>
<p>So let's create an application that changes the color based on the user's input.</p>
<p>Using <code>useState()</code> involves a simple process:</p>
<ul>
<li>Import the <code>useState()</code> hook from the 'react' library.</li>
<li>Define a state variable and its initial value using array destructuring.</li>
<li>Then, define another state variable that takes in the color choice of the user when typed.</li>
<li>Use the state variable and its corresponding setter function within the component's logic to read or update the state.</li>
</ul>
<p>Here's what that looks like in code:</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> React, { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;

<span class="hljs-keyword">const</span> State = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">const</span> [text, setText] = useState(<span class="hljs-string">'black'</span>);
  <span class="hljs-keyword">const</span> [color, setColor] = useState(<span class="hljs-string">'black'</span>); <span class="hljs-comment">// Another state to store the chosen color by the user</span>

  <span class="hljs-keyword">const</span> handleInputChange = <span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> {
    setText(e.target.value);
  };

  <span class="hljs-comment">// A function is been declared</span>
  <span class="hljs-keyword">const</span> handleButtonClick = <span class="hljs-function">() =&gt;</span> {
    setColor(text); <span class="hljs-comment">// it updates the chosen color when the button is clicked</span>
  };

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{{</span> <span class="hljs-attr">color:</span> <span class="hljs-attr">color</span> }}&gt;</span>
        Progressively effective resources via business metrics.
      <span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'inputBtn-container'</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
          <span class="hljs-attr">type</span>=<span class="hljs-string">'text'</span>
          <span class="hljs-attr">className</span>=<span class="hljs-string">'input'</span>
          <span class="hljs-attr">value</span>=<span class="hljs-string">{text}</span>
          <span class="hljs-attr">onChange</span>=<span class="hljs-string">{handleInputChange}</span>
        /&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'btn'</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{handleButtonClick}</span>&gt;</span>
          Change text color
        <span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
};

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> State;
</code></pre>
<p>In the above code, the state variable <code>text</code> is set to the initial state (color) using <code>useState()</code>. The <code>setText</code> function is set to update the value of color when the button is clicked.</p>
<p>The second state defined is to store the color update from the user. So the <code>text</code> color remains unchanged until the button is clicked. Once the button is clicked, the color state updates with <code>text</code> value, changing <code>text</code> color to what the user types.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/07/chrome_bJlWaFiHPQ.gif" alt="modified state of a application using useState()" width="600" height="400" loading="lazy">
<em>Result</em></p>
<h3 id="heading-option-2-managing-state-with-redux">Option 2: Managing State with <code>Redux</code></h3>
<p><code>Redux</code> is a JavaScript library for managing states in applications. It works with React and other frameworks. </p>
<p><code>Redux</code> helps you manage the <strong>global</strong> state of your app. It improves your app's performance as well.</p>
<p>Think of <code>Redux</code> as a traffic controller for the data in the app. It makes sure that the right information goes to the right places, so everything runs smoothly.</p>
<h3 id="heading-pros-of-using-redux-in-your-application">Pros of Using <code>Redux</code> in Your Application</h3>
<p><code>Redux</code> might seem complex at first, but it comes with several advantages that make learning it worthwhile:</p>
<ol>
<li><code>Redux</code> can be used with other front-ends frameworks not only in React applications (for example Angular.js, Vue.js, and Next.js).</li>
<li><code>Redux</code> allows you to store all the states in a central store, instead of scattering states across many components. This makes it easier to understand, track, and manage the application state.</li>
<li>Many large companies use <code>Redux</code> to manage the state of their application.</li>
</ol>
<h3 id="heading-cons-of-using-redux-in-your-application">Cons of Using <code>Redux</code> in Your Application</h3>
<ol>
<li>Using <code>Redux</code> can make your app more complicated, especially if you're new to it. You'll need to learn new concepts and write more code, which might take time to understand and use.</li>
<li><code>Redux</code> needs more code compared to <code>useState()</code>.</li>
<li>If your app is small or doesn't have complex state needs, using <code>Redux</code> may be unnecessary.</li>
<li>Debugging can be challenging in a complex Redux setup.</li>
</ol>
<h3 id="heading-how-to-use-redux-in-your-application">How to Use <code>Redux</code> in Your Application:</h3>
<p>First, you'll need to install the Redux package:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/06/Code_jSqM9Qi2Oc.gif" alt="how redux is been installed in your terminal " width="600" height="400" loading="lazy">
<em>Installing redux into your Code editor</em></p>
<p>The gif above shows that I ran three commands together in the terminal. This is a personal preference. </p>
<p><strong>What are these commands doing:</strong></p>
<ul>
<li><code>npm install redux</code> installs the <code>Redux</code> library.</li>
<li><code>react-redux</code> signifies that <code>Redux</code> is being used in a React application. It provides integration.</li>
<li><code>@reduxjs/toolkit</code> simplifies <code>Redux</code>, especially for beginners. It offers helpful tools and abstractions that make working with Redux easier and less complex for new developers.</li>
</ul>
<p>Next, check to make sure that <code>Redux</code> has been added to your dependencies. Look at your <code>package.json</code> file. It contains important information about the packages used in your project.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/06/redux-depency2.png" alt="react-dependencies" width="600" height="400" loading="lazy">
<em>react-dependencies</em></p>
<p>Then import {configureStore} from <code>@reduxjs/toolkit</code> to the <code>main.js</code> or <code>index.js</code>.</p>
<p>Use the provider tag to wrap up the main component of our app. Provide the <code>store</code> as an attribute (props) to the provider. This makes the store accessible globally throughout our application.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/07/image-136.png" alt="import of the store and provider at main.js or index.js file" width="600" height="400" loading="lazy">
<em>import of the store and provider tag</em></p>
<p>Let's go over some key terms used in <code>Redux</code>:</p>
<p><strong>Store</strong>: A "container" in our application is like a storage unit. Inside the store, we will define the <strong>reducer</strong>. </p>
<p><code>Redux</code> operates based on the principles of a centralized store. It  acts as a central store that holds the application's entire state. When any component needs access to the state or needs to be updated , it interacts with the store. The store then manages the data and propagates changes to the relevant parts of the application.</p>
<p><strong>Reducer</strong>: A reducer is an object that takes two inputs: the previous state and an action. It returns the updated state based on the dispatched actions. It examines the activity and decides how to update the app's state. </p>
<p>Reducers in Redux control how our app reacts to user input. This flexibility makes it easy to maintain and change our code when needed. We can use the store and Provider imports to update our application.</p>
<h3 id="heading-redux-example"><code>Redux</code> Example</h3>
<p>So let's create an application that changes the colour based on the user's input and use Redux to manage state this time.</p>
<p>First, make a folder called <code>components</code>. Inside that folder, create a file named <code>ChangeColor.jsx</code>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/07/image-137.png" alt="Initial state" width="600" height="400" loading="lazy">
<em>Initial state of the application</em></p>
<p>Here's the output:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/06/static-redux.png" alt="output" width="600" height="400" loading="lazy">
<em>static output</em></p>
<p>In your project directory, create a folder named <code>features</code>. Inside this folder, create a file called <code>Color.js</code> to hold the Redux logic for your application.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/06/color-redux.png" alt="Color.js" width="600" height="400" loading="lazy">
<em>color.js</em></p>
<p>Next, we want to enable users to input their desired color. To do that, import the useState() hook like this:</p>
<p><strong><code>ChangeColor.jsx</code></strong></p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;   <span class="hljs-comment">// useState() hook</span>

<span class="hljs-keyword">const</span> ChangeColor = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">const</span> [color, setColor] = useState(<span class="hljs-string">''</span>); 
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Progressively effective resources via business metrics.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'inputBtn-container'</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
          <span class="hljs-attr">type</span>=<span class="hljs-string">'text'</span>
          <span class="hljs-attr">className</span>=<span class="hljs-string">'input'</span>
        /&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'btn'</span>&gt;</span>change color text<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
};

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> ChangeColor;
</code></pre>
<p>At the <code>color.js</code>. This file holds the Redux logic for your application.</p>
<pre><code class="lang-js">
<span class="hljs-comment">// Import necessary functions from Redux Toolkit</span>
<span class="hljs-keyword">import</span> { createSlice } <span class="hljs-keyword">from</span> <span class="hljs-string">"@reduxjs/toolkit"</span>;<span class="hljs-comment">// Creating a slice for functionality is essential.</span>

<span class="hljs-comment">// Define the initial state for the slice</span>
<span class="hljs-keyword">const</span> initialState = <span class="hljs-string">"black"</span>


<span class="hljs-comment">// Create a slice using the createSlice function</span>
<span class="hljs-keyword">const</span> themeSlice = createSlice({
  <span class="hljs-attr">name</span>: <span class="hljs-string">'theme'</span>, <span class="hljs-comment">// Name of the slice</span>
  <span class="hljs-attr">initialState</span>: { <span class="hljs-attr">value</span>: initialState},<span class="hljs-comment">// Initial state for the slice</span>
  <span class="hljs-attr">reducers</span>: {
    <span class="hljs-attr">changeColor</span>: <span class="hljs-function">(<span class="hljs-params">state, action</span>)=&gt;</span>{
      state.value=action.payload <span class="hljs-comment">// Update the color value based on the dispatched action</span>
    },
    }
  }
})
</code></pre>
<p>Let's see what's going on in this code:</p>
<ul>
<li><code>createSlice</code> is a function from the Redux Toolkit that lets developers create reducers in a clear and organized way. It simplifies splitting logic and accessing it across the application. With createSlice, changing values and understanding the code become easier.</li>
<li><code>name</code> is a string that defines the name of the slice. This name is used as a prefix for the generated action type strings.</li>
<li><code>initialState</code> is the initial state value for the slice.</li>
<li><code>reducers</code> are objects that take two inputs – the previous state and an action. The reducer returns the updated state based on the dispatched actions. It examines the activity and decides how to update the app's state. Reducers in Redux control how our app reacts to user input. This flexibility makes it easy to maintain and change our code when needed. We can use the store and Provider imports to update our application. Using the reducer, we can manage and update the application in a structured way. It helps us track changes according to our desired logic.</li>
<li><code>state</code> refers to the data stored and managed by the application. It holds the current values of variables, properties, or fields that determine how the application behaves and looks.</li>
<li><code>action</code> is a plain JavaScript object that describes an intention to change the state. It's how we communicate with the reducers to initiate state updates.</li>
</ul>
<p>After defining the reducer logic, we can make it reusable by exporting it from the file and importing it wherever we need to manage the state. For example, in the <code>changeColor.jsx</code> file.</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> { createSlice } <span class="hljs-keyword">from</span> <span class="hljs-string">"@reduxjs/toolkit"</span>;

<span class="hljs-keyword">const</span> initialState=<span class="hljs-string">"black"</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> themeSlice = createSlice({
  <span class="hljs-attr">name</span>: <span class="hljs-string">'theme'</span>,
  <span class="hljs-attr">initialState</span>: { <span class="hljs-attr">value</span>: initialState},
  <span class="hljs-attr">reducers</span>: {
    <span class="hljs-attr">changeColor</span>: <span class="hljs-function">(<span class="hljs-params">state, action</span>)=&gt;</span>{
      state.value=action.payload
    }
  }
})
<span class="hljs-comment">// Export the reducer function</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> { changeColor } = themeSlice.actions
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> themeSlice.reducer
</code></pre>
<p>Let's see what's going on in this code:</p>
<ul>
<li>We will import the <code>useSelector</code> hook from <code>react-redux</code> to get data from the Redux store. This helps us get the current color value from the state.</li>
<li>We will import the <code>useDispatch</code> hook from <code>react-redux</code> to send actions to the Redux store. This allows us to update the color value in the state.</li>
<li>And finally import the <code>Color.js</code> file, which contains the Redux logic, including the reducer and the action for changing the color.</li>
</ul>
<p>Then:</p>
<ol>
<li>We get the current color from the Redux store using the <code>useSelector</code> hook.</li>
<li>We render an input element where users can type their desired color.</li>
<li>We define an event handler to handle changes to the input value. When the user types a color in the input, this event handler will be called.</li>
<li>When the user clicks the "Change Color" button, the event handler dispatches an action to the Redux store with the updated color value.</li>
</ol>
<p>With these changes, the <code>ChangeColor</code> component now uses Redux to manage the state. Users can change the color of the displayed text by typing their desired color in the input field and clicking the "Change text color" button.</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;
<span class="hljs-keyword">import</span> { useSelector, useDispatch } <span class="hljs-keyword">from</span> <span class="hljs-string">'react-redux'</span>;
<span class="hljs-keyword">import</span> { changeColor } <span class="hljs-keyword">from</span> <span class="hljs-string">'../features/Color'</span>;

<span class="hljs-keyword">const</span> ChangeColor = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-comment">// State to hold the selected color</span>
  <span class="hljs-keyword">const</span> [color, setColor] = useState(<span class="hljs-string">''</span>);

  <span class="hljs-comment">// Accessing the dispatch function from react-redux</span>
  <span class="hljs-keyword">const</span> dispatch = useDispatch();

  <span class="hljs-comment">// Accessing the theme color value from the Redux store</span>
  <span class="hljs-keyword">const</span> themeColor = useSelector(<span class="hljs-function">(<span class="hljs-params">state</span>) =&gt;</span> state.theme.value);

  <span class="hljs-comment">// Event handler for the input change</span>
  <span class="hljs-keyword">const</span> handleColorChange = <span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> {
    setColor(e.target.value);
  };

  <span class="hljs-comment">// Event handler for the button click</span>
  <span class="hljs-keyword">const</span> handleButtonClick = <span class="hljs-function">() =&gt;</span> {
    <span class="hljs-comment">// Dispatching the changeColor action with the selected color</span>
    dispatch(changeColor(color));
  };

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{{</span> <span class="hljs-attr">color:</span> <span class="hljs-attr">themeColor</span> }}&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Progressively effective resources via business metrics.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'inputBtn-container'</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'text'</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'input'</span> <span class="hljs-attr">onChange</span>=<span class="hljs-string">{handleColorChange}</span> /&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'btn'</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{handleButtonClick}</span>&gt;</span>
          Change text color
        <span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
};

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> ChangeColor;
</code></pre>
<p>Here's the output:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/07/chrome_LDhsOmTm5O-1.gif" alt="Modified State using Redux" width="600" height="400" loading="lazy">
<em>Modified State using Redux</em></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>The article covers two state management solutions: the <code>useState()</code> hook for small to medium apps and <code>Redux</code> for larger ones. </p>
<p>When choosing which to use, consider factors like app complexity, team size, and performance needs. Understanding both approaches will help you make the right choice.</p>
<p>You can read the <a target="_blank" href="https://redux.js.org/">Redux documentation</a> to learn more.</p>
<p>If you found this article helpful, share it with others who may also find it interesting. </p>
<p>You can also stay updated on my latest projects by following me on <a target="_blank" href="https://https//twitter.com/ijaydimples">Twitter</a> and <a target="_blank" href="https://https//www.linkedin.com/in/ijeoma-igboagu/">LinkedIn</a>.</p>
<p>Thank you for reading💖.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
