<?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: Konfy</title>
    <description>The latest articles on DEV Community by Konfy (@konfydev).</description>
    <link>https://dev.to/konfydev</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%2F937583%2Fae5833e6-e61d-4c5b-8572-5b04e8d183b6.jpg</url>
      <title>DEV Community: Konfy</title>
      <link>https://dev.to/konfydev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/konfydev"/>
    <language>en</language>
    <item>
      <title>Do we still need DTO ?</title>
      <dc:creator>Konfy</dc:creator>
      <pubDate>Thu, 05 Feb 2026 19:21:15 +0000</pubDate>
      <link>https://dev.to/konfydev/do-we-need-dto-with-graphql-53i5</link>
      <guid>https://dev.to/konfydev/do-we-need-dto-with-graphql-53i5</guid>
      <description>&lt;p&gt;I recently had the pleasure of talking about DTOs with a fellow engineer. During our discussion, I destructured the API response directly from the backend in my frontend code. I immediately noticed the disappointed look on their face. That got me thinking: why do we even need DTOs in the first place?&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a DTO?
&lt;/h2&gt;

&lt;p&gt;A DTO (Data Transfer Object) is a structured object used to transfer data between layers or systems. It often exists to:&lt;/p&gt;

&lt;p&gt;Validate data coming from the backend.&lt;/p&gt;

&lt;p&gt;Transform backend responses to match frontend needs.&lt;/p&gt;

&lt;p&gt;Decouple frontend and backend schemas to avoid breaking changes.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In traditional REST APIs, DTOs are common because responses may include extra fields, nested structures, or data that the frontend doesn’t need.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How GraphQL Changes the Game
&lt;/h2&gt;

&lt;p&gt;GraphQL allows the client to request exactly the data it needs. This has several implications:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fine-grained queries&lt;/strong&gt;&lt;br&gt;
You define the shape of the data on the client-side query. This reduces the need for mapping large responses to a DTO.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Strong typing&lt;/strong&gt;&lt;br&gt;
GraphQL schemas are strongly typed. Tools like Apollo Codegen or GraphQL Code Generator can automatically generate TypeScript types for your queries and mutations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flexible frontend evolution&lt;/strong&gt;&lt;br&gt;
If the backend adds extra fields, your client won’t be affected unless you query them. DTOs no longer serve as a shield against breaking changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  When You Might Still Want DTOs
&lt;/h2&gt;

&lt;p&gt;Despite GraphQL’s strengths, there are cases where DTOs in the frontend can be useful:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Business logic transformation&lt;/strong&gt;&lt;br&gt;
You might want to compute new fields, format dates, or merge multiple queries into one object suitable for the UI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Validation or sanitization&lt;/strong&gt;&lt;br&gt;
If the backend can send optional or nullable fields, a DTO can enforce stricter rules before the UI consumes the data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Decoupling for long-lived projects&lt;/strong&gt;&lt;br&gt;
In large teams, a DTO can isolate frontend code from backend schema changes, especially if the backend is shared across multiple clients.&lt;/p&gt;

&lt;h2&gt;
  
  
  When You Probably Don’t need DTOs
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Small apps or MVPs&lt;/strong&gt;&lt;br&gt;
The overhead of mapping to DTOs usually outweighs the benefits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Type-safe GraphQL clients&lt;/strong&gt;&lt;br&gt;
If you’re using TypeScript with generated types, your types already act as a “live DTO.”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Direct UI consumption&lt;/strong&gt;&lt;br&gt;
If your components can directly consume the GraphQL response, adding DTOs adds boilerplate without much gain.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Sidenote&lt;/em&gt;: Some still prefer to have it part of clean architecture. What's your perspective ?&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>dto</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Avoid react re-renders: Warning: Copy pasted from chatGPT</title>
      <dc:creator>Konfy</dc:creator>
      <pubDate>Wed, 14 Jan 2026 23:41:07 +0000</pubDate>
      <link>https://dev.to/konfydev/avoid-react-re-renders-warning-copy-pasted-from-chatgpt-5a0</link>
      <guid>https://dev.to/konfydev/avoid-react-re-renders-warning-copy-pasted-from-chatgpt-5a0</guid>
      <description>&lt;ol&gt;
&lt;li&gt;Use controlled state at the right level&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Keep state local when only one component needs it&lt;/p&gt;

&lt;p&gt;Lift state only when necessary&lt;/p&gt;

&lt;p&gt;// Bad: global store for a single toggle&lt;br&gt;
const showModal = useGlobalStore(state =&amp;gt; state.showModal);&lt;/p&gt;

&lt;p&gt;// Good: local state&lt;br&gt;
const [showModal, setShowModal] = useState(false);&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Memoize components and values
a. React.memo for functional components&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Prevents re-render if props haven’t changed:&lt;/p&gt;

&lt;p&gt;const ListItem = React.memo(({ item }) =&amp;gt; &lt;/p&gt;
&lt;li&gt;{item.name}&lt;/li&gt;);

&lt;p&gt;b. useMemo for expensive calculations&lt;br&gt;
const filtered = useMemo(() =&amp;gt; items.filter(i =&amp;gt; i.active), [items]);&lt;/p&gt;

&lt;p&gt;c. useCallback for stable callbacks&lt;br&gt;
const handleClick = useCallback(() =&amp;gt; doSomething(id), [id]);&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use selectors in state management&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Libraries like Redux / Zustand can trigger re-renders only for selected slices&lt;/p&gt;

&lt;p&gt;const userName = useStore(state =&amp;gt; state.user.name);&lt;/p&gt;

&lt;p&gt;Avoid reading the entire state object → prevents unnecessary re-renders&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Split large components&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Break into smaller components so only the relevant part re-renders&lt;/p&gt;

&lt;p&gt; →  + &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Avoid inline objects/arrays in props&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Inline objects/arrays are new references every render&lt;/p&gt;

&lt;p&gt; // ❌&lt;br&gt;
  // ✅&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use key properly in lists&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;React uses key to determine if elements changed&lt;/p&gt;

&lt;p&gt;Stable keys prevent unnecessary re-mounts&lt;/p&gt;

&lt;p&gt;{users.map(u =&amp;gt; )}&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Avoid context overuse&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Context updates re-render all consumers&lt;/p&gt;

&lt;p&gt;Use state libraries (Zustand, Jotai) for frequently changing state&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Optimize re-renders from parent → child&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Pass primitive props or memoized references&lt;/p&gt;

&lt;p&gt;Avoid passing functions/objects inline unless memoized&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use React Profiler for bottlenecks&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Identify unnecessary re-renders&lt;/p&gt;

&lt;p&gt;Optimize only hotspots&lt;/p&gt;

&lt;p&gt;Measure actual impact before premature optimization&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Server-side considerations&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For Next.js / SSR:&lt;/p&gt;

&lt;p&gt;Use server components for static content&lt;/p&gt;

&lt;p&gt;Only client components for interactive state&lt;/p&gt;

</description>
      <category>webdev</category>
    </item>
    <item>
      <title>How lambda manages dependancies</title>
      <dc:creator>Konfy</dc:creator>
      <pubDate>Sun, 11 Jan 2026 20:43:58 +0000</pubDate>
      <link>https://dev.to/konfydev/how-lambda-manages-dependancies-2a1d</link>
      <guid>https://dev.to/konfydev/how-lambda-manages-dependancies-2a1d</guid>
      <description>&lt;p&gt;When moving from EC2 to Lambda, one of the common trait in having node_modules all in a same lambda. Well, this practise has been long gone with the advent of Layers. &lt;br&gt;
Layers lets you to install dependancies separately in a common pool and use it across different lambdas.&lt;/p&gt;

&lt;p&gt;For example, I have 2 lambdas. &lt;/p&gt;

&lt;p&gt;Lambda 1 - Reads a csv and saves it to DB&lt;br&gt;
Lambda 2 - Reads a csv and sends email &lt;/p&gt;

&lt;p&gt;Now, both has a dependancy package to read the .csv file. Let's say exceljs. If you need to install them in both the lambdas, don't you think you will do same for future lambdas also and its a wastage to do it everytime.&lt;/p&gt;

&lt;p&gt;Instead, create a layer with your dependancies. Version them out and just update the layers.&lt;/p&gt;

&lt;p&gt;Check out more about layers over here - &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/chapter-layers.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/lambda/latest/dg/chapter-layers.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
    </item>
    <item>
      <title>Do you need state management still ?</title>
      <dc:creator>Konfy</dc:creator>
      <pubDate>Sun, 04 Jan 2026 11:55:42 +0000</pubDate>
      <link>https://dev.to/konfydev/do-you-need-state-management-still--pj0</link>
      <guid>https://dev.to/konfydev/do-you-need-state-management-still--pj0</guid>
      <description>&lt;p&gt;When I started working on my hausapp one question tickles my interest. I used to have a state management in place as a statement just in case if I need anything to be driven far from what I was expecting out of it.&lt;/p&gt;

&lt;p&gt;My app is simple&lt;/p&gt;

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

&lt;p&gt;Like many developers, I initially added state management “just in case” my app grew beyond expectations. But as I built more, I started questioning that decision.&lt;/p&gt;

&lt;p&gt;My app is simple:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select your block&lt;/li&gt;
&lt;li&gt;Upload a picture&lt;/li&gt;
&lt;li&gt;Make sure maintenance is paid on time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I do plan to extend it later, but for now, the scope is limited. That’s where the dilemma begins.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dilemma
&lt;/h2&gt;

&lt;p&gt;We have global and local state management. A good developer keeps state close to the component housing. This is what I have learnt so far but sometime you need global state for this too. &lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;When a user visits again, I want to remember their selected block.&lt;/p&gt;

&lt;p&gt;When they navigate to other services (help, previous maintenance records), I need access to shared user data like haus number or name.&lt;/p&gt;

&lt;p&gt;At this point, traditional solutions come to mind:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Redux&lt;/li&gt;
&lt;li&gt;Jotai&lt;/li&gt;
&lt;li&gt;Zustand&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And yes, they would work.&lt;/p&gt;

&lt;p&gt;I can do this via a state management, jotai  might help or rather redux is there with me &lt;/p&gt;

&lt;p&gt;But, lets pause for a second. Its a small component which makes calls and retrieves the data from the backend and displays it. Do you agree ? &lt;/p&gt;

&lt;p&gt;For this, I don't need lots of boilerplate or no state management at all right ?&lt;/p&gt;

&lt;h2&gt;
  
  
  Hello tanstack
&lt;/h2&gt;

&lt;p&gt;Enter TanStack Query&lt;/p&gt;

&lt;p&gt;This is where TanStack Query clicked for me.&lt;/p&gt;

&lt;p&gt;Most of what I was trying to “manage” was actually server state:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fetching user data&lt;/li&gt;
&lt;li&gt;Caching responses&lt;/li&gt;
&lt;li&gt;Keeping data fresh&lt;/li&gt;
&lt;li&gt;Avoiding unnecessary refetches&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;TanStack Query already solves all of this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Built-in caching&lt;/li&gt;
&lt;li&gt;Stale-while-revalidate&lt;/li&gt;
&lt;li&gt;Automatic background refetching&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And for the remaining lightweight client state,&lt;br&gt;
TanStack Store is more than enough for my use case—without the mental overhead of a full state management library.&lt;/p&gt;

&lt;p&gt;So, its a win-win for me using it and move on with my backend prisma schemas.&lt;/p&gt;

&lt;p&gt;Just my thoughts shared over here. what do you think?&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>discuss</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Let's (try to *) understand AI first.</title>
      <dc:creator>Konfy</dc:creator>
      <pubDate>Sat, 04 Oct 2025 09:36:34 +0000</pubDate>
      <link>https://dev.to/konfydev/lets-try-to-understand-ai-first-4kk9</link>
      <guid>https://dev.to/konfydev/lets-try-to-understand-ai-first-4kk9</guid>
      <description>&lt;h2&gt;
  
  
  My experience with LLMs
&lt;/h2&gt;

&lt;p&gt;Working with large language models (LLMs) has been fascinating. But to use them smoothly, it helps to understand some common traits. I am sharing some of what I have learnt here.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Training data influence ("bias")
&lt;/h2&gt;

&lt;p&gt;Have you heard of AI hallucinations? They, along with conversation bias, often come from the same root cause: training data. Because models reflect patterns from the data they were trained on, they can inherit human biases or habits. This shows up a lot in coding.&lt;/p&gt;

&lt;p&gt;As the joke goes: “I started discussing a problem with an LLM, and now I have two problems.”&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
You: Check this test case and see why it’s not passing. Also follow security advice.&lt;br&gt;
AI: After several tries, let me just comment out the test case and run it.&lt;/p&gt;

&lt;p&gt;Why? Because in real-world data, developers often comment out code while debugging. The model mirrors that pattern.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Mirroring / Parroting
&lt;/h2&gt;

&lt;p&gt;LLMs also tend to echo your tone and phrasing. It’s their way of keeping the conversation natural and aligned with you.&lt;/p&gt;

&lt;p&gt;For example, if you greet the model with “Howdy partner!” a few times, it may start greeting you the same way — even if it doesn’t “understand” cowboy culture.&lt;/p&gt;

&lt;p&gt;In short: AI echoing human terms = the AI parroting human linguistic habits, sometimes without deeper reasoning.&lt;/p&gt;

&lt;p&gt;—&lt;br&gt;
Recognizing these patterns helps you set better expectations and work with LLMs more effectively.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>coding</category>
      <category>webdev</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Figma MCP to Code with cursor</title>
      <dc:creator>Konfy</dc:creator>
      <pubDate>Sat, 04 Oct 2025 09:11:31 +0000</pubDate>
      <link>https://dev.to/konfydev/figma-mcp-to-code-5aeh</link>
      <guid>https://dev.to/konfydev/figma-mcp-to-code-5aeh</guid>
      <description>&lt;p&gt;Recently, I got the opportunity to explore Figma MCP to design. Here is beautiful post from &lt;a href="https://uxplanet.org/new-figma-mcp-cursor-integration-with-example-46e0641400d6" rel="noopener noreferrer"&gt;Amish&lt;/a&gt; which explains how to connect. I will discuss common pitfalls and how to prompt for better design to code &lt;/p&gt;

&lt;h2&gt;
  
  
  1. Make sure that you are selecting the "Frame"
&lt;/h2&gt;

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

&lt;p&gt;If you haven't selected the frame, your model finds it hard to know which one you are talking about &lt;/p&gt;

&lt;h2&gt;
  
  
  2. Granularize your prompt
&lt;/h2&gt;

&lt;p&gt;Don't give it "Built me a whole UI from the selected frame" prompt. Better talk to it like talking to a colleague. Let's build a button first. check the colors. is it matching ? now, lets build animation for it. This works better in my opinion&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Always make sure the screenshot from model matches the design.
&lt;/h2&gt;

&lt;p&gt;Most of the time it misses out the details in the design. It can create decent outlook but don't be perfectionist in beginning itself &lt;/p&gt;

&lt;p&gt;Note: It's not a magic bullet but an accelarator to ease off your design creation journey. *&lt;em&gt;Try to adapt it not force it. *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Remember, its not a slave but a companion. &lt;/p&gt;

&lt;p&gt;Happy exploring.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>figma</category>
      <category>konfydev</category>
      <category>programming</category>
    </item>
    <item>
      <title>React v19: New Features Breathe Life into My Favorite Pokemon App!</title>
      <dc:creator>Konfy</dc:creator>
      <pubDate>Fri, 03 Jan 2025 09:42:43 +0000</pubDate>
      <link>https://dev.to/konfydev/react-v19-new-features-breathe-life-into-my-favorite-pokemon-app-5do2</link>
      <guid>https://dev.to/konfydev/react-v19-new-features-breathe-life-into-my-favorite-pokemon-app-5do2</guid>
      <description>&lt;p&gt;React 19, released on December 5th, 2024, has arrived! I couldn't wait to see what exciting features it offered, so I dusted off my favorite Pokemon app and started tinkering. Here's what I discovered:&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;1. Effortless Loading States with &lt;em&gt;useTransition&lt;/em&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Gone are the days of manually managing a separate loading state! React 19 introduces the &lt;em&gt;useTransition&lt;/em&gt; hook, which streamlines handling temporary UI states during data fetching. With useTransition, you can show a placeholder UI while data loads in the background, automatically transitioning to the actual content once it's ready. This image showcases the power of &lt;em&gt;useTransition&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I don't need to keep on track for loading anymore. &lt;strong&gt;setting a Loading state&lt;/strong&gt; will be taken care by &lt;strong&gt;&lt;em&gt;startTransition&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;Pretty cool right.. &lt;/p&gt;

&lt;h2&gt;
  
  
  2. Rendering Revamp: createRoot Replaces ReactDOM.render
&lt;/h2&gt;

&lt;p&gt;While not a React v19 change, it's worth noting that React v18 introduced createRoot as a replacement for ReactDOM.render for rendering React apps. This provides a more modern and efficient way to handle app rendering. Here's a comparison of the old (ReactDOM.render) and new (createRoot) approaches (image link for v17 ReactDOM.render, image link for v18/v19 createRoot).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Before&lt;/em&gt;: &lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;After&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fac5jixwhk2qdsk9gaxsh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fac5jixwhk2qdsk9gaxsh.png" alt="react v19 and v18 createRoot() example" width="800" height="133"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Even More to Explore!&lt;/em&gt;&lt;br&gt;
These are just a few of the exciting features in React v19. Upgrading to v18 first might be a smoother transition path, depending on your current codebase. The official React documentation is a great resource for diving deeper into useTransition, createRoot, and other new functionalities.&lt;/p&gt;

&lt;p&gt;I'm thrilled to be exploring these new features and breathing new life into my Pokemon app!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Hitting CORS during oAuth? Do check how to setup reverse proxy in react</title>
      <dc:creator>Konfy</dc:creator>
      <pubDate>Mon, 30 Sep 2024 20:33:02 +0000</pubDate>
      <link>https://dev.to/konfydev/how-to-implement-oauth-with-pkce-for-third-party-integration-in-react-3jc3</link>
      <guid>https://dev.to/konfydev/how-to-implement-oauth-with-pkce-for-third-party-integration-in-react-3jc3</guid>
      <description>&lt;p&gt;While implementing oAuth for third-party integration, I stumbled upon some informations which weren't updated for quite a while. Here I am trying to capture my experience and how it works &lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;/em&gt;: This article won't talk in detail about oAuth and how it works. Mostly focus on how to configure and implement them in react application. If you want to read about oAuth, read &lt;a href="https://auth0.com/intro-to-iam/what-is-oauth-2" rel="noopener noreferrer"&gt;here&lt;/a&gt;. Provides crystal clear information. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Flow:
&lt;/h2&gt;

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

&lt;p&gt;Roughly the flow works like described above.&lt;/p&gt;

&lt;h2&gt;
  
  
  So, what's the problem:
&lt;/h2&gt;

&lt;p&gt;Usually when you try to get the code &amp;amp; code_verifier from third party website directly, you may encounter CORS issue. This is expected. &lt;/p&gt;

&lt;h2&gt;
  
  
  How to resolve them ?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Check with third party provider - If they can whitelist your website, amazing. You don't need a backend at all&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If whitelisting doesn't work, you may need a backend to work as reverse_proxy for you. In our case, we used a simple typescript setup which proxies our call and used it as backend for reverse proxy. You can achieve it with your backend setup too.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Why it's hitting CORS?
&lt;/h2&gt;

&lt;p&gt;Cause most likely, if you use PKCE, you have to send Authentication header along with your request, to get the token. Sending Authentication is a no-no from UI for security reasons.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;CORs is a feature built into browsers for added security. It prevents any random website from using your authenticated cookies to send an API request to your bank's website and do stuff like secretly withdraw money.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Which library did I use to get it done easily in react?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/authts/react-oidc-context" rel="noopener noreferrer"&gt;https://github.com/authts/react-oidc-context&lt;/a&gt;&lt;br&gt;
👆 this one. This provides configuration as context and also supports webstoragestatestore which is nice to have.&lt;/p&gt;

&lt;h2&gt;
  
  
  Do you have more questions?
&lt;/h2&gt;

&lt;p&gt;Reply here. Gladly would love to help if I can :) &lt;/p&gt;

&lt;p&gt;Happy coding..  &lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>architecture</category>
      <category>oauth</category>
    </item>
    <item>
      <title>Interesting behavior of window.location.href</title>
      <dc:creator>Konfy</dc:creator>
      <pubDate>Tue, 06 Feb 2024 09:00:18 +0000</pubDate>
      <link>https://dev.to/konfydev/interesting-behavior-of-windowlocationhref-ane</link>
      <guid>https://dev.to/konfydev/interesting-behavior-of-windowlocationhref-ane</guid>
      <description>&lt;p&gt;We recently had a small hiccup in downloading multiple files from a portal. We got blocked by browser saying its a popup or request client to allow multiple file download. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are we trying to do ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We have to download 3 files once client clicks on "Download all files" button. We don't want client to allow pop-up or allow multiple downloads&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the options&lt;/strong&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use a library to download like filesync or saver&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We don't like to use a library just to resolve this problem&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use window.open &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But this will be blocked by browser as pop-up. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use window.location.href&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Well, if you use this, you can get it . Yet, if you trigger multiple urls with it, it will &lt;strong&gt;"override"&lt;/strong&gt; the previous URL.&lt;/p&gt;

&lt;p&gt;So, how to solve it &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use windown.location.href with &lt;em&gt;settimeout&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To read more about it, you can see this amazing article from Ryo Mac&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/psynamic/demystifying-the-event-loop-featuring-settimeout-f702d4020d9a" rel="noopener noreferrer"&gt;https://medium.com/psynamic/demystifying-the-event-loop-featuring-settimeout-f702d4020d9a&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This sets a delay in execution and helps with override of url.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>bun.js - Faster alternative for yarn</title>
      <dc:creator>Konfy</dc:creator>
      <pubDate>Thu, 14 Sep 2023 07:16:44 +0000</pubDate>
      <link>https://dev.to/konfydev/bunjs-faster-alternative-for-yarn-4208</link>
      <guid>https://dev.to/konfydev/bunjs-faster-alternative-for-yarn-4208</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa819469zf64rc92nattq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa819469zf64rc92nattq.png" alt=" " width="171" height="150"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;tldr; bun is faster than yarn (Personally...) and it helps reduce loads of time by installing faster. I am still trying to do gitlab ci install now &lt;/p&gt;

&lt;p&gt;I have been working on evolutions. From nodejs, v8 engine to yarn, pnpm and new kid in town "bun.js"&lt;/p&gt;

&lt;p&gt;bun proves to steal the limelight and not just any limelight. When developers hate yarn everytime for slow installation,(again in ci personally..) bun does it in ease. &lt;/p&gt;

&lt;p&gt;Time taken for yarn install: 1 minute and 39 seconds&lt;br&gt;
Time taken for bun install : 5 seconds&lt;/p&gt;

&lt;p&gt;To counter argue, yarn v3 is improving the experience and what about pnpm. I get it. When you think of installing once and using it as runtime, test runner, bundler and total toolkit, well, I got convinced.&lt;/p&gt;

&lt;p&gt;Onwards and upwards raising with bun :) Delicacy delivered&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>faster</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Why we may use relative path instead of fullpath in nextjs</title>
      <dc:creator>Konfy</dc:creator>
      <pubDate>Mon, 17 Jul 2023 07:17:10 +0000</pubDate>
      <link>https://dev.to/konfydev/why-we-may-use-relative-path-instead-of-fullpath-in-nextjs-4ln1</link>
      <guid>https://dev.to/konfydev/why-we-may-use-relative-path-instead-of-fullpath-in-nextjs-4ln1</guid>
      <description>&lt;p&gt;Scenario : I have 2 levels of pages &lt;br&gt;
page 1 which has page1.1 and page 1.2&lt;/p&gt;

&lt;p&gt;Now, when these got blown to several pages you may end up with several pages and several sub pages. But, what happens to assets &lt;br&gt;
will you change them to ../../assets for pages which are in deep levels and so forth&lt;/p&gt;

&lt;p&gt;It can be resolved easily with something called reference path. what is reference path &lt;/p&gt;

&lt;p&gt;A path with prepend slash will result in referencing of assets folder which is relative to root directory &lt;/p&gt;

&lt;p&gt;Example instead of "../../assets/imgs" (fullPath) you can use "/assets/imgs" (relativePath) . Ofcourse, nextjs built this as in favor of root directory which will resolve in the beginning &lt;/p&gt;

&lt;p&gt;So, always remember to use relative path so that it will resolve itself instead of fullPath&lt;/p&gt;

&lt;p&gt;You can do a good read in fileSystementry about it &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/FileSystemEntry/fullPath" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/API/FileSystemEntry/fullPath&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>javascript</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>What is trailingslash in next.js</title>
      <dc:creator>Konfy</dc:creator>
      <pubDate>Tue, 04 Jul 2023 15:39:04 +0000</pubDate>
      <link>https://dev.to/konfydev/what-is-trailingslash-in-nextjs-26ej</link>
      <guid>https://dev.to/konfydev/what-is-trailingslash-in-nextjs-26ej</guid>
      <description>&lt;p&gt;Usually, when you are doing static site generation out of nextjs, the route will be handled via nextjs (Thanks to Next Link). But, when you are trying to point a small division to link inside this might not work. &lt;/p&gt;

&lt;p&gt;What's the issue:&lt;br&gt;
Let's say you have a url, &lt;a href="http://www.xyz.com/about" rel="noopener noreferrer"&gt;www.xyz.com/about&lt;/a&gt;. This will automatically handled by nextjs to be &lt;a href="http://www.xyz.com/about/" rel="noopener noreferrer"&gt;www.xyz.com/about/&lt;/a&gt; . Can you see the difference ? yes. the "/" after "about" (/about/). This is what we call as "trailing slash"&lt;/p&gt;

&lt;p&gt;What nextjs do here?&lt;br&gt;
It automatically redirects things with trailing slashes to their counterpart (&lt;a href="http://www.xyz.com/about" rel="noopener noreferrer"&gt;www.xyz.com/about&lt;/a&gt;) will be redirected to ( &lt;a href="http://www.xyz.com/about/" rel="noopener noreferrer"&gt;www.xyz.com/about/&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;pages inside nextjs expects to render components with trailing slashes which might cause an issue here&lt;/p&gt;

&lt;p&gt;How to solve it?&lt;br&gt;
By adding trailingslash: true in next.config.ts&lt;/p&gt;

&lt;p&gt;Want to read more about it ?&lt;br&gt;
Here is the link - [(&lt;a href="https://nextjs.org/docs/app/api-reference/next-config-js/trailingSlash)" rel="noopener noreferrer"&gt;https://nextjs.org/docs/app/api-reference/next-config-js/trailingSlash)&lt;/a&gt;]&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>staticsite</category>
      <category>konfycode</category>
    </item>
  </channel>
</rss>
