<?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: Soham Dalal ⚛️</title>
    <description>The latest articles on DEV Community by Soham Dalal ⚛️ (@mr_sd_jack_003).</description>
    <link>https://dev.to/mr_sd_jack_003</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F957231%2F317df5e9-aad5-41bb-a143-9d5bd6c7a5a3.png</url>
      <title>DEV Community: Soham Dalal ⚛️</title>
      <link>https://dev.to/mr_sd_jack_003</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mr_sd_jack_003"/>
    <language>en</language>
    <item>
      <title>Building a Unified React App with HONO</title>
      <dc:creator>Soham Dalal ⚛️</dc:creator>
      <pubDate>Thu, 16 May 2024 06:21:19 +0000</pubDate>
      <link>https://dev.to/mr_sd_jack_003/building-a-unified-react-app-with-hono-4aic</link>
      <guid>https://dev.to/mr_sd_jack_003/building-a-unified-react-app-with-hono-4aic</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Exploring the latest upgrades within the Hono framework, we uncover its strengthened alliance with Vite, presenting developers with a more seamless fusion of React SPAs and Hono APIs. Within this article, our aim is to unveil a straightforward approach to project development, where constructing a React SPA alongside an API server becomes an effortless endeavor with the aid of Hono's enhanced capabilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a Hono Project using bun package manager
&lt;/h2&gt;

&lt;p&gt;Creating a project with the Hono framework with using the bun package manager is very simple. Follow these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First, open the terminal and run the following command to create a new Hono project:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bun create hono app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Next, install the necessary packages to use Reactjs:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bun add react react-dom zod @hono/zod-validator
bun add -D vite @hono/vite-dev-server @types/react @types/react-dom bun-types @hono/vite-cloudflare-pages

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If you are using TypeScript, change &lt;code&gt;jsxImportSource&lt;/code&gt; in &lt;code&gt;tsconfig.json&lt;/code&gt; from &lt;code&gt;hono/jsx&lt;/code&gt; to &lt;code&gt;react&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Finally, edit the &lt;code&gt;vite.config.ts&lt;/code&gt; file and specify the react libraries in &lt;code&gt;ssr.external&lt;/code&gt;. This ensures that react functions correctly during the server side rendering.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, the basic setup of a project combining Hono and React is complete. Then we will move on to the client side and server side implementations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Client Side Implementation
&lt;/h2&gt;

&lt;p&gt;For the client side implementation, create a &lt;code&gt;src/client.jsx&lt;/code&gt; file. In this file define the Ui components using React. Here is the simple example :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { createRoot } from "react-dom/client";
import { hc } from "hono/client";
import { AppType } from ".";

interface TodoListProps {
  todos: string[];
}

const client = hc&amp;lt;AppType&amp;gt;("/");

function TodoList({ todos }: TodoListProps) {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;a href="/"&amp;gt;
        &amp;lt;h1&amp;gt;Todo App&amp;lt;/h1&amp;gt;
      &amp;lt;/a&amp;gt;
      &amp;lt;div&amp;gt;
        &amp;lt;input type="text" name="title" /&amp;gt;
        &amp;lt;button
          type="submit"
          onClick={() =&amp;gt; {
            const title = document.querySelector("input")?.value;
            client.todos.$post({
              form: {
                title
              },
            });
          }}
        &amp;gt;
          Add
        &amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;ul&amp;gt;
        {todos.map((todo, i) =&amp;gt; (
          &amp;lt;li key={i}&amp;gt;
            {todo}
            &amp;lt;button
              onClick={() =&amp;gt; {
                client.todos[":id"].$delete({
                  param: {
                    id: i.toString(),
                  },
                });
              }}
            &amp;gt;
              Delete
            &amp;lt;/button&amp;gt;
          &amp;lt;/li&amp;gt;
        ))}
      &amp;lt;/ul&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

const domNode = document.getElementById("root")!;
const root = createRoot(domNode);
root.render(&amp;lt;TodoList todos={["sample"]} /&amp;gt;);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Server Side Implementation
&lt;/h2&gt;

&lt;p&gt;For the server side implementation, create a &lt;code&gt;src/server.ts&lt;/code&gt; file and define the API endpoints using hono. Here is a simple example. With this, the API server that communicates with react application created on the client side is complete. By using Hono, you can easily set up API endpoints and establish communication with the react 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 { Hono } from "hono";
import { renderToString } from "react-dom/server";
import { z } from "zod";
import { zValidator } from '@hono/zod-validator'

const app = new Hono();

app.get("/", (c) =&amp;gt; {
  return c.html(
    renderToString(
      &amp;lt;html&amp;gt;
        &amp;lt;head&amp;gt;
          &amp;lt;meta charSet="utf-8" /&amp;gt;
          &amp;lt;meta content="width=device-width, initial-scale=1" name="viewport" /&amp;gt;
          {import.meta.env.PROD ? (
            &amp;lt;script type="module" src="/static/client.js"&amp;gt;&amp;lt;/script&amp;gt;
          ) : (
            &amp;lt;script type="module" src="/src/client.tsx"&amp;gt;&amp;lt;/script&amp;gt;
          )}
        &amp;lt;/head&amp;gt;
        &amp;lt;body&amp;gt;
          &amp;lt;div id="root"&amp;gt;&amp;lt;/div&amp;gt;
        &amp;lt;/body&amp;gt;
      &amp;lt;/html&amp;gt;
    )
  );
});

const schema = z.object({
  title: z.string().min(1),
});

app.post(
  "/todos",
  zValidator("form", schema),
  (c) =&amp;gt; {
    const { title } = c.req.valid('form')
    // TODO: DB insert
    return c.json({title})
  }
);

app.delete(
  "/todos/:id",
  (c) =&amp;gt; {
    const id = c.req.param.id
    // TODO: DB delete
    return c.json({ id });
  }
);

export type AppType = typeof app;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Building &amp;amp; Deploying the project
&lt;/h2&gt;

&lt;p&gt;To build and deploy the project, use the following command:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Build client and server:&lt;br&gt;
&lt;code&gt;vite build --mode client &amp;amp;&amp;amp; vite build&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deploy to  Cloudflare Pages:&lt;br&gt;
&lt;code&gt;wrangler pages deploy dist&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Additionally, you can deploy this using Vercel. However, in my case, I am using the Bun package manager, and unfortunately, Vercel deployment is not working for me. I encounter errors when attempting to deploy this on Vercel.&lt;/p&gt;

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

&lt;p&gt;In summary, this article demonstrated the streamlined process of constructing a project incorporating a React Single Page Application (SPA) and an API server using the Hono framework. By harnessing the synergy between Hono and Vite, developers can seamlessly navigate through development, building, and deployment phases. Hono emerges as a valuable tool for crafting personal or internal applications not reliant on SEO, including WebView applications.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>ADDING COMMAND ALIASES TO POWERSHELL</title>
      <dc:creator>Soham Dalal ⚛️</dc:creator>
      <pubDate>Tue, 07 May 2024 10:33:48 +0000</pubDate>
      <link>https://dev.to/mr_sd_jack_003/adding-command-aliases-to-powershell-87c</link>
      <guid>https://dev.to/mr_sd_jack_003/adding-command-aliases-to-powershell-87c</guid>
      <description>&lt;p&gt;HOW MUCH TIME COULD YOU SAVE BY SHORTENING COMMON COMMANDS AND PARAMETERS USING POWERSHELL ALIASES? THE ANSWER IS A LOT.&lt;br&gt;
If you’re like me, there are certain commands that get run repeatedly throughout your day. Between "git checkout", "docker {whatever}" and navigating to frequent paths with "cd", I’ve been wondering how much time I could save by shortening these commands and parameters.&lt;/p&gt;
&lt;h2&gt;
  
  
  THIS SEAT’S TAKEN
&lt;/h2&gt;

&lt;p&gt;PowerShell has built in commands that we don’t want to step on. I won’t list them all (there are MANY), but if you get something wildly unexpected from your aliases then you can Google them.&lt;/p&gt;
&lt;h2&gt;
  
  
  SO SHOW ME ALREADY
&lt;/h2&gt;

&lt;p&gt;Okay, okay. So first, let’s create a function in a ".ps1" file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function goGoGadgetGitStatus {
  git status
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function above simply calls "git status". You can then setup an alias to call that function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set-Alias gs goGoGadgetGitStatus
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then from your PowerShell console you can type "gs" and it will run "git status".&lt;/p&gt;

&lt;p&gt;That’s a very simplistic example but gives you an idea of what’s possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  WHAT ABOUT PARAMETERS
&lt;/h2&gt;

&lt;p&gt;Great question! We can define parameters in the function and then pass them in.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function goGoGadgetGit {
  Param(
    [Parameter(Mandatory = $true, Position = 0)]
    [String]
    $Cmd,

    [Parameter(Mandatory = $false, ValueFromRemainingArguments = $true)]
    [String[]]
    $Params
  )

  Switch ($Cmd)
  {
      #status
      's' { git status $Params }
      #init
      'i' {git init $Params }
      #add
      'a' {git add $Params }
      #branch
      'b' {git branch $Params }
      #checkout
      'ch' {git checkout $Params }
      #clean
      'cl' {git clean $Params }
      #clone
      'cln' {git clone $Params }
      #commit
      'cm' {git commit $Params }
      #config
      'cf' {git config $Params }
      #log
      'l' {git log $Params }
      #merge
      'm' {git merge $Params }
      #pull
      'pl' {git pull $Params }
      #push
      'pu' {git push $Params }
      #remote
      're' {git remote $Params }
  }
}
Set-Alias g goGoGadgetGit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now in our console we can call "g s" to get "git status", "g i" to execute "git init", "g a" to get "git add", "g b" to get "git branch", "g ch" to get "git checkout", "g cl" to get "git clean", "g cln" to get "git clone", "g cm" to get "git commit", "g cf" to get "git config", "g l" to get "git log", "g m" to get "git merge", "g pl" to get "git pull", "g pu" to get "git push", "g re" to get "git remote". Also according to you, you can change the all of this shortcut.&lt;br&gt;
And I’m not going to go into detail on how to write PowerShell functions or options for parameters. There are plenty of resources out there for the two. But hopefully this showed you a rudimentary way to set up command aliases for PowerShell. Just add the code to your PowerShell profile.ps1 and you’re off to the races.&lt;/p&gt;

&lt;h2&gt;
  
  
  POWERSHELL CONFIG
&lt;/h2&gt;

&lt;p&gt;I’ve actually created a repository at &lt;a href="https://github.com/dalalsoham/My_Powershell"&gt;https://github.com/dalalsoham/My_Powershell&lt;/a&gt; that has the PowerShell script that I include in my profile that gives many aliases for things like Git and also this is my PowerShell configuration. Feel free to fork &amp;amp; clone it and use this config in your system.&lt;/p&gt;

&lt;p&gt;If you have any other suggestions or any corrections Leave a comment below. :)❤️ &lt;/p&gt;

</description>
    </item>
    <item>
      <title>ADDING COMMAND ALIASES TO POWERSHELL</title>
      <dc:creator>Soham Dalal ⚛️</dc:creator>
      <pubDate>Tue, 07 May 2024 10:33:48 +0000</pubDate>
      <link>https://dev.to/mr_sd_jack_003/adding-command-aliases-to-powershell-1pkn</link>
      <guid>https://dev.to/mr_sd_jack_003/adding-command-aliases-to-powershell-1pkn</guid>
      <description>&lt;p&gt;HOW MUCH TIME COULD YOU SAVE BY SHORTENING COMMON COMMANDS AND PARAMETERS USING POWERSHELL ALIASES? THE ANSWER IS A LOT.&lt;br&gt;
If you’re like me, there are certain commands that get run repeatedly throughout your day. Between "git checkout", "docker {whatever}" and navigating to frequent paths with "cd", I’ve been wondering how much time I could save by shortening these commands and parameters.&lt;/p&gt;
&lt;h2&gt;
  
  
  THIS SEAT’S TAKEN
&lt;/h2&gt;

&lt;p&gt;PowerShell has built in commands that we don’t want to step on. I won’t list them all (there are MANY), but if you get something wildly unexpected from your aliases then you can Google them.&lt;/p&gt;
&lt;h2&gt;
  
  
  SO SHOW ME ALREADY
&lt;/h2&gt;

&lt;p&gt;Okay, okay. So first, let’s create a function in a ".ps1" file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function goGoGadgetGitStatus {
  git status
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function above simply calls "git status". You can then setup an alias to call that function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set-Alias gs goGoGadgetGitStatus
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then from your PowerShell console you can type "gs" and it will run "git status".&lt;/p&gt;

&lt;p&gt;That’s a very simplistic example but gives you an idea of what’s possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  WHAT ABOUT PARAMETERS
&lt;/h2&gt;

&lt;p&gt;Great question! We can define parameters in the function and then pass them in.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function goGoGadgetGit {
  Param(
    [Parameter(Mandatory = $true, Position = 0)]
    [String]
    $Cmd,

    [Parameter(Mandatory = $false, ValueFromRemainingArguments = $true)]
    [String[]]
    $Params
  )

  Switch ($Cmd)
  {
      #status
      's' { git status $Params }
      #init
      'i' {git init $Params }
      #add
      'a' {git add $Params }
      #branch
      'b' {git branch $Params }
      #checkout
      'ch' {git checkout $Params }
      #clean
      'cl' {git clean $Params }
      #clone
      'cln' {git clone $Params }
      #commit
      'cm' {git commit $Params }
      #config
      'cf' {git config $Params }
      #log
      'l' {git log $Params }
      #merge
      'm' {git merge $Params }
      #pull
      'pl' {git pull $Params }
      #push
      'pu' {git push $Params }
      #remote
      're' {git remote $Params }
  }
}
Set-Alias g goGoGadgetGit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now in our console we can call "g s" to get "git status", "g i" to execute "git init", "g a" to get "git add", "g b" to get "git branch", "g ch" to get "git checkout", "g cl" to get "git clean", "g cln" to get "git clone", "g cm" to get "git commit", "g cf" to get "git config", "g l" to get "git log", "g m" to get "git merge", "g pl" to get "git pull", "g pu" to get "git push", "g re" to get "git remote". Also according to you, you can change the all of this shortcut.&lt;br&gt;
And I’m not going to go into detail on how to write PowerShell functions or options for parameters. There are plenty of resources out there for the two. But hopefully this showed you a rudimentary way to set up command aliases for PowerShell. Just add the code to your PowerShell profile.ps1 and you’re off to the races.&lt;/p&gt;

&lt;h2&gt;
  
  
  POWERSHELL CONFIG
&lt;/h2&gt;

&lt;p&gt;I’ve actually created a repository at &lt;a href="https://github.com/dalalsoham/My_Powershell"&gt;https://github.com/dalalsoham/My_Powershell&lt;/a&gt; that has the PowerShell script that I include in my profile that gives many aliases for things like Git and also this is my PowerShell configuration. Feel free to fork &amp;amp; clone it and use this config in your system.&lt;/p&gt;

&lt;p&gt;If you have any other suggestions or any corrections Leave a comment below. :)❤️ &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
