<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Luis Esteban Saravia M</title>
    <description>The latest articles on DEV Community by Luis Esteban Saravia M (@esaraviam).</description>
    <link>https://dev.to/esaraviam</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F702341%2F5acc243b-4d60-43a9-831c-1b68cfda00d0.jpg</url>
      <title>DEV Community: Luis Esteban Saravia M</title>
      <link>https://dev.to/esaraviam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/esaraviam"/>
    <language>en</language>
    <item>
      <title>How to Integrate OpenGraph in React to Boost SEO and Social Sharing</title>
      <dc:creator>Luis Esteban Saravia M</dc:creator>
      <pubDate>Mon, 23 Sep 2024 21:43:37 +0000</pubDate>
      <link>https://dev.to/esaraviam/how-to-integrate-opengraph-in-react-to-boost-seo-and-social-sharing-25e1</link>
      <guid>https://dev.to/esaraviam/how-to-integrate-opengraph-in-react-to-boost-seo-and-social-sharing-25e1</guid>
      <description>&lt;p&gt;In the world of web development, ensuring that your pages look great when shared on social media is crucial for the success of your projects. In this post, I’ll show you how to add OpenGraph metadata to your React application to optimize how your pages or apps are displayed when shared.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is OpenGraph?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;OpenGraph is a protocol that allows developers to define how content should appear when shared on social media platforms like Facebook, Twitter, and LinkedIn. By using OpenGraph, you can control how key elements like the title, description, and preview image appear, enhancing both the appearance and SEO of your content on social media.&lt;/p&gt;

&lt;p&gt;Getting Started: Initial Setup in React&lt;/p&gt;

&lt;p&gt;To manage metadata in React, we’ll use a package called react-helmet, which allows us to easily manipulate the content inside the &lt;/p&gt; of our documents.

&lt;p&gt;&lt;strong&gt;1. Install react-helmet&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first thing we need to do is install the react-helmet package in our React project. Open your terminal and run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install react-helmet&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Create the OpenGraphMeta Component&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next, we’ll create a reusable React component that will handle the OpenGraph metadata. This component can be easily configured and used across different pages in your application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import { Helmet } from 'react-helmet';

type OpenGraphMetaProps = {
  title: string;
  description: string;
  url: string;
  image: string;
  siteName?: string;
};

const OpenGraphMeta: React.FC&amp;lt;OpenGraphMetaProps&amp;gt; = ({ title, description, url, image, siteName }) =&amp;gt; {
  return (
    &amp;lt;Helmet&amp;gt;
      {/* OpenGraph metadata */}
      &amp;lt;meta property="og:title" content={title} /&amp;gt;
      &amp;lt;meta property="og:description" content={description} /&amp;gt;
      &amp;lt;meta property="og:url" content={url} /&amp;gt;
      &amp;lt;meta property="og:image" content={image} /&amp;gt;
      &amp;lt;meta property="og:type" content="website" /&amp;gt;
      {siteName &amp;amp;&amp;amp; &amp;lt;meta property="og:site_name" content={siteName} /&amp;gt;}

      {/* Twitter metadata */}
      &amp;lt;meta name="twitter:card" content="summary_large_image" /&amp;gt;
      &amp;lt;meta name="twitter:title" content={title} /&amp;gt;
      &amp;lt;meta name="twitter:description" content={description} /&amp;gt;
      &amp;lt;meta name="twitter:image" content={image} /&amp;gt;
    &amp;lt;/Helmet&amp;gt;
  );
};

export default OpenGraphMeta;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Using the Component in a Page&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that we have our OpenGraphMeta component, let’s see how we can use it inside a page in our React app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import OpenGraphMeta from './OpenGraphMeta';

const MyPage: React.FC = () =&amp;gt; {
  return (
    &amp;lt;div&amp;gt;
      {/* Add OpenGraph metadata */}
      &amp;lt;OpenGraphMeta
        title="My Awesome Page"
        description="This is the description of my page."
        url="https://www.mypage.com"
        image="https://www.mypage.com/image.jpg"
        siteName="My Website"
      /&amp;gt;

      {/* Page content */}
      &amp;lt;h1&amp;gt;Welcome to My Page!&amp;lt;/h1&amp;gt;
      &amp;lt;p&amp;gt;This is the content of the page you're visiting.&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default MyPage;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Integrating OpenGraph in React is a great way to improve the visibility and presentation of your pages when shared on social media. By using a dynamic component like OpenGraphMeta, you can easily manage these metadata and optimize your content for different platforms.&lt;/p&gt;

&lt;p&gt;Now that you have this implementation ready, it’s time to put it into practice! Have you used OpenGraph before? Share your experiences in the comments below.&lt;/p&gt;

&lt;p&gt;This post is designed to be clear, technical, and easy to follow, perfect for a developer audience on Medium. Let me know if you’d like to make any changes or additions!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Merge a Git Feature Branch with a Squash Commit</title>
      <dc:creator>Luis Esteban Saravia M</dc:creator>
      <pubDate>Thu, 16 Feb 2023 19:20:54 +0000</pubDate>
      <link>https://dev.to/esaraviam/how-to-merge-a-git-feature-branch-with-a-squash-commit-8af</link>
      <guid>https://dev.to/esaraviam/how-to-merge-a-git-feature-branch-with-a-squash-commit-8af</guid>
      <description>&lt;p&gt;When working with Git, it's common to create a feature branch to work on a specific feature or fix a bug. Once the feature or bug fix is complete, you'll want to merge the changes back into the main branch. One way to do this is with a squash commit, which combines all of the changes from the feature branch into a single commit on the main branch.&lt;/p&gt;

&lt;p&gt;In this post, we'll show you how to use a simple Git script to merge a feature branch with a squash commit. The script creates a backup of the feature branch, creates a temporary branch from the main branch, squashes the feature branch into the temporary branch, and then commits the changes with a single message. It then points the feature branch to the temporary branch, force pushes the updated feature branch to the remote repository, and deletes the temporary branch.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Cloning the script&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To use the script, you'll need to clone the GitHub repository to your local machine. You can do this by running the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/esaraviam/git_squash.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you've cloned the repository, you can navigate to the directory where the script is located and follow the instructions in the post to create an alias and use the script.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Installing the Script&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Make sure you have Git installed on your machine.&lt;/li&gt;
&lt;li&gt;Download or clone the script to your local machine.&lt;/li&gt;
&lt;li&gt;Open a terminal window and navigate to the directory where the script is located.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Make the script executable by running the following command:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod +x git_squash.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Creating an alias&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Open your &lt;strong&gt;&lt;code&gt;.profile&lt;/code&gt;&lt;/strong&gt; file in a text editor by running the following command:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vi ~/.profile
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note: On some systems (such as macOS), the file may be named &lt;strong&gt;&lt;code&gt;.bash_profile&lt;/code&gt;&lt;/strong&gt; instead of &lt;strong&gt;&lt;code&gt;.profile&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Add the following line to the bottom of the file:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alias git-squash="/path/to/script/directory/git_squash.sh"
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Replace &lt;strong&gt;&lt;code&gt;/path/to/script/directory&lt;/code&gt;&lt;/strong&gt; with the full path to the directory where the script is located. Save and close the file.&lt;/p&gt;

&lt;p&gt;This will create an alias for the script called &lt;strong&gt;&lt;code&gt;git-squash&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Source your &lt;strong&gt;&lt;code&gt;.profile&lt;/code&gt;&lt;/strong&gt; file by running the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; source ~/.profile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will reload your &lt;strong&gt;&lt;code&gt;.profile&lt;/code&gt;&lt;/strong&gt; file and make the &lt;strong&gt;&lt;code&gt;git-squash&lt;/code&gt;&lt;/strong&gt; alias available in your terminal.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Usage&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To use the script, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open a terminal window and navigate to the directory where your Git repository is located.&lt;/li&gt;
&lt;li&gt;Checkout the feature branch that you want to merge into the main branch.&lt;/li&gt;
&lt;li&gt;Run the script with the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; git-squash &amp;lt;feature-branch&amp;gt; &amp;lt;main-branch&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace  &lt;strong&gt;&lt;code&gt;&amp;lt;feature-branch&amp;gt;&lt;/code&gt;&lt;/strong&gt; with the name of the branch that you want to merge and &lt;strong&gt;&lt;code&gt;&amp;lt;main-branch&amp;gt;&lt;/code&gt;&lt;/strong&gt; with the name of the main branch.&lt;/p&gt;

&lt;p&gt;For example, if you want to merge a feature branch named "feature-123" into a main branch named "main", run the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git-squash feature-123 main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;The script will create a backup of the feature branch, create a temporary branch from the main branch, squash the feature branch into the temporary branch, commit the changes, and then point the feature branch to the temporary branch. It will then &lt;strong&gt;force push&lt;/strong&gt; the updated feature branch to the remote repository and delete the temporary branch.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's it! The script should merge the feature branch into the main branch with a squash commit.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>discuss</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Custom Hook to Manage Api Request</title>
      <dc:creator>Luis Esteban Saravia M</dc:creator>
      <pubDate>Tue, 06 Dec 2022 13:50:51 +0000</pubDate>
      <link>https://dev.to/esaraviam/custom-hook-to-manage-api-request-4ng0</link>
      <guid>https://dev.to/esaraviam/custom-hook-to-manage-api-request-4ng0</guid>
      <description>&lt;p&gt;If you want to make API requests in a React functional component, you can use the useEffect hook to perform the request. However, this can quickly become repetitive and difficult to manage if you need to make multiple requests in your component.&lt;/p&gt;

&lt;p&gt;To make this process easier, you can create a custom hook called useAPI that wraps the useEffect hook and provides a simple interface for making API requests. Here is an example of how you might create the useAPI hook:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useState, useEffect } from 'react';

function useAPI({method, url, body}) {
  const [data, setData] = useState(null);
  const [error, setError] = useState(null);
  const [loading, setLoading] = useState(false);

  useEffect(() =&amp;gt; {
    setLoading(true);
    setError(null);

    fetch(url, {
      method,
      body: JSON.stringify(body),
      headers: {
        'Content-Type': 'application/json',
      },
    })
      .then(response =&amp;gt; response.json())
      .then(data =&amp;gt; setData(data))
      .catch(error =&amp;gt; setError(error))
      .finally(() =&amp;gt; setLoading(false));
  }, [method, url, body]);

  return { data, error, loading };
}

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

&lt;/div&gt;



&lt;p&gt;In this example, the useAPI hook takes a method, url, and body parameter, and uses the useState and useEffect hooks to make an API request using the specified method and url. The body parameter is stringified and included in the request as the request body. The hook also tracks the loading state, data, and error state of the request, and returns them as an object.&lt;/p&gt;

&lt;p&gt;To use the useAPI hook in a functional component, you can call the hook and destructure the returned object to access the data, error, and loading state. Here is an example of how you might use the useAPI hook in a functional component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import { useAPI } from './useAPI';

function MyComponent() {
const {data, error, loading} = useAPI({
         method:'POST', 
         url: 'https://my-api.com/data', 
         body: {title: 'My Post'}
     });
...
}

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

&lt;/div&gt;



</description>
      <category>react</category>
      <category>customhook</category>
      <category>hooks</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Using Typescript in a Node Project</title>
      <dc:creator>Luis Esteban Saravia M</dc:creator>
      <pubDate>Thu, 30 Sep 2021 02:12:52 +0000</pubDate>
      <link>https://dev.to/esaraviam/using-typescript-in-a-node-project-4khj</link>
      <guid>https://dev.to/esaraviam/using-typescript-in-a-node-project-4khj</guid>
      <description>&lt;p&gt;I've been in the software industry for more than 15 years, most of that time, from one way or another, I always have to use javascript for the frontend or backend, but always feels I'm missing something, the language is not excellent enough to apply the uncle Bob suggestions, for example defining interfaces.&lt;/p&gt;

&lt;p&gt;For that reason and a lot more, I've decided to move forward and start to use typescript in all my professional work, that reason can be a post itself, but in this post, I going to explain how you can create an Express Application using typescript from the beginning.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's get started.
&lt;/h2&gt;

&lt;p&gt;First of all, we have to create a brand new project using yarn but if you prefer you can use Npm, that is completely up to you.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir ts-node-app

cd ts-node-app

yarn init -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding the necessary dependencies
&lt;/h3&gt;

&lt;p&gt;In first place we will add express.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add express
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we will add the support for typescript. in order to do that let add some other dependencies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add typescript ts-node @types/node @types/express --dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;typescript is installed as a dev dependency because all your code will be compilated into vanilla js, the that dependencies will be unnecessary once you build your application&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's configure your app to use typescript.
&lt;/h3&gt;

&lt;p&gt;To start using  typescript in your project is not enough to install it as a dependency; you have to create a configuration file called tsconfig.json; in this file, there are a lot of configurations the most of that commented, to understand this file, please check this &lt;a href="https://www.staging-typescript.org/tsconfig"&gt;Link&lt;/a&gt;     &lt;/p&gt;

&lt;p&gt;to create the tsconfig.json you can use npx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx tsc --init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Now we are ready to write code using Typescript.
&lt;/h3&gt;

&lt;p&gt;let's create a simple server using express and typescript.&lt;br&gt;
&lt;/p&gt;

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

const app: express.Application = express();

app.get("/", (request: express.Request, response: express.Response) =&amp;gt; {
  response.send("Hello World");
});

app.listen(3000, () =&amp;gt; {
  console.log("Listening on port 3000");
});

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Building the app.
&lt;/h3&gt;

&lt;p&gt;Now we are in position to build the app, so we will create a build and start scripts in package.json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
    "build": "tsc --project ./",
    "start": "node ./build/app.js"
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Github Repo
&lt;/h3&gt;

&lt;p&gt;I've put a complete version of code in my github account, here is the &lt;a href="https://github.com/esaraviam/node-typescript-boilerplate"&gt;Link&lt;/a&gt; &lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>node</category>
      <category>programming</category>
    </item>
    <item>
      <title>Hexagonal Architecture applied to typescript react project</title>
      <dc:creator>Luis Esteban Saravia M</dc:creator>
      <pubDate>Thu, 09 Sep 2021 15:40:23 +0000</pubDate>
      <link>https://dev.to/esaraviam/hexagonal-architecture-applied-to-typescript-react-project-enn</link>
      <guid>https://dev.to/esaraviam/hexagonal-architecture-applied-to-typescript-react-project-enn</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Usually, when we develop react Apps, we only concern about separate in our directory map, hooks, components, pages, store,  etc. But this directory separation doesn't guarantee that our application will scale or be maintainable in the future.&lt;/p&gt;

&lt;p&gt;Here's comes to help the &lt;b&gt;Domain-Driven Desing(DDD)&lt;b&gt; in particular in this article Hexagonal Architecture.&lt;/b&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;We will implement a typescript project using react to apply some of the concepts of HA (Hexagonal Architecture)&lt;/p&gt;

&lt;p&gt;First of all, to maintain this real we implement an existing API to get Dog Breeds Photos in the link bellow you can find the api documentation.&lt;br&gt;
&lt;a href="https://dog.ceo/dog-api/documentation/" rel="noopener noreferrer"&gt;Dog CEO Api documentation&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Let's get started
&lt;/h3&gt;

&lt;p&gt;I'm gonna create a react app, using yarn and create react app CLI and typescript template to do this you need to type the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;yarn&lt;/span&gt; &lt;span class="nx"&gt;create&lt;/span&gt; &lt;span class="nx"&gt;react&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="nx"&gt;dogapp&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;template&lt;/span&gt; &lt;span class="nx"&gt;typescript&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;this will create a boilerplate react app that we will modify to implement HA, first of all let's talk about design.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hexagonal Architecture.
&lt;/h3&gt;

&lt;p&gt;The Hexagonal Architecture is based in layers like an onion, and propose three base layers, Domain , Application and Infrastructure. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fesaraviam%2Fesaraviam%2Fmain%2Fimages%2Fhexagon.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fesaraviam%2Fesaraviam%2Fmain%2Fimages%2Fhexagon.png" title="Hexagonal Architecture Diagram" alt="alt HA Diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hexagonal Architecture proposes that our domain is the core of the layers and that it does not couple to anything external. Instead of making explicit use and through the principle of inversion of dependencies, we couple ourselves to contracts (interfaces or ports) and not to specific implementations.&lt;/p&gt;

&lt;h3&gt;
  
  
  The code.
&lt;/h3&gt;

&lt;p&gt;we will make a dog breed app so let's create some directories to implement HA.&lt;/p&gt;

&lt;p&gt;To implement HA we need to separate our domain of the implementations so let create the layer proposed by HA.&lt;/p&gt;

&lt;p&gt;so we need to create 3 main folders to contain our app.&lt;/p&gt;

&lt;p&gt;I'll upload this in a github repository at the end of the post.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;src&lt;/li&gt;
&lt;ul&gt;
  &lt;li&gt;--domain&lt;/li&gt;
  &lt;li&gt;--application&lt;/li&gt;
  &lt;li&gt;--infrastructure&lt;/li&gt;

&lt;/ul&gt;




&lt;/ul&gt;

&lt;p&gt;using this approach the domain folder does know how will be implemented, and the application layer only can access to domain but doesn't know how the infrastructure will be implemented&lt;/p&gt;

&lt;p&gt;if you want you can see the finished project implemented in my github account &lt;a href="https://github.com/esaraviam/dogappv1" rel="noopener noreferrer"&gt;esaraviam&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;From the react app perspective implementing this kind of architecture will push you to apply SOLID principles and your app will be more scalable and easy to maintain.&lt;/p&gt;

&lt;p&gt;It forces our domain not to be coupled to anything external through the use of our domain's own interfaces that are implemented by external elements.&lt;/p&gt;

&lt;p&gt;It facilitates being decoupled from the delivery method, making it easier for a use case to work for a mobile App, API, a traditional website, a single web App by REST, etc ...&lt;/p&gt;

&lt;p&gt;On the other hand, it allows you to be prepared to change the implementation details such as the persistence or the framework.&lt;br&gt;
Like any architecture based on the investment of dependencies, it facilitates that the components can be unit tested.&lt;/p&gt;

</description>
      <category>react</category>
      <category>typescript</category>
      <category>architecture</category>
      <category>design</category>
    </item>
  </channel>
</rss>
