<?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 Agus Setyawan on Medium]]></title>
        <description><![CDATA[Stories by Agus Setyawan on Medium]]></description>
        <link>https://medium.com/@agusetyawan?source=rss-88e8449b0df7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*v7xUHd7DnhuD2_VMHVCQUg.jpeg</url>
            <title>Stories by Agus Setyawan on Medium</title>
            <link>https://medium.com/@agusetyawan?source=rss-88e8449b0df7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 18:13:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@agusetyawan/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[Streaming UI: The Architecture Behind ChatGPT-Style Interfaces]]></title>
            <link>https://medium.com/@agusetyawan/streaming-ui-the-architecture-behind-chatgpt-style-interfaces-33afd798f7d4?source=rss-88e8449b0df7------2</link>
            <guid isPermaLink="false">https://medium.com/p/33afd798f7d4</guid>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[user-interface]]></category>
            <dc:creator><![CDATA[Agus Setyawan]]></dc:creator>
            <pubDate>Sun, 21 Jun 2026 18:32:41 GMT</pubDate>
            <atom:updated>2026-06-21T18:32:41.601Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o-l11tAtFmIVqTxQ" /><figcaption>Photo by <a href="https://unsplash.com/@emilianovittoriosi?utm_source=medium&amp;utm_medium=referral">Emiliano Vittoriosi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Ever wondered how ChatGPT displays text one token at a time, mimicking a typewriter effect? While it looks like a simple UI animation, the reality involves a sophisticated data pipeline behind the scenes.</p><h3>Beyond Simple Animation</h3><p>Unlike standard API requests where the client waits for the full response (await response.json()), Streaming UI processes partial data chunks as soon as they arrive from the server. This is the foundation of the responsive, real-time experience users expect today.</p><h3>How It Works: The Technical Pipeline</h3><p>Based on the <em>Frontend System Design Essentials</em> framework, here is the architectural breakdown:</p><ol><li>Server-Side (NDJSON): The server transmits data using Newline Delimited JSON (NDJSON). By sending each JSON object as a complete line followed by a newline character, the server ensures the client doesn’t need the entire body to begin rendering.</li><li>Client-Side Pipeline:</li></ol><ul><li>The browser receives the response as a Readable Stream of raw bytes via fetch.</li><li>A TextDecoder converts these bytes into readable text.</li><li>Since network chunks don’t always align with JSON boundaries, the client uses a buffer to collect fragments until a newline is detected.</li></ul><p>3. Updating the UI: Once a line is complete, it is parsed into a JSON object and dispatched to update the React state incrementally.</p><h3>Why This Matters</h3><p>Viewing Streaming UI as a data pipeline rather than just an animation changes how you approach modern web development. Whether you are building an AI chatbot or a live data dashboard, mastering this pattern — whether via NDJSON or Server-Sent Events (SSE) — is a critical skill for building high-performance, real-world applications.</p><p><em>This article is based on the Frontend System Design series by I Code It.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33afd798f7d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[This Website Took 27.8s to Load. Here’s How I Optimized It]]></title>
            <link>https://medium.com/@agusetyawan/this-website-took-27-8s-to-load-heres-how-i-optimized-it-ee71dcbdf911?source=rss-88e8449b0df7------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee71dcbdf911</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web-performance]]></category>
            <category><![CDATA[case-study]]></category>
            <dc:creator><![CDATA[Agus Setyawan]]></dc:creator>
            <pubDate>Wed, 08 Apr 2026 20:01:01 GMT</pubDate>
            <atom:updated>2026-04-09T02:39:15.528Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rm6A3Nj1MDLMZ6yTion1Nw.png" /></figure><p>The project: [<em>Digital Invitation Website](</em><a href="https://hannogeswedding.undangku.com/Olie">https://hannogeswedding.undangku.com/Olie</a>).</p><p>The first time I ran a Lighthouse audit on this digital invitation website, it scored 56/100.</p><p>The Largest Contentful Paint? 27,8 seconds. For something as a wedding invitation, that’s not just slow. That’s broken.</p><p>Guests don’t wait 27 seconds to see the content. They will leave.</p><p>Started with a simple question: Can a digital invitation feel instant, even on a slow network?</p><p>Instead of treating it like a typical landing page, I approached it like a performance-critical app. Every asset, every request, and every millisecond had to justify its existence.</p><p>The goal was straightforward:</p><ul><li>Push Lighthouse Performance close to 100/100</li><li>Reduce the payload</li><li>Make the page feel fast from the very first second</li></ul><p>What followed wasn’t one big trick, but a series of small, deliberate decisions that completely changed how the page loaded.</p><h3>1. The Real Problem Wasn’t JavaScript. It Was Images.</h3><p>Some of them were over 1MB, and the browser was resizing them on the fly. That means extra CPU work, longer decoding time, and a delayed Largest Contentful Paint.</p><p>In short, the browser was doing work it should never have been asked to do. So I focused on :</p><p><strong>🏞️ Convert to WebP</strong><br>All images were converted from PNG/JPG to WebP at around 75–80% quality. The visual difference was minimal, but the size reduction was huge.</p><p><strong>✂️ Resize for real devices</strong><br>Instead of shipping oversized images, I resized them to match actual mobile screen dimensions. No more wasted pixels.</p><p><strong>🗂️ Decouple assets from the bundle</strong><br>All static assets were moved to the /public directory. This keeps large binary files out of the JavaScript bundle and avoids unnecessary processing.</p><p>The result?</p><p>The total payload dropped by more than 85<strong>%.</strong></p><p>And more importantly, the LCP improved dramatically because the browser could finally download and render the main image quickly.</p><h3>2. Not Everything Should Load at Once</h3><p>Even after optimizing images, the page still didn’t feel instant. The issue wasn’t size anymore. It was a priority.</p><p>By default, the browser tries to load everything as it discovers it. But not everything matters equally. So instead of letting the browser decide, I took control of the loading order.</p><p>I split the assets into two groups:</p><p><strong>🥇 Critical Path (what the user sees first)</strong><br>This includes the main background and assets that are loaded first, no exceptions.</p><p><strong>🥈 Background Path (everything else)</strong><br>Modals, icons, and secondary UI elements are loaded later, asynchronously.</p><p>This simple separation made a huge difference. The page no longer waits for everything to be ready. It opens as soon as the important parts are visible. To reinforce this, I added a lightweight loading bar directly in the HTML. It appears instantly, even before the full page is ready.</p><p>The page feels fast because the user sees something immediately, even if some parts are still loading in the background.</p><h3>3. Eliminating CSS as a Bottleneck</h3><p>Traditional stylesheets are loaded through &lt;link&gt; tags, which means the browser has to:</p><ol><li>Download the HTML</li><li>Discover the CSS file</li><li>Make another request</li><li>Wait before rendering</li></ol><p>That’s a full round trip before anything appears on screen.</p><p>For a single-page invitation, that delay isn’t worth it. So I removed it entirely.</p><p>Using a custom setup in vite.config.ts, I inlined all production CSS directly into the &lt;head&gt; of the HTML. No external stylesheet. No extra request. This means the browser can render the fully styled UI immediately as the HTML loads.</p><p>Yes, this increases the size of the HTML slightly. But in this case, it’s a trade-off that works in our favor. One slightly larger file is faster than multiple network requests.</p><h3>4. Sometimes the Best Optimization Is Doing Nothing</h3><p>A common mistake in web apps is trying to fetch everything as soon as the page loads.</p><p>I did the opposite. The RSVP data and guest information were intentionally delayed.</p><p>Why? Because at the start, the user doesn’t care about data. They care about visuals.</p><p>They want to see:</p><ul><li>Who’s getting married</li><li>When the event is</li><li>What the invitation looks like</li></ul><p>By delaying API requests, I allowed the browser to focus entirely on loading visual assets first. This keeps the network “pipe” clean during the most critical phase.</p><p>The result is:<br>The page looks finished before the data even starts loading. It feels faster, even though technically more work is happening later.</p><h3>5. Smoothness Over Noise</h3><p>Another subtle issue was visual instability. The loading indicator was updating too frequently, causing unnecessary layout recalculations.</p><p>This is known as forced reflow, and it can make animations feel jittery.</p><p>So instead of updating the progress continuously, I simplified it into four clear stages:</p><ul><li>25%</li><li>50%</li><li>75%</li><li>100%</li></ul><p>Combined with requestAnimationFrame, this reduced the load on the main thread and made transitions smoother.</p><p>The difference is subtle, but noticeable.</p><p>Instead of a noisy, jumpy loading experience, the page now feels calm and deliberate.</p><h3>The Result: From Mega-Scale to Kilo-Scale</h3><p>After all these changes, the results were clear:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vN3jDnZCX4bLj5WF9t5FdQ.png" /></figure><ul><li><strong>Initial payload: ~450KB</strong></li></ul><p>From a 56/100 score and 27.8s load time to a near-instant experience.</p><h3>Final Thought</h3><p>This wasn’t an enterprise app. It was just a wedding invitation. And yet, optimizing it made one thing clear:</p><blockquote>Performance isn’t about scale. It’s about intention.</blockquote><p>In a world where most websites are measured in megabytes, this project proves that you can build something fast, lightweight, and still beautiful.</p><p>Because in the end, speed isn’t a bonus feature. It’s part of the experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee71dcbdf911" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Strategic Refactoring Escaping Div Soup to Semantic Architecture]]></title>
            <link>https://medium.com/is-a-code/strategic-refactoring-escaping-div-soup-to-semantic-architecture-d77b9676b142?source=rss-88e8449b0df7------2</link>
            <guid isPermaLink="false">https://medium.com/p/d77b9676b142</guid>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Agus Setyawan]]></dc:creator>
            <pubDate>Sun, 01 Mar 2026 23:35:52 GMT</pubDate>
            <atom:updated>2026-03-01T23:35:52.355Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5CkLFsawT2ggX39I" /><figcaption>Photo by <a href="https://unsplash.com/@kaleidico?utm_source=medium&amp;utm_medium=referral">Kaleidico</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Why Your Semantic HTML Structure Matters More Than You Think?</h3><p>As developers, we often pride ourselves on a pixel-perfect UI. You open a browser, and the site is stunning with vibrant colors, crisp typography, and a layout that breathes. But for many projects, if you inspect element, you’ll find a structural nightmare called Div Soup.</p><p>Imagine a bowl of soup where every single ingredient is wrapped in the exact same indistinguishable plastic packaging. This is the reality of a website built entirely with &lt;div&gt; tags. While the end user sees a beautiful meal, the underlying architecture is a chaotic jumble. This isn&#39;t just a matter of neatness. It is a form of tech debt that impacts everyone from your users to your fellow developers. If the visual result is the same, why does the underlying code matter? Because a website’s value isn&#39;t just in how it looks, but in how it communicates.</p><h3>Visual Perfection vs Functional Confusion</h3><p>In frontend, we must distinguish between <em>presentation</em> and <em>meaning</em>. It is a dangerous trap to assume that if a website looks functional, it is functional. Two websites can look identical in a browser tab, yet one can be fundamentally “broken” for the machines and specialized software that power the modern web.</p><p>The core issue is the <strong>“Meaning over Presentation”</strong> mantra. A &lt;div&gt; is a generic flow container. It tells the browser and the Accessibility Tree absolutely nothing about the content’s priority or purpose. When you use a &lt;div&gt; for a button, you aren&#39;t just being messy. You are failing at a fundamental architectural level. A generic &lt;div&gt; lacks the inherent keyboard focus, &quot;click&quot; properties, and User Agent Stylesheets that a proper &lt;button&gt; element provides out of the box. Relying on visual styling to convey function creates a fragile system that lacks semantic interoperability.</p><h3>The Silent Barrier to Accessibility</h3><p>For those of us dedicated to accessibility, Semantic HTML isn’t an extra. It is the map. Screen readers rely on the DOM structure to help users navigate. When that structure is buried in a Div Soup, the map is erased. This is about more than just code. It’s about our users.</p><blockquote>“So our website can also be accessed by our friends with visual impairments, because screen readers will be able to understand the structure of our web pages.”</blockquote><p>By choosing elements that explain themselves, we ensure our digital environments are inclusive. Without semantic markers, the Accessibility Tree becomes a flat, unnavigable forest of generic nodes.</p><h3>Speaking the Language of Search Engines</h3><p>Beyond human accessibility, semantic hierarchy is a business necessity. Search engine crawlers do not see your CSS. They parse your HTML to determine what information is vital.</p><p>When you replace generic containers with specific semantic elements, you provide a clear hierarchy. You are telling the search engine, “This is the most important heading on the page,” or “This is a navigation menu.” This structural clarity allows algorithms to understand the relevance and relationship of your data. In a competitive market, semantic code is the difference between a site that is found and a site that is ignored.</p><h3>Code that Documents Itself</h3><p>We often focus on how machines read our code, but what about the humans? The source context reminds us that when we write Div Soup, other developers are confused.</p><p>E.g., a typical navigation bar. In a soup layout, a developer is forced to create a chain of generic containers:</p><p>a &lt;div&gt; with a class of top-bar-container-inner, holding another &lt;div&gt; with a class of nav-item-list. This creates a heavy, redundant naming convention just to explain what the code is doing.</p><p>In a semantic structure, that entire mess is replaced by a single &lt;nav&gt; element containing an unordered list &lt;ul&gt;. The code becomes self-documenting<strong>.</strong> By using tags like &lt;header&gt;, &lt;main&gt;, &lt;article&gt;, and &lt;footer&gt; you eliminate the need for bloated class names. The result is clean code that your teammates can read, understand, and debug in half the time.</p><h3>The Div as a Last Resort</h3><p>I teach myself in my practice projects a simple rule: always prioritize semantic elements first. The &lt;div&gt; should be a last resort. It’s a tool for layout and styling, a hook for CSS when no other element fits, and it should never be used to represent meaningful content.</p><p>Before you reach for &lt;div&gt;, ask first: Is this a list? Use &lt;ul&gt;. Is this a sidebar? Use &lt;aside&gt;. Is this a clickable action? Use &lt;button&gt;. Adhering to the <strong>Meaning over Presentation</strong> philosophy ensures architecture is resilient and future-proof.</p><h3>Conclusion: A Call for Meaningful Code</h3><p>The shift from Div Soup to Semantic HTML is a shift from writing code for browsers to writing code for the world. We are building for humans, for assistive software, and for the algorithms that organize human knowledge.</p><p>The transition from a soup of indistinguishable tags to a structured masterpiece doesn’t just make you a better developer. It makes the web a better place for everyone.</p><p>Is your current project a soup or a semantic masterpiece?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d77b9676b142" width="1" height="1" alt=""><hr><p><a href="https://medium.com/is-a-code/strategic-refactoring-escaping-div-soup-to-semantic-architecture-d77b9676b142">Strategic Refactoring Escaping Div Soup to Semantic Architecture</a> was originally published in <a href="https://medium.com/is-a-code">Is a code</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pergeseran Paradigma Vanila JavaScript → React]]></title>
            <link>https://medium.com/@agusetyawan/memahami-pergeseran-paradigma-javascript-react-5efef7dd5fb0?source=rss-88e8449b0df7------2</link>
            <guid isPermaLink="false">https://medium.com/p/5efef7dd5fb0</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[paradigm-shift]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[frontend]]></category>
            <dc:creator><![CDATA[Agus Setyawan]]></dc:creator>
            <pubDate>Sat, 31 Jan 2026 15:34:19 GMT</pubDate>
            <atom:updated>2026-02-01T17:30:54.614Z</atom:updated>
            <content:encoded><![CDATA[<h3>Pergeseran Paradigma JavaScript → React</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G8UGMhvbPByryNk7" /><figcaption>Photo by <a href="https://unsplash.com/@vladimir_d?utm_source=medium&amp;utm_medium=referral">Volodymyr Dobrovolskyy</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Jika baru belajar dan sudah mulai solid dengan Vanilla JS. Memanipulasi DOM dengan getElementById, menambahkan event listener, mengubah innerHTMLlalu tiba-tiba masuk ke React, kemungkinan besar akan merasa:</p><p>“Kok tidak ada DOM manipulation?”</p><p>“HTML di dalam JavaScript? Seriously?”</p><p>Kebingungan ini wajar karena kamu sedang mengalami pergeseran paradigma dari imperatif ke deklaratif. Ini bukan sekadar soal belajar syntax baru namun lebih ke tentang mengubah cara berpikir fundamental dalam membangun <em>interface.</em></p><p>Aku tulis artikel ini untuk mendokumentasikan pemahaman akan perbedaan paradigma tersebut, sebagai fondasi mental sebelum ke konsep-konsep React selanjutnya.</p><blockquote>“Imperatif vs Deklaratif”</blockquote><h3>Imperatif: “How”</h3><p>Paradigma imperatif fokus pada langkah-langkah detail bagaimana mencapai hasil. Memberitahu komputer apa yang harus dilakukan, langkah demi langkah. Seperti memasak nasi goreng sendiri.</p><blockquote><em>“Ambil wajan, panaskan, tuang minyak, tunggu panas, masukkan bumbu nasi goreng(bawang putih, bawang merah, cabe), pecahkan telur, orak-arik telur, masukan nasi ke wajan, goreng dan aduk, tambahkan kecap, taruh di piring.”</em></blockquote><h3>Deklaratif: “What”</h3><p>Paradigma deklaratif fokus pada hasil akhir yang diinginkan. Dengan mendeskripsikan apa yang ingin ditampilkan, framework yang mengurus detailnya. Seperti memesan nasi goreng di Solaria.</p><blockquote><em>“Saya mau nasi goreng.”</em></blockquote><p><em>Chef yang tahu caranya, kita taunya sudah di piring dan siap dimakan.</em></p><h3>Mari lihat perbedaannya dalam kode, di fitur Counter berikut:</h3><h4>Vanilla JavaScript (Imperatif)</h4><pre>// 1. Ambil elemen dari DOM<br>const button = document.getElementById(&#39;counter-btn&#39;);<br>let counter = 0;<br><br>// 2. Definisikan fungsi untuk update UI<br>function updateUI() {<br>  button.innerHTML = `Count: ${counter}`;<br>}<br><br>// 3. Tambahkan event listener<br>button.addEventListener(&#39;click&#39;, () =&gt; {<br>  counter++;           // 4. Update data -&gt; di memory Js<br>  updateUI();          // 5. Update UI secara manual -&gt; di DOM<br>});<br><br>// 6. Set initial state<br>updateUI();</pre><ul><li>Mengontrol setiap langkah, bagaimana update terjadi</li><li>Manual sync antara data (counter) dan UI (innerHTML)</li></ul><h4>React (Deklaratif)</h4><pre>function Counter() {<br>  const [count, setCount] = useState(0);<br>  <br>  return (<br>    &lt;button onClick={() =&gt; setCount(count + 1)}&gt;<br>      Count: {count}<br>    &lt;/button&gt;<br>  );<br>}</pre><ul><li>Mendeskripsikan UI berdasarkan state, apa yang harus ditampilkan</li><li>React otomatis sync data dan UI</li></ul><h3>Perbedaan Fundamental yang Perlu Dipahami</h3><h4>1. State Management</h4><p><strong>Imperatif:</strong></p><pre>let counter = 0;           // State di JS<br>button.innerHTML = &#39;0&#39;;    // State di DOM<br><br>// Dua tempat berbeda, bisa tidak sinkron karena harus diupdate manual state yang di JS dan di DOM</pre><p><strong>Deklaratif:</strong></p><pre>const [counter, setCounter] = useState(0);  // Single source of truth<br>return &lt;div&gt;{counter}&lt;/div&gt;;                // UI dan data otomatis sinkron</pre><h4>2. Update UI</h4><p><strong>Imperatif:</strong></p><pre>// Harus eksplisit update DOM<br>counter++;<br>element.innerHTML = `Count: ${counter}`;</pre><p><strong>Deklaratif:</strong></p><pre>// Cuma update state, React yang urus UI<br>setCount(count + 1);<br>// UI otomatis re-render</pre><p>Di React, tidak langsung manipulasi DOM. Ubah state, React akan re-render komponen.</p><h3>Contoh Lebih Kompleks Membuat Todo List</h3><h4>Vanilla JavaScript (Imperatif)</h4><pre>const todoList = document.getElementById(&#39;todo-list&#39;);<br>const todos = [];<br><br>function addTodo(text) {<br>  // 1. Update data<br>  const todo = { id: Date.now(), text };<br>  todos.push(todo);<br>  <br>  // 2. Buat elemen DOM<br>  const li = document.createElement(&#39;li&#39;);<br>  li.textContent = text;<br>  li.id = `todo-${todo.id}`;<br>  <br>  // 3. Buat tombol delete<br>  const deleteBtn = document.createElement(&#39;button&#39;);<br>  deleteBtn.textContent = &#39;Delete&#39;;<br>  deleteBtn.onclick = () =&gt; deleteTodo(todo.id);<br>  <br>  // 4. Gabungkan dan append<br>  li.appendChild(deleteBtn);<br>  todoList.appendChild(li);<br>}<br><br>function deleteTodo(id) {<br>  // 1. Update data<br>  const index = todos.findIndex(t =&gt; t.id === id);<br>  todos.splice(index, 1);<br>  <br>  // 2. Update DOM<br>  const element = document.getElementById(`todo-${id}`);<br>  element.remove();<br>}</pre><ul><li>Setiap operasi harus update 2 tempat (data + DOM)</li><li>Mudah lupa update salah satunya, akan jadi bug</li></ul><h4>React (Deklaratif)</h4><pre>function TodoApp() {<br>  const [todos, setTodos] = useState([]);<br>  <br>  const addTodo = (text) =&gt; {<br>    setTodos([...todos, { id: Date.now(), text }]);<br>  };<br>  <br>  const deleteTodo = (id) =&gt; {<br>    setTodos(todos.filter(t =&gt; t.id !== id));<br>  };<br>  <br>  return (<br>    &lt;ul&gt;<br>      {todos.map(todo =&gt; (<br>        &lt;li key={todo.id}&gt;<br>          {todo.text}<br>          &lt;button onClick={() =&gt; deleteTodo(todo.id)}&gt;Delete&lt;/button&gt;<br>        &lt;/li&gt;<br>      ))}<br>    &lt;/ul&gt;<br>  );<br>}</pre><ul><li>Cukup update 1 tempat (state)</li><li>UI otomatis re-render sesuai state</li><li>Lebih ringkas dan mudah dibaca</li></ul><blockquote>❌ Misconception 1: “React cuma syntactic sugar dari vanilla JS”</blockquote><blockquote><strong>Realita:</strong> React adalah paradigma berbeda. Virtual DOM, reconciliation, dan unidirectional data flow adalah konsep yang tidak ada di vanilla JS.</blockquote><blockquote>❌ Misconception 2: “Deklaratif lebih lambat karena abstraksi tinggi”</blockquote><blockquote><strong>Realita:</strong> React menggunakan Virtual DOM dan diffing algorithm yang sangat efisien. Untuk aplikasi kompleks, React justru lebih cepat karena hanya update bagian DOM yang berubah.</blockquote><blockquote>❌ Misconception 3: “Imperatif sudah usang, tidak perlu dipelajari”</blockquote><blockquote><strong>Realita:</strong> Imperatif tetap penting untuk algoritma, data processing, dan memahami low-level operations. Keduanya punya tempat masing-masing.</blockquote><blockquote>❌ Misconception 4: “Di React tidak boleh manipulasi DOM sama sekali”</blockquote><blockquote><strong>Realita:</strong> Ada kasus edge (misal integrasi library pihak ketiga) yang butuh direct DOM access via ref. Tapi ini exception, bukan rule.</blockquote><h3>Kesimpulan</h3><p>Perpindahan dari vanilla JavaScript ke React bukan hanya tentang belajar syntax baru tapi tentang <em>paradigm shift</em> dari imperatif ke deklaratif.</p><ol><li><strong>Imperatif</strong> mengajarkan kontrol dan detail, hal ini penting untuk fondasi programming</li><li><strong>Deklaratif</strong> mengajarkan abstraksi dan composition, cocok untuk membangun UI kompleks</li><li>Keduanya bukan superior/inferior, hanya berbeda use case</li><li>React memilih deklaratif karena lebih <em>scalable</em> untuk aplikasi UI modern dan <em>Trust the framework</em>, fokus pada state dan UI yang diinginkan</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5efef7dd5fb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Skills You Won’t Learn in Tutorials: A Reflection]]></title>
            <link>https://medium.com/@agusetyawan/the-skills-you-wont-learn-in-tutorials-a-reflection-41c0d729486e?source=rss-88e8449b0df7------2</link>
            <guid isPermaLink="false">https://medium.com/p/41c0d729486e</guid>
            <category><![CDATA[people]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[discussion]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Agus Setyawan]]></dc:creator>
            <pubDate>Wed, 31 Dec 2025 16:37:17 GMT</pubDate>
            <atom:updated>2026-01-16T15:05:52.368Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fhVXUlAGniN-Eybt" /><figcaption>Photo by <a href="https://unsplash.com/@timothycdykes?utm_source=medium&amp;utm_medium=referral">Timothy Dykes</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The Skills You Won’t Learn in Tutorials, But Companies Pay For. Ada satu kenyataan yang sering terlambat disadari oleh banyak developer, yaitu hal yang membuat kita dipromosikan, dihargai, dan dibayar mahal sering kali tidak ada hubungannya dengan seberapa hafal kita pada syntax atau <em>beauty of coding style </em>kita.</p><p>Jangan salah paham. <em>Technical skill</em> itu wajib. Itu adalah karcis masuk. Tapi, pernahkah melihat developer yang kodingannya biasa saja tapi karirnya melesat cepat? Atau sebaliknya, developer jenius yang justru “stuck” atau bahkan terkena L word?</p><p>Setelah <em>observing </em>dan ngobrol dengan mentor yang puluhan tahun di kolam ini, saya menyadari bahwa “game” yang sebenarnya bukanlah tentang menulis kode.</p><blockquote><strong>Perusahaan Membayarmu untuk Menghilangkan Masalah, Bukan Sekadar Menulis Kode</strong></blockquote><p>Banyak terjebak dalam pola pikir: “Saya dibayar untuk koding.” Padahal, kode hanyalah alatnya. Tujuan utamanya adalah solusi bisnis.</p><p>Ada perbedaan besar antara developer yang menghilang 3 hari untuk membuat fitur canggih yang tidak diminta siapa pun, dengan developer yang menghabiskan 30 menit bertanya untuk memahami masalah akar, lalu menyarankan solusi sederhana (bahkan mungkin tanpa koding) yang menghemat waktu tim berhari-hari.</p><p>Sering kali, solusi terbaik bukanlah <em>dashboard real-time</em> dengan WebSocket yang rumit, melainkan laporan Excel sederhana yang memang dibutuhkan tim Sales setiap Senin pagi. <em>Seniority</em> bukan diukur dari seberapa kompleks teknologimu.</p><blockquote><strong>“Judgment” Adalah Skill Paling Underrated</strong></blockquote><p>Di tutorial koding, jalan menuju solusi selalu lurus. Di dunia nyata, kita dihadapkan pada ketidakpastian.</p><p>Skill mahal di sini adalah kemampuan untuk mencium bau <em>requirement</em> yang buruk sebelum itu menjadi fitur yang gagal. Kemampuan untuk berkata, “<em>Wait</em>, kalau kita build ini sekarang, siapa yang akan <em>maintain</em> 6 bulan lagi?” atau “Apakah ini sepadan dengan beban operasionalnya?”</p><p>Mengetahui kapan harus mengejar “kesempurnaan arsitektur” dan kapan harus <em>“ship it fast and iterate”</em> adalah seni yang membedakan level seorang developer dengan yang lain.</p><blockquote><strong>Komunikasi Bukan Soft Skill, Itu Core Skill</strong></blockquote><p>Kamu bisa membangun sistem paling canggih di dunia, tapi kalau tidak bisa menjelaskan mengapa itu penting kepada <em>stakeholders</em>, atau jika dokumentasinya membuat orang lain pusing dan mual, sistem itu tidak bernilai.</p><p>Menulis kode yang “canggih” itu memuaskan ego pribadi. Tapi menulis kode yang jelas, membosankan, dan mudah dipahami oleh developer yang baru masuk seminggu ke dalam tim, itulah <em>engineering </em>sesungguhnya.</p><p>Kode ditulis untuk manusia. Jika kamu membuat kode yang begitu rumit sehingga hanya kamu yang bisa menyentuhnya, kamu bukan aset, kamu adalah <em>bottleneck</em>.</p><blockquote><strong>Memahami Konteks Politik dan Manusia</strong></blockquote><p>Bukan politik kantor yang saling sikut, melainkan pemahaman bahwa organisasi terdiri dari manusia dengan motivasi, ketakutan, dan tujuan yang berbeda.</p><p>Developer yang sukses tahu cara memposisikan ide teknis mereka ke dalam bahasa bisnis. Mereka tidak bilang “Kita harus refactor karena kodenya jelek”, tapi “Refactor ini akan mengurangi <em>bug rate</em> sehingga kita bisa rilis fitur lebih cepat di Q3.”</p><p>Memahami siapa <em>stakeholder</em>-mu dan apa yang membuat mereka tidak bisa tidur nyenyak adalah kunci agar inisiatif teknismu didukung, bukan dijegal.</p><blockquote><strong>Mengelola Ego dan Menerima Feedback</strong></blockquote><p>Momen di mana menerima code review pada PR/MR dan tidak merasa diserang secara personal, di situlah kamu tumbuh. Banyak karir terhambat karena sikap defensif.</p><blockquote><strong>Self-Awareness dan Manajemen Energi</strong></blockquote><p>Tutorial tidak mengajarkanmu cara menghindari <em>burnout</em>. Industri ini sering memuja jam kerja panjang, tapi konsistensi jangka panjang jauh lebih berharga daripada <em>sprint</em> gila-gilaan yang berakhir dengan kelelahan mental.</p><p>Mengenali ritme kerja sendiri, menyadari bias estimasi sendiri, dan berani berkata “tidak” demi menjaga kualitas kerja adalah bagian dari profesionalisme.</p><h3>Ikhtisar: Kedewasaan Profesional</h3><p>Pada akhirnya, apa yang perusahaan cari bisa dirangkum dalam satu frasa: Kedewasaan Profesional.</p><p>Ini tentang mengambil <em>ownership</em>. Ini tentang melihat gambaran besar. Ini tentang menjadi orang yang memudahkan hidup rekan satu tim, bukan mempersulitnya.</p><p>Tutorial dan <em>online course </em>memberi dasar-dasar teknis. Itu penting. Tapi pertumbuhan karir yang eksponensial datang dari pengalaman manusiawi yang berantakan: komunikasi, empati, pengambilan keputusan di bawah tekanan, dan pemahaman bisnis.</p><p>Jadi, teruslah belajar bertumbuh. Tapi jangan lupa untuk melatih meta-skill ini. Karena inilah yang akan membuat tetap relevan ketika ribuan orang lain memiliki sertifikat yang sama denganmu.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41c0d729486e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mark the Props as Read-only: Memahami Warning TypeScript di React]]></title>
            <link>https://medium.com/@agusetyawan/mark-the-props-as-read-only-memahami-warning-typescript-di-react-80ad891d2ce6?source=rss-88e8449b0df7------2</link>
            <guid isPermaLink="false">https://medium.com/p/80ad891d2ce6</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Agus Setyawan]]></dc:creator>
            <pubDate>Sat, 15 Nov 2025 19:23:03 GMT</pubDate>
            <atom:updated>2025-11-15T19:23:03.300Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KX9Zrch-qosTmt9wjQnJ3w.png" /></figure><p>Pernah bertanya-tanya mengapa props di React tidak boleh diubah? Atau mungkin pernah melihat Readonly&lt;&gt; di TypeScript dan bingung apa gunanya? Warning seperti di <em>screencapture</em> di atas itu apa maksudnya? Kenapa di props-nya ada garis cacing kuning?</p><h3>Apa Itu Props Read-only?</h3><p>Props read-only artinya props tidak boleh dimodifikasi secara langsung di dalam komponen yang menerimanya. Props itu seperti parameter fungsi yang value-nya diberikan dari luar (<em>parent component</em>) dan hanya boleh dibaca, tidak boleh diubah langsung.</p><blockquote><strong>Note:</strong> Di React, <strong>semua props sudah pasti read-only by design</strong>. Ini adalah aturan fundamental React. Yang bikin beda adalah bagaimana bahasa pemrograman (JavaScript atau TypeScript) membantu menegakkan aturan ini.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S6lH2Dn0_WsaVQtLSTrbQQ.png" /><figcaption><a href="https://react.dev/learn/passing-props-to-a-component">https://react.dev/learn/passing-props-to-a-component</a></figcaption></figure><h4>Apa itu Parent Component &amp; Child Component?</h4><p>Kalau masih ingat, di atas tadi telah disinggung soal <em>parent component</em>. Kita perlu tahu siapa yang melempar dan siapa yang menerima props agar punya mental model yang jelas tentang bagaimana data mengalir di antara komponen React.</p><p><strong>📌 Parent Component </strong>adalah yang melempar props (pemberi)<br><strong>📌 Child Component </strong>adalah yang menerima props (penerima)</p><pre>//PARENT COMPONENT<br>function App() {<br>  return (<br>    &lt;div&gt;<br>      &lt;Welcome name=&quot;John Doe&quot; age={25} /&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>//CHILD COMPONENT<br>function Welcome(props) {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Hello, {props.name}&lt;/h1&gt;<br>      &lt;p&gt;Umur: {props.age}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><h3>Kalau Mau Ubah Data, Bagaimana?</h3><p>Untuk mengubah data dari <em>parent component</em> gunakan state bukan dari props langsung.</p><pre>import { useState } from &#39;react&#39;;<br><br>function Counter(props) {<br>  const [count, setCount] = useState(props.initialCount); <br>  //props.initialCount tetap read-only, tapi count bisa diubah dengan setCount<br><br>  return (<br>    &lt;button onClick={() =&gt; setCount(count+1)}&gt;<br>      Count: {count}<br>    &lt;/button&gt;    <br>  )<br>}</pre><h4>Apa yang terjadi jika props diubah paksa?</h4><p>Karena props sudah pasti read-only by design di React, pertanyaannya adalah bagaimana mencegah developer tidak sengaja melanggar aturan ini.</p><p>Jika menggunakan React dengan JavaScript, tidak ada <em>safety net </em>di waktu <em>compile </em>dan secara teknis kode akan tetap jalan namun ESlint akan “ngomel” dengan ngasih garis cacing seperti gambar di paling atas serta hal tersebut melanggar aturan React.</p><pre>function Welcome(props) {<br>  props.name = &quot;Budi&quot;; // Tidak ada error!<br>  // Tapi ini MELANGGAR aturan React<br><br>  return &lt;h1&gt;Hello, {props.name}&lt;/h1&gt;;<br>}</pre><p>Kalau menggunakan React + TypeScript akan bisa lebih <em>safety </em>karena dengan menggunakan Readonly&lt;&gt; memberikan proteksi di waktu <em>compile.</em></p><pre>function Welcome(props: Readonly&lt;{name: string}&gt;) {<br>  props.name = &quot;Budi&quot;; // ❌ TypeScript ERROR saat compile!<br>  // Error: Cannot assign to &#39;name&#39; because it is a read-only property<br><br>  return &lt;h1&gt;Hello, {props.name}&lt;/h1&gt;;<br>}</pre><blockquote>Note: Proteksi TypeScript hanya di compile time (waktu development). Setelah di-compile ke JavaScript dan jalan di browser (runtime), proteksi ini hilang.</blockquote><blockquote>Tapi itu cukup untuk mencegah developer membuat kesalahan sejak awal</blockquote><p>Dampak buruk yang bisa terjadi jika props diubah paksa dapat menjadikan bugs yang sulit di-tracing karena <em>parent component </em>tidak tahu data telah berubah dan akan sulit di-debug.</p><p>Sebaiknya upayakan untuk:</p><ol><li>Selalu perlakukan props sebagai read-only meskipun JavaScript tidak melarang</li><li>Gunakan TypeScript dengan Readonly&lt;&gt; untuk proteksi ekstra</li><li>Gunakan state (setState) untuk data yang perlu diubah</li><li>Jangan mutasi object/array di props. Buat <em>copy</em> dulu jika perlu transformasi</li><li>Dokumentasikan. Bikin dokumentasi dengan jelas dan rapi di setiap proyek yang dikerjakan</li></ol><pre>import { useState } from &#39;react&#39;;<br><br>interface UserProps {<br>  readonly id: number;<br>  readonly initialName: string;<br>}<br><br>function UserProfile(props: Readonly&lt;UserProps&gt;) {<br>  // Props tidak diubah langsung, tapi di-copy dulu ke state<br>  const [name, setName] = useState(props.initialName);<br>  <br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;User #{props.id}&lt;/h1&gt;<br>      &lt;input <br>        value={name} <br>        onChange={(e) =&gt; setName(e.target.value)} <br>      /&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><h3>Ikhtisar</h3><blockquote><em>“Props untuk dibaca, state untuk diubah” adalah</em> golden rule <em>di React</em></blockquote><p>Props read-only adalah salah satu aturan fundamental di React yang membuat aplikasi lebih predicable, maintainable, dan scalable. Meskipun JavaScript tidak memaksa aturan ini secara runtime, mengikuti aturan adalah best practice yang akan menghindarkan dari banyak bugs tersembunyi yang sulit di-debug.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80ad891d2ce6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Menulis Commit Message yang Bermakna]]></title>
            <link>https://medium.com/@agusetyawan/menulis-commit-message-yang-bermakna-0234ff875bfc?source=rss-88e8449b0df7------2</link>
            <guid isPermaLink="false">https://medium.com/p/0234ff875bfc</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[tips]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[developer]]></category>
            <dc:creator><![CDATA[Agus Setyawan]]></dc:creator>
            <pubDate>Tue, 30 Sep 2025 16:53:34 GMT</pubDate>
            <atom:updated>2025-10-04T17:27:41.039Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7VPWyPF3Gs5-1qh67cDJew.png" /></figure><h3><strong>The Problem</strong></h3><p>Menggunakan commit message “fix bug”, “update”, “done”, atau “wip” membuat itu tidak mudah dimengerti tentang perubahan apa yang dilakukan. Harus menyelam dulu ke <em>codebase-</em>nya, membuka dan masuk ke dalam barisan <em>line of code </em>baru bisa tau perubahan apa yang telah dilakukan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DmtZMu5J9lVZisoDnPRFnA.png" /><figcaption>Commit message</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z5FNxURq4L7ChMpLIBRBxQ.png" /></figure><p>Kamu melakukan commit begitu juga? Bayangkan tiga bulan kemudian harus mencari tahu kapan dan perubahan bagian mana fitur login ditambahkan atau bug fitur A diperbaiki. Tanpa commit message yang jelas, sudah pasti terpaksa membuka satu per satu file yang berubah untuk memahami apa yang terjadi. Apalagi kalau bekerja dalam tim, anggota tim yang lain harus menghabiskan waktu ekstra hanya untuk memahami perubahan kita dan sebaliknya.</p><h3>Langkah Pertama: Jelaskan Commit Dengan Spesifik &amp; Deskriptif</h3><p>Prinsip dasarnya sederhana, commit message harus menjelaskan apa yang dikerjakan tanpa perlu membuka kode.</p><p>Gunakan kalimat perintah, <em>imperative</em> dan bentuk sekarang (present tense):</p><p><strong>Contoh Buruk 🙅</strong></p><ul><li>fixed stuff</li><li>updated file</li><li>changes</li></ul><p><strong>Contoh Baik ✅</strong></p><ul><li>ubah ukuran maksimal upload foto profil menjadi 5MB</li><li>tambahkan fitur filter berdasarkan tanggal</li><li>perbaiki error saat submit form tanpa mengisi email</li><li>hapus dependensi yang tidak digunakan</li><li>tambahkan validasi untuk input nomor telepon</li></ul><p>Dengan meluangkan waktu 15 detik menulis commit message yang deskriptif, akan menghemat banyak waktu di masa depan.</p><h3>Langkah Kedua: Kategorikan Commit</h3><p>Setelah membuat pesan yang deskriptif, kita bisa meningkatkannya dengan menambahkan kategori di awal. Ini memudahkan kita mengenali jenis perubahan hanya dengan melihat kata pertama.</p><p>Beberapa <em>prefix</em> yang umum digunakan:</p><ul><li><strong>feat</strong> — menambah atau menghapus fitur</li><li><strong>fix</strong> — memperbaiki bug</li><li><strong>docs</strong> — perubahan dokumentasi</li><li><strong>style</strong> — formatting kode, menghapus whitespace, menata ulang import</li><li><strong>refactor</strong> — mengubah struktur kode tanpa mengubah fungsionalitas</li><li><strong>test</strong> — menambah atau memperbaiki testing</li><li><strong>chore</strong> — instalasi package, update dependencies</li><li><strong>perf</strong> — perbaikan performa aplikasi</li></ul><p>Dengan begitu sekarang kita bisa dengan cepat mem-filter commit berdasarkan kategori yang kita cari.</p><h3>Langkah Ketiga: Ikuti Konvensi yang Konsisten</h3><p>Untuk membuat commit message yang lebih terstruktur dan bisa dibaca oleh tools otomatis, kita bisa mengikuti standar <em>Conventional Commits.</em></p><pre>&lt;tipe&gt;[scope opsional]: &lt;deskripsi&gt;<br><br>[body opsional]<br>[footer opsional]</pre><h4>Aturan Penting</h4><ol><li><strong>Tipe wajib diisi</strong> — gunakan salah satu kategori yang sudah ditentukan</li><li><strong>Scope opsional</strong> — bisa menambahkan scope untuk spesifik area (misal: auth, dashboard, payment)</li><li><strong>Deskripsi harus jelas</strong> — jelaskan apa yang dilakukan</li><li><strong>Gunakan huruf kecil</strong> — jangan kapitalisasi di awal deskripsi</li><li><strong>Tanpa tanda titik</strong> — jangan tambahkan titik di akhir deskripsi</li><li><strong>Satu commit untuk satu perubahan</strong> — jika ada beberapa perubahan berbeda, commit secara terpisah</li></ol><p><strong>Breaking Change</strong> — jika perubahan tidak kompatibel dengan versi sebelumnya, tambahkan tanda seru:</p><pre>feat!: ubah struktur response API user profile</pre><h4>Contoh Penerapan</h4><pre>feat(dashboard): tambahkan grafik statistik penjualan bulanan<br><br>fix(checkout): perbaiki total harga tidak update saat hapus item<br><br>docs: perbarui panduan instalasi di README<br><br>style(components): rapikan indentasi pada file Button.jsx<br><br>refactor(utils): sederhanakan fungsi format tanggal<br><br>test(api): tambahkan unit test untuk endpoint login<br><br>chore: update react dari versi 17 ke 18<br><br>perf(images): implementasi lazy loading untuk galeri foto</pre><p>Jika perubahan kompleks, tambahkan body untuk menjelaskan detailnya:</p><pre>feat(payment): integrasi payment gateway Midtrans<br><br>- Tambahkan konfigurasi API key untuk production dan sandbox<br>- Implementasi callback handler untuk update status pembayaran<br>- Tambahkan halaman konfirmasi pembayaran<br><br>Closes #145</pre><h3>Langkah Keempat: Otomasi dengan Tools</h3><p>Dengan mengikuti konvensi di atas, bisa menggunakan tools seperti standard-version untuk:</p><ul><li>Membuat changelog otomatis</li><li>Menaikkan versi package secara otomatis</li><li>Membuat git tag</li></ul><p>Changelog akan berisi commit dengan tipe feat dan fix yang penting untuk user, tanpa perlu menyertakan commit style atau chore yang tidak relevan.</p><p>Agar semua anggota tim mengikuti konvensi yang sama, gunakan commitlint dengan husky. Tools ini akan memvalidasi commit message sebelum di-commit, sehingga tidak ada yang bisa commit dengan pesan yang tidak sesuai aturan.</p><p><strong>Instalasi</strong></p><pre>npm install --save-dev @commitlint/cli @commitlint/config-conventional husky</pre><p>Dengan cara ini, tidak akan bisa melakukan commit jika tidak mengikuti konvensi yang telah disepakati.</p><h3>Lalu, Kapan Harus Melakukan Commit?</h3><ul><li>Commit setiap kali menyelesaikan satu unit pekerjaan yang logis</li><li>Jangan menunggu sampai akhir hari untuk commit semua perubahan sekaligus</li><li>Pisahkan refactoring dari penambahan fitur</li></ul><p>Menulis commit message yang baik adalah investasi waktu yang sangat berharga, dengan:</p><ol><li>✅ Menulis deskripsi yang spesifik dan jelas</li><li>✅ Mengkategorikan dengan tipe yang konsisten</li><li>✅ Mengikuti konvensi Conventional Commits</li><li>✅ Menggunakan tools untuk automasi dan validasi</li></ol><h3>Summary</h3><p>Kita belajar dengan melakukan commit message yang deskriptif, menambahkan kategorinya, menggunaan aturan Conventional Commits akan membuat proses development lebih efisien, code review lebih cepat, dan maintenance project lebih mudah baik untuk diri sendiri maupun tim.</p><blockquote>commit message yang baik adalah dokumentasi terbaik untuk history project.</blockquote><p>Gimana commit message kamu sekarang?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0234ff875bfc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Belajar Reactjs : 20 Konsep Dasar yang Paling Penting]]></title>
            <link>https://medium.com/@agusetyawan/belajar-reactjs-20-konsep-dasar-yang-paling-penting-c08c7d35b379?source=rss-88e8449b0df7------2</link>
            <guid isPermaLink="false">https://medium.com/p/c08c7d35b379</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Agus Setyawan]]></dc:creator>
            <pubDate>Sun, 31 Aug 2025 14:10:39 GMT</pubDate>
            <atom:updated>2025-08-31T14:10:39.899Z</atom:updated>
            <content:encoded><![CDATA[<h3>Belajar Reactjs : 20 Konsep Dasar yang Paling Penting</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7V0gTX8hpeZlENak" /><figcaption>Photo by <a href="https://unsplash.com/@lautaroandreani?utm_source=medium&amp;utm_medium=referral">Lautaro Andreani</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>React sering kali terdengar penuh dengan istilah-istilah keren seperti <em>reconciliation</em>, <em>composition</em>, atau <em>error boundaries</em>. Semua istilah itu bisa dijelaskan dengan sederhana. Yuk, kita mulai dari dasar dan bahas satu per satu.</p><h3>1️⃣ Components</h3><p>Komponen adalah blok penyusun aplikasi React. Semua yang terlihat di aplikasi mulai dari tombol, input, sampai satu halaman penuh dibuat dari komponen.</p><p>Bayangin aja seperti Lego: satu keping bisa dipakai berkali-kali untuk bikin bentuk yang berbeda. Di React, komponen biasanya ditulis sebagai fungsi JavaScript yang mengembalikan markup.</p><h3>2️⃣ JSX</h3><p>Komponen React tidak mengembalikan HTML biasa, tapi sesuatu yang mirip namanya <strong>JSX</strong> (<em>JavaScript XML</em>). JSX ini sebenarnya JavaScript yang menyamar jadi HTML.</p><p>Sebenarnya kita bisa menulis UI dengan createElement, tapi kodenya cepat jadi berantakan, makanya hampir semua orang pakai JSX.</p><p>Perlu diingat, karena ini JavaScript, penulisan atribut sedikit beda. Misalnya class jadi className.</p><h3>3️⃣ Curly Braces {}</h3><p>Kelebihan JSX dibanding HTML biasa adalah kita bisa menaruh nilai JavaScript langsung di dalam kurung kurawal.</p><p>Contoh: kita bisa menampilkan teks dari variabel, menghitung angka, atau menambahkan style pakai objek JavaScript.</p><h3>4️⃣ Fragments</h3><p>Fungsi JavaScript cuma bisa mengembalikan <strong>satu</strong> hal. Sama juga di React: komponen harus punya satu elemen induk. Kalau nggak, error.</p><p>Daripada nambah &lt;div&gt; yang nggak perlu, kita bisa pakai <strong>React Fragment</strong> (&lt;&gt;...&lt;/&gt;). Ini seperti pembungkus kosong.</p><h3>5️⃣ Props</h3><p>Kalau mau kirim data dari satu komponen ke komponen lain, kita pakai props. Bentuknya mirip atribut HTML, tapi kita bisa ngisi dengan data apa pun. Di dalam komponen penerima, props ini bisa diakses lewat parameter fungsi.</p><h3>6️⃣ Children</h3><p>Props juga bisa dipakai buat mengirim komponen lain. Caranya dengan membuat tag buka-tutup, lalu isi di dalamnya. Isi itu disebut children.</p><p>Fitur ini sangat berguna untuk bikin layout umum, misalnya Card yang bisa membungkus isi apa pun di dalamnya.</p><h3>7️⃣ Keys</h3><p>Saat bikin daftar dengan map, React butuh tahu elemen mana yang berbeda. Itu sebabnya kita harus menambahkan prop key sebagai identitas unik.</p><p>Kalau nggak ada nilai unik, kita bisa pakai index array (namun tidak selalu disarankan).</p><h3>8️⃣ Rendering</h3><p>Bagaimana React menampilkan semua kode kita ke browser? Itu lewat proses rendering.</p><p>React pakai sesuatu yang namanya Virtual DOM. Saat state berubah:</p><ol><li>React update Virtual DOM.</li><li>React membandingkan (diffing) versi lama dan baru.</li><li>React hanya update bagian yang berubah ke DOM asli (<em>reconciliation</em>).</li></ol><p>Ini yang bikin React efisien.</p><h3>9️⃣ Event Handling</h3><p>React punya event bawaan seperti onClick, onChange, atau onSubmit. Bedanya dengan HTML biasa, event ini ditulis dalam camelCase.</p><p>Kita bisa menghubungkan event dengan fungsi untuk merespons interaksi pengguna.</p><h3>🔟 State</h3><p>Kalau props dipakai buat mengirim data antar komponen, <strong>state</strong> dipakai untuk menyimpan data di dalam komponen itu sendiri.</p><p>State ibarat snapshot kondisi aplikasi. Kita bikin state dengan hook seperti useState. Setiap kali state berubah, React otomatis render ulang bagian yang perlu.</p><h3>1️⃣1️⃣ Controlled Components</h3><p>Kalau kita mau input punya perilaku yang lebih terkontrol, kita pakai controlled component. Nilai input ditentukan oleh state, dan setiap perubahan input akan mengupdate state.</p><p>Dengan begitu, perilaku input bisa sepenuhnya kita atur lewat JavaScript.</p><h3>1️⃣2️⃣ useState Hook</h3><p>useState adalah hook paling sering dipakai di React. Hook ini memberi kita dua hal: variabel state dan fungsi untuk mengubahnya.</p><p>Selain useState, ada hook lain seperti:</p><ul><li>useReducer → mengatur state kompleks.</li><li>useEffect → menjalankan efek samping.</li><li>useRef → referensi ke elemen DOM.</li><li>useContext → akses data global.</li></ul><h3>1️⃣3️⃣ Purity</h3><p>Komponen React idealnya pure function: input sama → output sama.</p><p>Komponen yang pure nggak boleh sembarangan mengubah variabel luar atau state saat render. Kalau dilanggar, hasil render bisa kacau.</p><h3>1️⃣4️⃣ Strict Mode</h3><p>React menyediakan Strict Mode untuk membantu kita menemukan pola buruk sejak dini. Biasanya dipakai di root app dengan cara membungkus &lt;App /&gt;.</p><h3>1️⃣5️⃣ Effects</h3><p>Kadang kita butuh jalanin sesuatu di luar React, misalnya fetch data dari server atau pakai API browser. Itu disebut side effect.</p><p>React punya useEffect buat menangani hal ini. Contoh umum: fetch data saat komponen pertama kali muncul.</p><h3>1️⃣6️⃣ Refs</h3><p>Kalau kita butuh akses langsung ke elemen DOM (misalnya fokus ke input), kita bisa pakai ref.</p><p>Ref dibuat dengan useRef, lalu dipasang lewat ref={myRef}. Dengan begitu kita bisa pegang elemen DOM secara langsung.</p><h3>1️⃣7️⃣ Context</h3><p>Kalau props terlalu ribet karena harus oper data lewat banyak level, kita bisa pakai Context.</p><p>Dengan Context, data bisa diakses dari komponen mana pun yang berada dalam Provider, tanpa harus melewati semua komponen perantara.</p><h3>1️⃣8️⃣ Portals</h3><p>Kadang elemen perlu ditampilkan di luar hirarki komponen, misalnya modal atau tooltip. Untuk itu kita bisa pakai Portal.</p><p>Portals memungkinkan kita me-render komponen ke elemen HTML tertentu di luar root utama.</p><h3>1️⃣9️⃣ Suspense</h3><p>Suspense membantu kita menampilkan fallback UI (misalnya loading spinner) ketika sebuah komponen atau datanya masih dimuat. Cocok untuk lazy loading.</p><h3>2️⃣0️⃣ Error Boundaries</h3><p>Kalau ada error di dalam render komponen, biasanya seluruh aplikasi bisa crash. Untungnya React punya Error Boundary, yaitu komponen khusus untuk menangkap error dan menampilkan fallback UI.</p><p>Dengan begitu, aplikasi tetap jalan meski ada bagian yang error.</p><h3>Penutup</h3><p>Kalau baru mulai belajar coba fokus dulu ke components, props, state, event handling, dan hooks dasar seperti useState dan useEffect.</p><p>Seiring waktu, akan semakin terbiasa dengan konsep lain seperti Context, Suspense, sampai Error Boundaries.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c08c7d35b379" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Back to Basic: Should we use <link> or @import?]]></title>
            <link>https://medium.com/@agusetyawan/back-to-basic-should-we-use-link-or-import-163c13ad2b79?source=rss-88e8449b0df7------2</link>
            <guid isPermaLink="false">https://medium.com/p/163c13ad2b79</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[user-experience]]></category>
            <category><![CDATA[web-performance]]></category>
            <dc:creator><![CDATA[Agus Setyawan]]></dc:creator>
            <pubDate>Thu, 31 Jul 2025 14:24:38 GMT</pubDate>
            <atom:updated>2025-08-23T12:34:15.439Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*I75Wv6ZjlbDVdsE2" /><figcaption>Photo by <a href="https://unsplash.com/@anniespratt?utm_source=medium&amp;utm_medium=referral">Annie Spratt</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>I used to think that including stylesheet in a website was just a matter of preference. Use &lt;link&gt; or @import Same thing, right?</p><p>Well, not exactly.</p><p>Turns out, choosing between &lt;link&gt; and @importhas a real impact on how fast a website loads and how accessible it is to users. After learning the difference, I now default to using &lt;link&gt;. I’ll show you why that’s usually the better choice.</p><h3>How Does &lt;link&gt; Work?</h3><p>The &lt;link&gt; tag is used in HTML, typically inside the &lt;head&gt;. It tells the browser to load an external resource like a CSS file right away.</p><pre>&lt;head&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;<br>&lt;/head&gt;</pre><p>Because the browser parses the HTML from top to bottom, it finds the &lt;link&gt; early and starts loading the CSS in parallel with the rest of the HTML. This helps the page load faster and look styled sooner.</p><p>That’s why &lt;link&gt; is the default recommendation for loading CSS and other resources like fonts.</p><h3>How Does @import Work?</h3><p>@import is used inside a CSS file to include another CSS file like this:</p><pre>@import url(https://medium.com/&quot;theme.css&quot;);</pre><p>At first glance, it seems clean and modular. But there’s a problem…</p><p>Unlike &lt;link&gt;, the browser won’t fetch the imported CSS until after the original CSS is loaded and parsed. This causes a delay in rendering styles, especially noticeable on slower networks.</p><p>Yep, this can cause a “Flash of Unstyled Content” effect. The appearance of the website was plain before the style appeared.</p><p>Let’s take an example using Google Fonts.</p><p>Using &lt;link&gt;:</p><pre>&lt;link href=&quot;https://fonts.googleapis.com/css2?family=Inter&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt;</pre><p>Using @import:</p><pre>@import url(https://medium.com/&quot;https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans&amp;display=swap&quot;);</pre><p>Both will load the font, but for performance reasons, the @import version is slower and may delay text styling.</p><h3>When can we still use @import?</h3><p>Sometimes using @import is okay, especially when:</p><ul><li>Working with CSS preprocessors like Sass or Less</li><li>Structuring modular stylesheets for components</li><li>Adding non-critical styles (like print styles)</li></ul><p>But even then, use it sparingly. Your users deserve fast, styled content as soon as possible.</p><h3>Can we mix both?</h3><p>Technically, yes. But don’t mix them without a good reason.</p><p>For example, don’t put a &lt;link&gt; in your HTML and then have that file use @import to load another crucial stylesheet. That just slows things down for no benefit.</p><h3>Conclusion</h3><ul><li>✅ Use &lt;link&gt; in your HTML for loading stylesheets and fonts</li><li>❌ Avoid using @import for critical CSS</li><li>🧵 @import is fine for modular code inside preprocessors</li><li>🚀 &lt;link&gt; gives better performance and faster styling</li></ul><p>Small decisions like this may seem trivial, but they add up, especially when it comes to performance and user experience. So the next time you’re including a stylesheet, go with &lt;link&gt;. Your website and your users will thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=163c13ad2b79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why REST API Held Me Back — And How tRPC Made Fullstack Dev Easier]]></title>
            <link>https://medium.com/@agusetyawan/why-rest-api-held-me-back-and-how-trpc-made-fullstack-dev-easier-fad41d20d82c?source=rss-88e8449b0df7------2</link>
            <guid isPermaLink="false">https://medium.com/p/fad41d20d82c</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[backend-developer]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[fullstack-development]]></category>
            <dc:creator><![CDATA[Agus Setyawan]]></dc:creator>
            <pubDate>Mon, 30 Jun 2025 13:52:11 GMT</pubDate>
            <atom:updated>2025-07-31T13:11:52.363Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why REST API Held Me Back and How tRPC Made Fullstack Dev Easier</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1hKBvPDh_j8YiaFv" /><figcaption>Photo by <a href="https://unsplash.com/@hudsoncrafted?utm_source=medium&amp;utm_medium=referral">Debby Hudson</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Every tech decision in a project is a huge investment of precious time and energy. For ages, I’ve pretty much exclusively relied on REST APIs for communication between my frontend and backend. But I decided it was time to step outside my comfort zone and try something new: <strong>tRPC</strong>. This is the story of my transition, and why tRPC quickly became a game-changer for my fullstack dev workflow. In fact, this very project is already live and you can check it out here: <a href="https://kantongpos.vercel.app/">https://kantongpos.vercel.app</a>.</p><p>A sweet combo of Next.js, TypeScript, TailwindCSS, tRPC, Prisma, and Supabase — promises an integrated, type-safe development experience. We’ll dive into why tRPC is such a compelling choice, especially for fellow fullstack devs used to the REST API grind, and how it changed the way.</p><h3>Shifting Gears: From REST to RPC</h3><p>Before we jump into tRPC itself, let’s quickly re-align our understanding of how REST API and RPC fundamentally differ.</p><h4>REST API: Your Familiar Resource Library</h4><p>For most of us, REST (Representational State Transfer) is the go-to architectural style for building APIs. REST API is an Application Programming Interface (API) designed to follow these REST principles. My mental model for REST APIs is best explained through an analogy: I see them as a big library. Every “book” or “document” in this library is a resource with its unique address (URL). As a library visitor (client), you perform standard actions on these books using “requests” (HTTP methods):</p><ul><li><strong>GET:</strong> You grab a book or a list of books.</li><li><strong>POST:</strong> You add a new book to the collection.</li><li><strong>PUT/PATCH:</strong> You update the details of an existing book.</li><li><strong>DELETE:</strong> You remove a book.</li></ul><p>The strengths of a REST API are its simplicity, its stateless nature (each request stands on its own), and the universal HTTP standard. But as a single fighter dev, I often found myself wrestling with repetitive boilerplate code for type-safety (think validation schemas, interface definitions on both sides) and the common headaches of over-fetching — getting too much data or under-fetching — not getting enough data, which always meant extra optimization work.</p><h4>RPC: Calling Functions, Remotely</h4><p>On the flip side, we have RPC (Remote Procedure Call), which is more of a communication paradigm focused on actions or functions. My mental model for RPC is like you’re directly calling a function or procedure that runs on another computer (the server) as if it were right there on your machine. You pass “arguments” to this function, and it returns a “result.”</p><p>In a REST API scenario, you might do PUT /products/123 to update a product. In RPC, you might call updateProduct(id: 123, data: { name: &#39;New Name&#39; }).</p><h3>Why tRPC?</h3><p>tRPC is an implementation of the RPC paradigm built right on top of TypeScript. And this is what makes it an absolute game-changer, especially for fullstack developers who live and breathe type-safety.</p><p>tRPC’s biggest superpower is its end-to-end type-safety.</p><p>tRPC magically infers the types directly from my backend functions and makes them available on the frontend. This gives me:</p><ul><li><strong>Spot-on auto-completion:</strong> when I’m calling API from the frontend.</li><li><strong>Compile-time error detection:</strong> (not runtime!) if I provide the wrong input or expect the wrong output.</li><li><strong>Safer refactoring:</strong> If I change a function’s signature on the backend, TypeScript immediately screams at me wherever I need to update its calls on the frontend.</li></ul><h3>Why tRPC is a Game-Changer Beyond REST API</h3><p>As fullstack developers, we’re constantly juggling two distinct worlds: the frontend and the backend. In the traditional REST API approach, this often feels like speaking two different languages, even if both are using TypeScript.</p><h4>🎃 The REST API Fullstack Workflow</h4><p>When I built applications using REST API, my fullstack workflow often looked something like this:</p><ol><li><strong>Backend Design (Server-side):</strong> Define my API endpoints (e.g., /api/products, /api/users), and the HTTP methods (GET, POST, PUT, DELETE) for each. I&#39;d then define the data contracts – what data shape to expect for payload and what shape to return for responses.</li><li><strong>Frontend Integration (Client-side):</strong> Now, on the frontend, I’d write code to consume these APIs. This meant manually constructing URLs, picking the right HTTP method, and crafting the request body. Crucially, I’d also have to manually define TypeScript types for the incoming and outgoing data, making sure they matched what the backend was sending or expecting. If the backend API changed, I’d have to manually update my frontend types and potentially my API calls.</li><li><strong>The Contract Overhead:</strong> The biggest pain point for me as a solo fullstack developer was managing this contract between the two sides. It was like having to manually translate and verify every single message between two people who, despite speaking the same language (TypeScript), had separate rulebooks for conversation. This led to:</li></ol><ul><li><strong>Boilerplate:</strong> Tons of repetitive type definitions.</li><li><strong>Type Mismatches:</strong> Runtime errors because a backend change wasn’t perfectly reflected on the frontend types.</li><li><strong>Slow Feedback:</strong> Errors only appeared when running the application, not during coding.</li><li><strong>Refactoring Dread:</strong> Changing an API signature on the backend felt like defusing a bomb — one wrong move and the frontend would break in unpredictable ways.</li></ul><h4>👾 tRPC Unifying the Fullstack Experience</h4><p>This is where tRPC truly shines as a fullstack developer’s dream. It shifts the paradigm from resource-based API communication to type-safe function calls across the network.</p><p>With tRPC, the lines between frontend and backend seamlessly connect through shared TypeScript types.</p><p>My workflow transformed into this:</p><ol><li><strong>Backend Design (Server-side):</strong> I define my server-side procedures (think functions) in TypeScript, specifying their input and output types directly. I use <a href="https://zod.dev/">Zod</a> for robust runtime validation, but that definition now doubles as my API contract.</li><li><strong>Frontend Integration (Client-side):</strong> This is the magic part. Because the frontend and backend are in the same TypeScript environment, tRPC can infer the types of my backend procedures directly onto my frontend.</li></ol><ul><li>When I type api.product., I immediately get auto-completion for getAll, create, update, etc.</li><li>When I call api.product.create.useMutation(), TypeScript tells me exactly what arguments (name, price, stock) are expected, complete with their types. If I make a mistake, my IDE flags it instantly at compile-time, not at runtime.</li><li>If I refactor a procedure name or change its input/output types on the backend, TypeScript immediately shows me the errors on the frontend, allowing for safe and rapid refactoring.</li></ul><h3>The Fullstack Benefits of tRPC</h3><ul><li><strong>End-to-End Type Safety:</strong> This is the headline feature. It virtually eliminates an entire class of bugs related to data contract mismatches between frontend and backend.</li><li><strong>Zero Boilerplate:</strong> No more redundant type definitions, no auto-generated API clients, no separate schema files to maintain. The code you write on the backend <em>is</em> your API contract.</li><li><strong>Unparalleled Developer Experience (DX):</strong> Auto-completion, immediate type error feedback, and a seamless calling experience make coding incredibly fast and enjoyable. It feels like you’re simply calling a local function.</li><li><strong>Faster Iteration:</strong> With less boilerplate and immediate feedback, the cycle of “write code, test, fix bugs” becomes much, much quicker. You spend more time building features and less time debugging communication issues.</li><li><strong>Reduced Cognitive Load (Especially for Solo Devs):</strong> As a single developer, managing both sides can be overwhelming. tRPC significantly reduces that <em>mental overhead</em> by ensuring consistency and catching errors early, freeing up your brainpower for actual business logic.</li><li><strong>Optimized Payloads:</strong> Like GraphQL, tRPC allows you to define exactly what data you need for each procedure, helping avoid <em>over-fetching</em> or <em>under-fetching</em> that can sometimes plague REST APIs.</li></ul><p>In essence, tRPC doesn’t just make API calls easier. it creates type-safe development environment where the frontend and backend speaking the same language without needing an interpreter. For a fullstack developer, especially a “single fighter”, that’s nothing short of revolutionary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KMnfnvTO5hIrKGE_J-3YCg.png" /></figure><h4>Example — Backend side (src/server/api/routers/product.ts)</h4><pre>import { z } from &quot;zod&quot;; // For input validation<br>import { createTRPCRouter, publicProcedure, protectedProcedure } from &quot;../trpc&quot;;<br><br>export const productRouter = createTRPCRouter({<br>  // Query to get all products<br>  getProducts: publicProcedure.query(async ({ ctx }) =&gt; {<br>    // ctx.db is your Prisma instance<br>    const { db } = ctx;<br>    const products = await db.product.findMany();<br>    return products;<br>  }),<br><br>  // Mutation to create a new product (requires authentication)<br>  createProduct: protectedProcedure<br>    .input(<br>      z.object({<br>        name: z.string().min(3),<br>        price: z.number().positive(),<br>        stock: z.number().int().min(0),<br>      }),<br>    )<br>    .mutation(async ({ ctx, input }) =&gt; {<br>      // ctx.session.user.id is available in protectedProcedure<br>      const { db } = ctx;<br>      const newProduct = await db.product.create({<br>        data: {<br>          name: input.name,<br>          price: input.price,<br>          stock: input.stock,<br>        },<br>      });<br><br>      return newProduct;<br>    }),<br>});</pre><p>Here, publicProcedure is an endpoint anyone can access, while protectedProcedure requires a valid user session. Input validation is done with Zod, and tRPC magically uses these types for inference on the frontend.</p><h4>Example — Frontend side (src/pages/products.tsx)</h4><pre>import { api } from &quot;@/utils/api&quot;;<br>import { useState } from &quot;react&quot;;<br><br>function ProductList() {<br>  // Calling the getProducts query from the product router<br>  const { data: products, isLoading:isLoadingProducts, error } = api.product.getProducts.useQuery();<br><br>  if (isLoadingProducts) return &lt;div&gt;Loading products...&lt;/div&gt;;<br>  if (error) return &lt;div&gt;Error loading products: {error.message}&lt;/div&gt;;<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Product List&lt;/h1&gt;<br>      &lt;ul&gt;<br>        {products?.map((product) =&gt; (<br>          &lt;li key={product.id}&gt;<br>            {product.name} - ${product.price} ({product.stock} in stock)<br>          &lt;/li&gt;<br>        ))}<br>      &lt;/ul&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>function CreateProductForm() {<br>  const [name, setName] = useState(&quot;&quot;);<br>  const [price, setPrice] = useState(0);<br>  const [stock, setStock] = useState(0);<br><br>  // Calling the create mutation from the product router<br>  const createProductMutation = api.product.createProduct.useMutation({<br>    onSuccess: () =&gt; {<br>      // Invalidate cache on success to refetch product list<br>      api.product.getProducts.invalidate();<br>      setName(&quot;&quot;);<br>      setPrice(0);<br>      setStock(0);<br>      alert(&quot;Product added successfully!&quot;);<br>    },<br>    onError: (err) =&gt; {<br>      alert(`Failed to add product: ${err.message}`);<br>    },<br>  });<br><br>  const handleSubmit = (e: React.FormEvent) =&gt; {<br>    e.preventDefault();<br>    createProductMutation.mutate({ name, price, stock });<br>  };<br><br>  return (<br>    &lt;form onSubmit={handleSubmit}&gt;<br>      &lt;h2&gt;Add New Product&lt;/h2&gt;<br>      &lt;input<br>        type=&quot;text&quot;<br>        placeholder=&quot;Product Name&quot;<br>        value={name}<br>        onChange={(e) =&gt; setName(e.target.value)}<br>      /&gt;<br><br>      {/* Other inputs for price and stock */}<br>      &lt;button type=&quot;submit&quot; disabled={createProductMutation.isLoading}&gt;<br>        {createProductMutation.isLoading ? &quot;Adding...&quot; : &quot;Add Product&quot;}<br>      &lt;/button&gt;<br><br>      {createProductMutation.error &amp;&amp; (<br>        &lt;p style={{ color: &quot;red&quot; }}&gt;Error: {createProductMutation.error.message}&lt;/p&gt;<br>      )}<br>    &lt;/form&gt;<br>  );<br>}<br><br>export default function ProductsPage() {<br>  return (<br>    &lt;&gt;<br>      &lt;ProductList /&gt;<br>      &lt;hr /&gt;<br>      &lt;CreateProductForm /&gt;<br>    &lt;/&gt;<br>  );<br>}</pre><p>Notice how api.product.getProducts and api.product.createProduct are directly available on the frontend with perfect types. That&#39;s the real power of tRPC 🧙‍♂️</p><h3>Conclusion</h3><p>The efficiency gained from tRPC’s end-to-end type-safety has significantly accelerated my development process. I can focus on core app features instead of getting caught up in boilerplate or debugging errors that could have been avoided.</p><p>If you’re a single fighter fullstack developer<em> </em>looking to boost productivity, slash <em>bugs</em>, and build applications with incredible speed, I highly recommend exploring tRPC.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fad41d20d82c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>