<?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" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hammad Afzal on Medium]]></title>
        <description><![CDATA[Stories by Hammad Afzal on Medium]]></description>
        <link>https://medium.com/@hammadafzal1111?source=rss-a3a8b58ea5f4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VfkUsh1O_EDvz-L9rlJfrQ.jpeg</url>
            <title>Stories by Hammad Afzal on Medium</title>
            <link>https://medium.com/@hammadafzal1111?source=rss-a3a8b58ea5f4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 06:52:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hammadafzal1111/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why I’m Learning Next.js — As a React Developer]]></title>
            <link>https://medium.com/@hammadafzal1111/why-im-learning-next-js-as-a-react-developer-7b369b0f9958?source=rss-a3a8b58ea5f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b369b0f9958</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[nextjs-tutorial]]></category>
            <category><![CDATA[server-side-rendering]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Hammad Afzal]]></dc:creator>
            <pubDate>Tue, 01 Jul 2025 07:00:36 GMT</pubDate>
            <atom:updated>2025-07-01T07:00:36.404Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why I’m Learning Next.js — As a React Developer</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R54VOVvpaxraj8EqTpnE4A.png" /></figure><p>React gave me full control — but it came with decision fatigue, setup chaos, and no clear path forward.</p><p>Every new feature meant rewriting routes, reshuffling folders, or Googling yet another ‘how to fix X in React’ thread. I was writing the same boilerplate: routes, API calls, configs — over and over.</p><p>Routing felt like a maze. SEO? A black hole. And SSR? Even hearing the term gave me anxiety.</p><p>My codebase felt like a bundle of duct-taped npm hacks — barely holding together.</p><p>hat’s when I found something different — clean, structured, and oddly comforting: <strong>Next.js</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_iytChbSH81o6ULuoJUqoQ.png" /></figure><p>Next.js was solving real headaches I kept patching manually.</p><ul><li>🗂️ Routing that makes sense — no more wrestling with react-router</li><li>⚙️ SSR out of the box — finally, a fast page load without a config rabbit hole</li><li>🔌 API routes in the same codebase — finally, no more switching folders to write one endpoint</li><li>🖼️ Image optimization without installing 3 extra packages</li></ul><p>It felt like React — but with structure, speed, and features I didn’t even know I needed. So I’m jumping in — slowly, deliberately, and fully committed.</p><p>No crash course. No 10-hour tutorials. Just slow, focused learning — one concept at a time.</p><h4><strong>Day 1 Starts Here</strong></h4><p>Let’s start simple. Let’s start real.</p><p>If you’re diving into Next.js too, let’s mess it up together. I’ll share every bug, win, and oops moment as it happens.</p><p>Let’s stop hopping from tutorial to tutorial — and finally build something real. Something that’s ours.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b369b0f9958" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Level Up Your JavaScript: Why Beginners Must Try TypeScript]]></title>
            <link>https://medium.com/@hammadafzal1111/level-up-your-javascript-why-beginners-must-try-typescript-c249dcd5bc09?source=rss-a3a8b58ea5f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/c249dcd5bc09</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[typescript-tips]]></category>
            <category><![CDATA[typescript-with-react]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[beginner-javascript]]></category>
            <dc:creator><![CDATA[Hammad Afzal]]></dc:creator>
            <pubDate>Tue, 29 Oct 2024 17:40:39 GMT</pubDate>
            <atom:updated>2024-10-29T17:40:39.669Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M54ZStoA0GU2ZaksRHcBTA.jpeg" /><figcaption>Credits: <a href="https://angularexperts.io/blog/advanced-typescript">Angular Experts</a></figcaption></figure><p>If you’re a JavaScript developer, you know it’s a flexible language. However, this flexibility often leads to hidden bugs and confusing error messages that can significantly eat up your development time.</p><h3>A Common Scenario</h3><p>Imagine working on a large application, only to discover a small typo in a variable name that causes a critical feature to break. These types of issues can result in wasted hours and lead to confusion down the line.</p><p>This is where TypeScript comes in — a powerful tool designed to enhance your coding experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*Lin2HSDP9ucMOCBUp93dDw.png" /><figcaption>Credits: <a href="https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fwww.technigo.io%2Fexplained%2Fwhat-is-typescript-a-comprehensive-introduction&amp;psig=AOvVaw3H0vb06ec5XzezUMdmAbnf&amp;ust=1730309728078000&amp;source=images&amp;cd=vfe&amp;opi=89978449&amp;ved=0CAMQjB1qFwoTCLiV6KGQtIkDFQAAAAAdAAAAABAE">Technigo</a></figcaption></figure><h3>What Exactly is TypeScript?</h3><p>Think of TypeScript as JavaScript with a safety net. It’s a superset of JavaScript that adds static typing, allowing you to catch errors during development rather than discovering them in production when they can lead to major issues.</p><h3>Practical Context</h3><p>In a large project with multiple developers, a minor typo in a variable name might slip through in JavaScript, leading to unexpected behavior or even a significant outage. TypeScript’s type safety ensures these errors are flagged during development, helping prevent such problems.</p><p>If you already understand JavaScript, transitioning to TypeScript will feel seamless; you’ll simply be building on your existing knowledge.</p><h3>Why TypeScript Will Change How You Code</h3><h3>1. TypeScript Catches Errors Early</h3><p>JavaScript’s flexibility is both a blessing and a curse. For instance, consider this <strong>JavaScript code</strong>:</p><pre>function greet(name) {<br>  return &quot;Hello, &quot; + name;<br>}<br>console.log(greet(123)); // Outputs: Hello, 123</pre><p>Here, a number is passed instead of a string. JavaScript lets this slip through, which can lead to unexpected behavior later.</p><p>Now, let’s see the same code in <strong>TypeScript</strong>:</p><pre>function greet(name: string): string {<br>  return &quot;Hello, &quot; + name;<br>}<br>console.log(greet(123)); // Error: Argument of type &#39;number&#39; is not assignable to parameter of type &#39;string&#39;.</pre><p>TypeScript flags the issue immediately, saving you debugging time and future headaches.</p><h3>2. Enhanced Code Readability and Maintainability</h3><p>TypeScript makes your code easier to read and understand, especially for collaborative projects. When someone sees a TypeScript function, they instantly know what data types are expected.</p><p>For example, using an interface to define a user object:</p><pre>interface User {<br>  name: string;<br>  age: number;<br>}<br><br>function printUserInfo(user: User): void {<br>  console.log(`User: ${user.name}, Age: ${user.age}`);<br>}</pre><p>This clarity simplifies maintenance and updates, ensuring everyone is on the same page.</p><h3>3. Unbeatable IDE Support</h3><p>Using TypeScript enhances your development environment. Editors like Visual Studio Code offer fantastic features such as autocompletion, inline documentation, and real-time error checking.</p><p>It’s like having a helpful assistant by your side, catching mistakes as you code, which allows you to develop faster and with more confidence.</p><h4>4. Seamless Integration with Popular Frameworks</h4><p>If you’re working with frameworks like React, Node.js, or using the MERN stack, TypeScript integrates beautifully. This is especially valuable in larger applications where consistency is essential.</p><p>For example, in a React application, you can define component props like this:</p><pre>interface ButtonProps {<br>  label: string;<br>  onClick: () =&gt; void;<br>}<br><br>const Button: React.FC&lt;ButtonProps&gt; = ({ label, onClick }) =&gt; {<br>  return &lt;button onClick={onClick}&gt;{label}&lt;/button&gt;;<br>};</pre><p>Here, TypeScript ensures you always pass the correct data types to your components, making your code safer and easier to manage.</p><h3>Addressing Common Misconceptions</h3><h4>“TypeScript is Hard to Learn”</h4><p>When you first dive into TypeScript, concepts like interfaces and generics might seem daunting. But there’s no need to master everything at once.</p><p>Start with basic types, like numbers and strings, and gradually expand your knowledge.</p><h4>“TypeScript Slows Down Development”</h4><p>Adding type annotations might feel tedious, but this upfront work pays off.</p><p>You’ll save time later by catching bugs before they become larger issues. Think of it as a way to future-proof your code.</p><h4>“You Need to Convert Everything to TypeScript”</h4><p>Not at all! TypeScript is designed for gradual adoption. You can start by renaming JavaScript files to .ts and adding types to a few functions.</p><p>As you grow more comfortable, you can expand your TypeScript usage.</p><h3>Conclusion: Embrace the Change</h3><p>TypeScript is revolutionizing how we write JavaScript, enhancing reliability, readability, and maintainability. While the initial learning curve may seem steep, the long-term benefits are well worth it.</p><p>If you’re a beginner or even an intermediate developer, don’t hesitate — start exploring TypeScript today!</p><h3>Call-to-Action: Share Your Thoughts</h3><p>What’s holding you back from adopting TypeScript? If you’re already using it, what benefits have you noticed?</p><p>I’d love to hear your thoughts in the comments below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c249dcd5bc09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Your Own Custom Hook in React: A Simple Guide to Fetching Data]]></title>
            <link>https://medium.com/@hammadafzal1111/building-your-own-custom-hook-in-react-a-simple-guide-to-fetching-data-a5165550fa7b?source=rss-a3a8b58ea5f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5165550fa7b</guid>
            <category><![CDATA[reactjs-development]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[fetching-data-from-api]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Hammad Afzal]]></dc:creator>
            <pubDate>Mon, 23 Sep 2024 11:05:46 GMT</pubDate>
            <atom:updated>2024-09-23T11:19:11.278Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Em01xSau8lWYU1xVnJulGw.jpeg" /><figcaption>Credits: <a href="https://unsplash.com/@rahuulmiishra">https://unsplash.com/@rahuulmiishra</a></figcaption></figure><h3>1. Introduction</h3><p>When working with React, managing state and side effects — like fetching data — can get repetitive, especially if you have similar logic in multiple components. This is where <strong>custom hooks</strong> come in handy. They allow you to bundle reusable logic into a single function, making your code cleaner and easier to manage.</p><p>In this blog, we’ll create a custom hook called useCountry that fetches information about countries from an API. We’ll break down each step to ensure you can easily follow along.</p><h3>2. What is a React Hook?</h3><p>Before we jump into custom hooks, let’s quickly review some built-in hooks in React:</p><ul><li><strong>useState</strong>: Think of this as a container that holds information that can change over time, like user input in a form.</li><li><strong>useEffect</strong>: This is like a timer that tells React to perform a certain action after something happens, such as fetching data from a server.</li></ul><h3>A Quick Example</h3><p>Imagine you’re building a simple form. You’d use useState to keep track of the input values (like a shopping list) and useEffect to trigger actions when those values change (like updating the list).</p><p>These built-in hooks are the building blocks for creating custom hooks, which let you reuse logic across different components.</p><h3>3. Step-by-Step Guide to Building the Custom Hook</h3><h4>Step 1: Define the Purpose of Your Hook</h4><p>We’re going to create a custom hook called useCountry, which will fetch country details based on the name you provide. It will handle loading states and any errors that may occur.</p><p><strong>Challenge</strong>: Think of another use case for a custom hook. What kind of data would you like to fetch?</p><h4>Step 2: Initial Setup</h4><p>We’ll use <strong>Axios</strong> to make our API calls. Axios simplifies the process of sending requests and gives better error messages compared to the Fetch API.</p><p>Here’s a basic outline of our custom hook:</p><pre>import { useState, useEffect } from &#39;react&#39;;<br>import axios from &#39;axios&#39;;<br><br>function useCountry(countryName) {<br>  const [data, setData] = useState(null); // Holds fetched country data<br>  const [loading, setLoading] = useState(true); // Tracks loading state<br>  const [error, setError] = useState(null); // Tracks errors<br><br>  useEffect(() =&gt; {<br>    if (!countryName) return; // If countryName is empty, exit early<br>    <br>    const fetchCountry = async () =&gt; {<br>      setLoading(true); // Start loading<br>      try {<br>        const response = await axios.get(`https://restcountries.com/v3.1/name/${countryName}`);<br>        setData(response.data[0]); // Set country data<br>      } catch (err) {<br>        setError(err.response ? err.response.data.message : err.message); // Handle errors<br>      } finally {<br>        setLoading(false); // End loading<br>      }<br>    };<br>    <br>    fetchCountry(); // Call the function to fetch data<br>  }, [countryName]); // Re-run if countryName changes<br><br>  return { data, loading, error }; // Return state<br>}<br><br>export default useCountry;</pre><p>Key points:</p><ul><li>Axios automatically converts JSON responses, so you don’t have to do it manually.</li><li>It provides better error messages, making debugging easier.</li></ul><blockquote><strong>Try It Yourself</strong>: Copy the code into your editor and change the country name to see different results!</blockquote><h4>Step 3: Handle Edge Cases</h4><p>It’s essential to manage edge cases — like when the country name is invalid or empty. Here’s how we can enhance our hook:</p><pre>useEffect(() =&gt; {<br>  if (!countryName) {<br>    setError(&#39;Country name is required&#39;); // Set error if no input<br>    setLoading(false);<br>    return; // Exit if country name is empty<br>  }<br><br>  const fetchCountry = async () =&gt; {<br>    setLoading(true);<br>    try {<br>      const response = await axios.get(`https://restcountries.com/v3.1/name/${countryName}`);<br>      setData(response.data[0]);<br>    } catch (err) {<br>      setError(err.response ? err.response.data.message : err.message);<br>    } finally {<br>      setLoading(false);<br>    }<br>  };<br><br>  fetchCountry();<br>}, [countryName]);</pre><h3>Example Scenarios:</h3><ul><li><strong>Invalid Country Name</strong>: If you input “Atlantis,” the API will return a 404 error, which we can catch and display.</li><li><strong>Empty Input</strong>: If the input is empty, we show an error message indicating that a country name is required.</li></ul><h4>Step 4: Using the Custom Hook in a Component</h4><p>Now that we have our useCountry hook, let’s use it in a component to fetch and show country details.</p><pre>import React, { useState } from &#39;react&#39;;<br>import useCountry from &#39;./useCountry&#39;;<br><br>const CountryInfo = () =&gt; {<br>  const [country, setCountry] = useState(&#39;&#39;); // State for country input<br>  const { data, loading, error } = useCountry(country); // Use custom hook<br><br>  const handleInputChange = (e) =&gt; {<br>    setCountry(e.target.value); // Update country state<br>  };<br><br>  return (<br>    &lt;div&gt;<br>      &lt;input<br>        type=&quot;text&quot;<br>        value={country}<br>        onChange={handleInputChange}<br>        placeholder=&quot;Enter country name&quot;<br>      /&gt;<br>      {loading &amp;&amp; &lt;p&gt;Loading...&lt;/p&gt;} // Show loading message<br>      {error &amp;&amp; &lt;p&gt;Error: {error}&lt;/p&gt;} // Show error message<br>      {data &amp;&amp; (<br>        &lt;div&gt;<br>          &lt;h2&gt;{data.name.common}&lt;/h2&gt;<br>          &lt;p&gt;Population: {data.population}&lt;/p&gt;<br>          &lt;p&gt;Region: {data.region}&lt;/p&gt;<br>        &lt;/div&gt;<br>      )}<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default CountryInfo;</pre><h3>User Interaction</h3><p>When a user types “<strong>Pakistan</strong>” into the input field, our component will fetch and display the country details.</p><p><strong>Try It Yourself</strong>: Create an input field using the CountryInfo component. What happens when you enter different country names?</p><h3>4. Best Practices for Custom Hooks</h3><ul><li><strong>Naming Conventions</strong>: Always start your custom hook with “use,” like useCountry. This helps clarify that it follows React&#39;s hook rules.</li><li><strong>Reusability</strong>: Make sure your hook is versatile enough to be used in multiple components. For example, a hook for form handling can work with different forms.</li><li><strong>Handling Side Effects</strong>: Always use useEffect for side effects (like API calls) within your hook. This keeps your components focused on their primary job.</li></ul><p><strong>Example</strong>: How could you modify useCountry to include a search history? Share your ideas!</p><h3>5. When Not to Use Custom Hooks</h3><p>Custom hooks are great, but they’re not always needed. Here are times when they might not be the best choice:</p><ul><li><strong>Single-Use Logic</strong>: If the logic is specific to one component and won’t be reused, there’s no need to create a custom hook.</li><li><strong>Simple State Management</strong>: If managing state is straightforward (like a toggle switch), making a custom hook could complicate things.</li></ul><blockquote><strong>Reflection</strong>: Think about recent projects. Have you created any logic that might benefit from being turned into a custom hook? Share your thoughts!</blockquote><h3>6. Conclusion</h3><p>Custom hooks in React help you manage state and side effects while keeping your components clean and reusable. We’ve shown how to build a custom hook using Axios to fetch country details, manage loading and error states, and handle edge cases.</p><p>By using custom hooks, you can make your code more organized and maintainable. Start creating your own custom hooks for tasks like data fetching or form handling!</p><h3>Final Challenge</h3><p>Try <strong>creating your own custom hook</strong> for a different purpose, such as fetching weather data. Can you build it? If not, feel free to revisit this material for a deeper understanding.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5165550fa7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy Your Node.js TypeScript App on Vercel: The Ultimate Guide]]></title>
            <link>https://medium.com/@hammadafzal1111/deploy-your-node-js-typescript-app-on-vercel-the-ultimate-guide-43cf7848cf09?source=rss-a3a8b58ea5f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/43cf7848cf09</guid>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[vercel-deployment]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Hammad Afzal]]></dc:creator>
            <pubDate>Mon, 02 Sep 2024 08:52:58 GMT</pubDate>
            <atom:updated>2024-09-03T05:13:56.170Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f6EGD_ujNt-Maq1zn5fqOQ.png" /><figcaption>My Notes App Deployment on Vercel</figcaption></figure><h3><strong>Deploy Your Node.js TypeScript App on Vercel Quickly and Efficiently: A Step-by-Step Guide</strong></h3><p>Deploying a Node.js app with TypeScript on Vercel can be quick and straightforward — if you set it up correctly. Vercel offers seamless deployment with powerful CI/CD capabilities, making it ideal for modern web applications. This guide will help you navigate the setup process, <strong>sidestep common configuration errors</strong>, and ensure your deployment is successful.</p><h3>1. Prerequisites</h3><p>Before getting started, make sure you have the following:</p><ul><li><strong>Vercel Free Account:</strong> <a href="https://vercel.com/">Sign up here</a> to get started and deploy your apps effortlessly..</li><li><strong>Node.js &amp; NPM:</strong> <a href="https://nodejs.org/">Install Node.js</a> if you haven’t already. This will also install npm, essential for running JavaScript packages..</li><li><strong>API Setup:</strong> Have an existing API ready, or create a simple one.. Check out my <a href="https://github.com/MHammad33/Notes-App/tree/Vercel-Deploy">reference repository </a>for a quick setup guide that gets you up and running in minutes.</li></ul><h3>2. Setting Up Your Project</h3><p>Let’s start by setting up a basic Node.js project with TypeScript.</p><h4>Step 1: Initialize Your Project</h4><pre>npm init</pre><h4>Step 2: Install Key Packages</h4><p>Install the essential packages for TypeScript and Node.js development:</p><pre>npm install express typescript ts-node @types/node @types/express<br>ts-node-dev</pre><ul><li><strong>express</strong>: Minimalist web framework for Node.js, used to set up routing and middleware.</li><li><strong>typescript</strong>: Superset of JavaScript that adds static typing, enhancing code quality and catching errors early.</li><li><strong>ts-node-dev</strong>: Runs TypeScript files with hot-reloading, streamlining the development process.</li></ul><h3>3. Configure TypeScript (tsconfig.json)</h3><p>The tsconfig.json file controls how TypeScript compiles your code. Here’s a recommended configuration:</p><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;module&quot;: &quot;commonjs&quot;,<br>    &quot;esModuleInterop&quot;: true,<br>    &quot;allowSyntheticDefaultImports&quot;: true,<br>    &quot;target&quot;: &quot;ES6&quot;,<br>    &quot;noImplicitAny&quot;: true,<br>    &quot;moduleResolution&quot;: &quot;node&quot;,<br>    &quot;sourceMap&quot;: true,<br>    &quot;outDir&quot;: &quot;dist&quot;,<br>    &quot;baseUrl&quot;: &quot;.&quot;,<br>    &quot;paths&quot;: {<br>      &quot;*&quot;: [<br>        &quot;node_modules/*&quot;,<br>        &quot;src/types/*&quot;<br>      ]<br>    }<br>  },<br>  &quot;include&quot;: [<br>    &quot;./src/**/*&quot;<br>  ]<br>}</pre><p><strong>Key Configurations Explained:</strong></p><ul><li><strong>&quot;module&quot;: &quot;commonjs&quot;</strong>: Ensures compatibility with Node.js.</li><li><strong>&quot;target&quot;: &quot;ES6&quot;</strong>: Compiles code to ES6 standards, allowing modern JavaScript features.</li><li><strong>&quot;outDir&quot;: &quot;dist&quot;</strong>: Specifies the output folder for compiled files, crucial for Vercel deployments.</li><li><strong>&quot;paths&quot;</strong>: Helps alias directories, making imports cleaner and the codebase more maintainable.</li></ul><h3>4. Set Up Scripts in package.json</h3><p>Next, configure scripts in your package.json to manage development, build, and deployment workflows effectively:</p><pre>&quot;scripts&quot;: {<br>  &quot;start&quot;: &quot;node src/index.ts&quot;,<br>  &quot;dev&quot;: &quot;npx nodemon src/index.ts&quot;,<br>  &quot;build:ui&quot;: &quot;@powershell Remove-Item -Recurse -Force dist &amp;&amp; cd ../frontend &amp;&amp; npm run build &amp;&amp; @powershell Copy-Item -Recurse dist ../backend&quot;,<br>  &quot;lint&quot;: &quot;eslint .&quot;<br>}</pre><p><strong>Scripts Overview:</strong></p><ul><li><strong>start</strong>: Runs the app in production mode using node.</li><li><strong>build:ui</strong>: Cleans the dist directory, builds the frontend, and copies static files to the backend. This is particularly useful for monorepo setups.</li><li><strong>lint</strong>: Uses ESLint to maintain code quality and consistency by identifying problematic patterns in JavaScript.</li></ul><h3>5. Vercel Deployment Configuration</h3><p>Deploying to Vercel requires a vercel.json file to define your build and route configurations. Here&#39;s a basic setup:</p><pre>{<br>  &quot;version&quot;: 2,<br>  &quot;builds&quot;: [<br>    {<br>      &quot;src&quot;: &quot;dist/index.js&quot;,<br>      &quot;use&quot;: &quot;@vercel/node&quot;,<br>      &quot;config&quot;: { &quot;includeFiles&quot;: [&quot;dist/**&quot;] }<br>    }<br>  ],<br>  &quot;routes&quot;: [<br>    {<br>      &quot;src&quot;: &quot;/(.*)&quot;,<br>      &quot;dest&quot;: &quot;dist/index.js&quot;<br>    }<br>  ]<br>}</pre><p><strong>Configuration Highlights:</strong></p><ul><li><strong>Builds</strong>: Specifies the entry point (dist/index.js) and includes necessary files.</li><li><strong>Routes</strong>: Directs all incoming requests to the main file and handles CORS, which is crucial for cross-origin requests.</li></ul><h3>6. Common Deployment Issues &amp; Fixes</h3><p>Deployments often run into a few common issues. Here’s how to tackle them:</p><ul><li><strong>Build Failures</strong>: Make sure your dist folder is generated correctly. Double-check file paths in vercel.json to ensure all required files are included.</li><li><strong>CORS Errors</strong>: Modify CORS headers in vercel.json to suit your API’s specific needs, ensuring smooth communication between the frontend and backend.</li><li><strong>Missing Dependencies</strong>: Verify all dependencies in package.json are installed correctly and up-to-date to prevent build breaks.</li></ul><h3>7. Conclusion</h3><p>Deploying a TypeScript-based Node.js app on Vercel can be smooth and efficient with the right configurations. Focus on setting up your tsconfig.json, package.json, and vercel.json accurately to streamline the process. If you need a complete example or further tweaks, feel free to explore my <a href="https://github.com/MHammad33/Notes-App/tree/Vercel-Deploy">complete codebase here</a> for further reference and tweak the configurations as needed.</p><p><strong>Next Steps:</strong> Test these configurations locally before deploying to ensure everything works as expected. Follow me for more guides, and don’t hesitate to share your deployment experiences or ask questions!</p><p>Happy coding and deploying on Vercel! 🍻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43cf7848cf09" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>