<?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 Shyam Jith on Medium]]></title>
        <description><![CDATA[Stories by Shyam Jith on Medium]]></description>
        <link>https://medium.com/@1shyam2shyam?source=rss-9c3649b1c465------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*0BHxVyCyI1N6YRm0</url>
            <title>Stories by Shyam Jith on Medium</title>
            <link>https://medium.com/@1shyam2shyam?source=rss-9c3649b1c465------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 11:43:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@1shyam2shyam/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[I shipped a bug to my own homepage and only caught it by building a tool to find it]]></title>
            <link>https://javascript.plainenglish.io/i-shipped-a-bug-to-my-own-homepage-and-only-caught-it-by-building-a-tool-to-find-it-7f9d38c36f73?source=rss-9c3649b1c465------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f9d38c36f73</guid>
            <category><![CDATA[seo-tips]]></category>
            <category><![CDATA[developer-tools]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[technical-seo]]></category>
            <dc:creator><![CDATA[Shyam Jith]]></dc:creator>
            <pubDate>Sun, 06 Sep 2026 18:40:51 GMT</pubDate>
            <atom:updated>2026-09-06T18:40:51.954Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Why SEO tooling should work like a lockfile, not a scorecard.</em></p><p>My homepage had no social preview image. Every time someone shared the link, it rendered as a plain text card. I did not know.</p><p>The image existed. It was 1200x630, sitting in /public/og.jpg, and my root layout.tsx referenced it correctly:</p><pre>export const metadata: Metadata = {<br>  openGraph: {<br>    title: &quot;Shyamjith | Software Engineer&quot;,<br>    images: [{ url: &quot;/og.jpg&quot;, width: 1200, height: 630 }],<br>  },<br>}</pre><p>Then my home page defined its own openGraph block, because I wanted a different title on that one page.tsx:</p><pre><br>export const metadata: Metadata = {<br>  openGraph: {<br>    title: &#39;Shyamjith | Software Engineer · AI · Flutter · Full Stack&#39;,<br>    description: &#39;...&#39;,<br>    url: &#39;https://www.shyamjith.in/&#39;,<br>    type: &#39;website&#39;,<br>  },<br>}</pre><p>Next.js does not deep merge that object. It replaces it. My images array went with it.</p><p>Nothing was broken. The build passed. The page rendered. Lighthouse was happy. The only symptom was a slightly worse link preview, on the one page most likely to be shared, and there is no test in any normal workflow that catches it.</p><h3>Scorecards tell you the wrong thing</h3><p>Every SEO tool I have used answers the same question: how is this page doing right now? You get a score, a list of warnings, and a green tick when you fix them.</p><p>That is useful once. It is close to useless on the fiftieth deploy.</p><p>The failures that actually cost traffic are not “this page has no meta description.” They are:</p><ul><li>This deploy dropped the canonical tag from 400 archive pages, because a plugin update changed a template.</li><li>A layout refactor added noindex to a route group.</li><li>A CMS migration stripped Product schema from every product page.</li><li>Somebody added Disallow: / for GPTBot in robots.txt and nobody noticed for a month.</li></ul><p>These share a shape. Nothing errors. The build passes. The site looks fine. Traffic moves three weeks later and by then nobody can tell you when it started, because there is no record of what the site looked like before.</p><p>You do not need a score. You need a diff.</p><h3>A lockfile for your search surface</h3><p>That is what I built. It is called pagetrace.</p><p>You snapshot your site’s search visible surface into a lockfile and commit it, exactly like package-lock.json:</p><pre>npx pagetrace snapshot --dir ./out<br>git add pagetrace.lock.json</pre><p>Then every build gets diffed against it:</p><pre>npx pagetrace check --dir ./out</pre><p>The lockfile records what matters per page. Title, meta description, canonical, robots directives, Open Graph and Twitter tags, hreflang alternates, the h1 text, the heading outline, every JSON-LD entity with its property list, word count, images missing alt, and the length of the opening paragraph. Site wide it records robots.txt crawlability per AI user agent, declared sitemaps, and llms.txt with its section headings.</p><h3>The one design decision that makes it usable</h3><p>Here is the part I spent the most time on.</p><blockquote><em>Severity is about transition, not state.</em></blockquote><p>A reworded title is info. A removed canonical is error. Same field, completely different events, and any tool that reports current state cannot tell them apart.</p><p>This sounds like a small distinction. It is the difference between a check you can put in CI and one you turn off after a week. Content changes constantly. Titles get edited, descriptions get rewritten, paragraphs get moved. If your gate fires on all of that, you will start ignoring it by Thursday.</p><p>So the rule I hold the codebase to is this. If a new rule cannot distinguish “changed” from “removed”, it does not belong in the diff engine. It belongs in the separate audit mode, which reports absolute state and does not gate anything.</p><p>There are two other rules that fell out of real use.</p><h4>Counts are per issue, not per instance</h4><p>One template defect on 400 pages is one problem, not 400. An early version reported a real audit as 66 problems when it was 3. Now it rolls up by issue and labels the wide ones as template wide, so you triage the fix once.</p><h4>Cross page rules have to degrade safely on a partial crawl</h4><p>If you crawl with --limit 50, an absent page proves nothing. The hreflang reciprocity check only reports a failure against pages actually present in the snapshot. Any new cross page rule has to have the same property, or it manufactures findings out of incomplete data.</p><h3>It watches the AI surface too</h3><p>Search is not the only thing reading your pages now. So it also tracks:</p><ul><li>Whether /llms.txt disappeared, or quietly lost sections, or shrank by half.</li><li>Whether robots.txt started blocking GPTBot, ClaudeBot, PerplexityBot, Google-Extended and others.</li><li>Whether a page still opens with a paragraph an answer engine can quote.</li></ul><p>Blocking an AI crawler by accident is a regression like any other. It just has no dashboard yet.</p><h3>What it found on my own site</h3><p>I pointed it at my own portfolio, expecting a clean run. Twelve pages, all written by me, all reviewed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Rd89vb5ZLs6fw-zZGIVgA.png" /></figure><figure><img alt="output from pagetrace auditing shyamjith.in. It reports 5 issues across 12 pages: one error for three pages missing an h1, plus warnings for two pages sharing a meta description, a missing og:image on the homepage, and a page under 150 words. Each finding lists the affected routes and a fix." src="https://cdn-images-1.medium.com/max/1024/1*vSn_ebszVHRqBHSnRNnf0w.png" /></figure><p>None of these would fail a build. None of these show up in a test suite. All of them were costing me something small and continuous.</p><p>There was a fifth finding: one page under 150 words. That one is honest. It needs writing, not tooling, and it is still open.</p><h3>Wiring it into CI</h3><p>My site is server rendered and its headers() config rules out a static export, so there is no directory of HTML to point at. The workflow builds it, serves it, and crawls localhost:</p><pre>- run: npm ci &amp;&amp; npm run build<br>- run: npx next start &amp;<br>- uses: shyamexe/pagetrace@v1<br>  with:<br>    url: http://localhost:3000<br>    baseline-branch: main</pre><p>baseline-branch reads the lockfile out of a git ref instead of the working tree, so feature branches never carry one and you get no lockfile churn in pull requests. The action posts the findings as a PR comment and updates that same comment on every push.</p><p>Setting this up surfaced two more problems on my site, incidentally. My sitemap.ts hardcoded the production domain, which meant every preview deployment published a sitemap pointing at production. And public/robots.txt was shadowing src/app/robots.ts, so the route I had written had never once been served. Anything in public/ wins over a route of the same name.</p><h3>What it deliberately does not do</h3><p>No Lighthouse. No performance scoring. No keyword research. No rank tracking.</p><p>Those all exist elsewhere and they are better than anything I would build. Adding them would dilute the one thing this does that nothing else does, which is tell you what changed.</p><p>It also does not execute JavaScript. Fingerprints come from rendered HTML, so a client rendered app needs a pre rendered build or a deployed URL. That is a real limitation and it is written in the README rather than hidden.</p><p>The whole thing is pure functions over plain objects. Three runtime dependencies, all small and boring. MIT licensed, no telemetry, published with npm provenance.</p><h3>Try it</h3><pre>npx pagetrace audit --url https://your-site.com</pre><p>That needs no lockfile and no config. It crawls your sitemap, runs every rule, and rolls the findings up by issue with an explanation and a fix for each one. If your site is on WordPress or Next.js it will detect that and give you platform specific instructions instead of generic advice.</p><p>I would genuinely like to know what it finds on sites I did not build. Two real sites so far have produced zero false errors, which is the bar I am trying to hold, but two is not many.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f9d38c36f73" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/i-shipped-a-bug-to-my-own-homepage-and-only-caught-it-by-building-a-tool-to-find-it-7f9d38c36f73">I shipped a bug to my own homepage and only caught it by building a tool to find it</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Day I Finally Understood Git Commit Messages (And Why feat, fix, and chore Matter)]]></title>
            <link>https://medium.com/@1shyam2shyam/the-day-i-finally-understood-git-commit-messages-and-why-feat-fix-and-chore-matter-a5892d831913?source=rss-9c3649b1c465------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5892d831913</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[personal-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Shyam Jith]]></dc:creator>
            <pubDate>Thu, 25 Dec 2025 14:59:15 GMT</pubDate>
            <atom:updated>2025-12-25T14:59:15.144Z</atom:updated>
            <content:encoded><![CDATA[<p>For a long time, my Git commit messages looked like this:</p><pre>final fix<br>updated code<br>works now</pre><p>They got the job done… but that’s about it.</p><p>Then one day, while scrolling through a well-maintained open-source repository, I noticed something different. Every commit felt intentional. Clean. Predictable.</p><p>That’s when I stumbled upon <strong>Conventional Commits</strong> and honestly, it changed how I treat my code history forever.</p><h3>What Are Conventional Commits (In Simple Terms)?</h3><p>Conventional Commits are just a <strong>structured way to write commit messages</strong> so that both humans and tools can understand them easily.</p><p>The format is simple:</p><pre>type(scope): short description</pre><p>Example:</p><pre>feat(auth): add OTP login flow</pre><p>At first glance, it may seem strict. But once you understand the <strong>why</strong>, it becomes second nature.</p><h3>The Real Power Is in the type</h3><p>That first word — feat, fix, chore, etc. — tells a story about <strong>what kind of change you made</strong>.</p><p>Let’s walk through the most commonly used ones, the way I learned them.</p><h3>feat — When You Build Something New</h3><p>This is the most exciting one.</p><p>I use <strong>feat</strong> whenever I add something users can actually see or use.</p><p><strong>Examples:</strong></p><ul><li>A new screen</li><li>A new flow</li><li>A new public API</li><li>A new capability</li></ul><pre>feat(profile): add edit profile screen<br>feat(cart): support multiple currencies</pre><p>Whenever I see feat in history, I know:</p><blockquote><em>“Ah, something new was introduced here.”</em></blockquote><h3>fix — When Something Was Broken</h3><p>No project escapes bugs.<br> <strong>fix</strong> is for correcting something that wasn’t working as intended.</p><pre>fix(login): prevent crash on invalid OTP<br>fix(wallet): correct balance calculation</pre><p>Seeing a fix commit tells future-me:</p><blockquote><em>“This was a real issue. Don’t casually remove this.”</em></blockquote><h3>chore — The Silent Work No One Notices</h3><p>This one took me the longest to appreciate.</p><p><strong>chore</strong> is for work that <strong>keeps the project healthy</strong>, but doesn’t change behavior.</p><pre>chore: update flutter sdk to 3.22<br>chore: remove unused assets</pre><p>No new features.<br>No bug fixes.<br>Just maintenance.</p><p>And that’s important.</p><h3>refactor — Same Behavior, Better Code</h3><p>Sometimes the code works… but it doesn’t feel right.</p><p>That’s where <strong>refactor</strong> comes in.</p><pre>refactor(api): simplify error handling<br>refactor(core): clean up state management logic</pre><p>Nothing changes for the user — but the codebase becomes easier to work with.</p><h3>perf — Making Things Faster or Lighter</h3><p>If a change improves performance without altering behavior, it deserves its own category.</p><pre>perf(list): reduce unnecessary rebuilds<br>perf(network): cache API responses</pre><p>These commits are gold when optimising later.</p><h3>docs — Documentation Is Code Too</h3><p>README updates, usage examples, comments — they all matter.</p><pre>docs(readme): add installation steps<br>docs(api): document public methods</pre><p>Good documentation saves more time than clever code.</p><h3>test — Confidence in Code</h3><p>Tests don’t change features, but they change confidence.</p><pre>test(auth): add unit tests for login bloc<br>test(widget): add golden tests</pre><p>When I see these commits, I know stability improved.</p><h3>style — Making Code Look Better</h3><p>Formatting changes, lint fixes, spacing — no logic touched.</p><pre>style: format code with dartfmt<br>style: fix lint warnings</pre><p>Simple, clean, intentional.</p><h3>build — Build &amp; Tooling Changes</h3><p>Anything related to build systems or tooling belongs here.</p><pre>build(android): update minSdkVersion<br>build: update pubspec configuration</pre><h3>ci — Automation &amp; Pipelines</h3><p>CI/CD work deserves its own clarity.</p><pre>ci: add commitlint to pipeline<br>ci: update GitHub actions workflow</pre><h3>deps — Dependency Updates</h3><p>Instead of hiding dependency changes inside other commits, I keep them explicit.</p><pre>deps: bump dio to v5.4.0<br>deps: update flutter_lints</pre><h3>revert — Undoing a Mistake (It Happens)</h3><pre>revert: revert &quot;feat(auth): add OTP login&quot;</pre><p>Clear, honest, traceable.</p><h3>A Quick Summary Table</h3><figure><img alt="Conventional Commits are just a structured way to write commit messages so that both humans and tools can understand them easily." src="https://cdn-images-1.medium.com/max/1024/1*ZoiX1vPB3dKGq5nF-T9byg.png" /></figure><h3>Why This Actually Matters</h3><p>Once I started using Conventional Commits consistently, a few things happened:</p><ul><li>My commit history became readable</li><li>Code reviews became faster</li><li>Changelogs practically wrote themselves</li><li>My open-source projects looked more professional</li><li>Future-me thanked past-me</li></ul><p>Commit messages stopped being noise — they became <strong>project documentation</strong>.</p><h3>Final Thought</h3><p>Your code tells <em>how</em> something works.<br> Your commits tell <em>why</em> it changed.</p><p>Using clear commit types like feat, fix, and chore isn’t about rules — it’s about respect:</p><ul><li>For your teammates</li><li>For contributors</li><li>For your future self</li></ul><p>If you take away just one thing:<br> <strong>Be kind to your commit history.</strong></p><p>Happy committing 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5892d831913" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing UniversalBreakpoints — A Unified Responsive & Adaptive Layout Toolkit for Flutter…]]></title>
            <link>https://medium.com/@1shyam2shyam/introducing-universalbreakpoints-a-unified-responsive-adaptive-layout-toolkit-for-flutter-9f6f05dade1c?source=rss-9c3649b1c465------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f6f05dade1c</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter-package]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Shyam Jith]]></dc:creator>
            <pubDate>Sat, 29 Nov 2025 02:08:55 GMT</pubDate>
            <atom:updated>2025-11-29T02:10:44.941Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introducing UniversalBreakpoints - A Unified Responsive &amp; Adaptive Layout Toolkit for Flutter (Mobile, Web &amp; Desktop)</h3><p>Building truly responsive Flutter apps is harder than it looks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aLKpA8FNr1QCTTW6H05ecg.png" /><figcaption>UniversalBreakpoints</figcaption></figure><p>When your app needs to run on <strong>Android, iOS, Web, Windows, macOS, Linux</strong>, and potentially even foldables or large displays, you quickly face challenges like:</p><ul><li>Managing multiple screen sizes</li><li>Scaling typography &amp; spacing</li><li>Switching between layouts (mobile/tablet/desktop)</li><li>Avoiding messy, repeated MediaQuery checks</li><li>Maintaining clean code across the whole project</li></ul><p>Flutter gives us the tools (MediaQuery, LayoutBuilder, SafeArea, etc.), but writing responsive logic repeatedly becomes <strong>boilerplate-heavy</strong> and hard to maintain.</p><p>That’s why I built <strong>UniversalBreakpoints</strong> — a unified, clean, cross-platform solution to handle breakpoints and scaling in Flutter apps.</p><p>👉 <strong>GitHub</strong>: <a href="https://github.com/shyamexe/universal_breakpoints">https://github.com/shyamexe/universal_breakpoints</a><br> 👉 <strong>Pub.dev</strong>: <a href="https://pub.dev/packages/universal_breakpoints?utm_source=chatgpt.com">https://pub.dev/packages/universal_breakpoints</a></p><h3>What is UniversalBreakpoints?</h3><h4>✔ Platform-agnostic breakpoints</h4><p>Works on <strong>all</strong> Flutter-supported platforms:<br> <strong>Android, iOS, Web, Windows, macOS, Linux.</strong></p><h4>✔ Smart breakpoint system</h4><p>Predefined (and customizable) breakpoints from <strong>small phones → tablets → desktops → 4K displays</strong>.</p><h4>✔ Super-easy context extensions</h4><p>No more manual width checks.</p><pre>context.isMobile<br>context.isTablet<br>context.isDesktop<br>context.screenType</pre><h4>✔ Responsive value helpers</h4><p>Use different values for mobile/tablet/desktop:</p><pre>context.responsiveValue(<br>  mobile: 12,<br>  tablet: 16,<br>  desktop: 20,<br>)</pre><h4>✔ Scaling utilities</h4><p>Scale font sizes &amp; dimensions smoothly:</p><pre>16.sF   // scaled font<br>100.sW  // scaled width<br>40.sH   // scaled height</pre><h4>✔ Zero boilerplate after initialization</h4><p>Just initialise once, and use it anywhere.</p><h3>Why This Package Exists</h3><p>During multi-platform projects, I repeatedly ran into issues:</p><ul><li>Breakpoint logic scattered across 100+ widgets</li><li>Typography looks perfect on mobile but tiny on desktop</li><li>Tablet layouts need more control</li><li>Web dashboard layouts need multiple panes</li><li>Existing packages were overkill, web-only, or outdated</li></ul><p>So I built something that is:</p><ul><li><strong>Simple</strong> (one-time init, clean API)</li><li><strong>Consistent</strong> (same logic across all platforms)</li><li><strong>Flexible</strong> (customizable breakpoints and utilities)</li><li><strong>Production-friendly</strong> (no magic, no heavy dependencies)</li></ul><h3>Breakpoint System Overview</h3><p>UniversalBreakpoints uses a structured hierarchy inspired by popular design systems (Bootstrap, Tailwind, Material 3) and real-world device widths.</p><p>DefaultBreakpoints:</p><pre>| Category              | Width         |<br>| --------------------- | ------------- |<br>| Small Phone           | `&lt; 360px`     |<br>| Phone                 | `360–480px`   |<br>| Large Phone / Phablet | `480–600px`   |<br>| Small Tablet          | `600–720px`   |<br>| Tablet                | `720–960px`   |<br>| Large Tablet          | `960–1200px`  |<br>| Desktop               | `1200–1600px` |<br>| Large Desktop / 4K    | `1600px+`     |</pre><p>These values are based on modern device ranges and web design standards.</p><p>You can override them if your project needs custom thresholds.</p><h3>Installation</h3><p>Add to pubspec.yaml:</p><pre>dependencies:<br>  universal_breakpoints: ^1.0.0</pre><h3>Initialization</h3><p>Place in your app root:</p><pre>void main() {<br>  runApp(const MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    UniversalBreakpoints().init(context);<br><br>    return MaterialApp(<br>      home: const HomePage(),<br>    );<br>  }<br>}</pre><h3>Example: Responsive Layout Switching</h3><pre>Widget build(BuildContext context) {<br>  if (context.isMobile) {<br>    return MobileView();<br>  } else if (context.isTablet) {<br>    return TabletView();<br>  } else {<br>    return DesktopView();<br>  }<br>}</pre><h3>Scaled Typography (No More Magic Numbers)</h3><pre>Text(<br>  &#39;Hello&#39;,<br>  style: TextStyle(fontSize: 16.sF),<br>);</pre><p>Fonts scale according to screen context.</p><h3>Responsive Spacing &amp; Dimensions</h3><pre>Container(<br>  width: 200.sW,<br>  height: 40.sH,<br>  padding: EdgeInsets.all(8.sW),<br>  child: ...<br>)</pre><p>Everything adapts automatically.</p><h3>Responsive Values</h3><p>Switch values dynamically:</p><pre>final padding = context.responsiveValue(<br>  mobile: 8,<br>  tablet: 12,<br>  desktop: 16,<br>);</pre><h3>Why UniversalBreakpoints Is Different</h3><p>Compared to manual MediaQuery logic</p><pre>| Manual            | UniversalBreakpoints     |<br>| ----------------- | ------------------------ |<br>| Repeated code     | One-time logic           |<br>| Hard to maintain  | Clean API                |<br>| No scaling        | Built-in scaling         |<br>| Prone to mistakes | Standardized breakpoints |</pre><h3>Compared to existing packages</h3><p><strong>Most packages are:</strong></p><ul><li>web-focused</li><li>poorly maintained</li><li>not cross-platform</li><li>offer only breakpoints (no scaling)</li><li>add heavy frameworks or layouts</li></ul><p><strong>UniversalBreakpoints focuses on:</strong></p><p>✔ lightweight<br> ✔ cross-platform<br> ✔ easy to adopt<br> ✔ customizable<br> ✔ pure Flutter</p><h3>Real-World Use Cases</h3><h4>✔ E-commerce apps (mobile + web)</h4><p>Switch from grid → list, side filters on desktop, compact view on phone.</p><h4>✔ Admin dashboards</h4><p>Multi-column layout on desktop, single-column on tablet/mobile.</p><h4>✔ News / Blog / Content apps</h4><p>Typography scales beautifully on large screens.</p><h4>✔ Tablet-first apps (POS, kiosk)</h4><p>Breakpoints give finer control (600–960px).</p><h4>✔ Desktop apps</h4><p>Auto switch to sidebar navigation.</p><h3>Best Practices (built from research)</h3><ul><li>Use <strong>breakpoints</strong> for structure (layout switching)</li><li>Use <strong>scaling utilities</strong> for typography/spacing</li><li>Don’t over-scale fonts on very large screens</li><li>Test on real device sizes</li><li>Prefer <strong>content-driven breakpoints</strong> when needed</li><li>Combine with Flutter adaptive patterns (NavigationRail, Drawer, SplitView)</li></ul><h3>Future Plans</h3><ul><li>Customizable scaling profiles</li><li>DeviceType-based adaptive components</li><li>Responsive Grid builder</li><li>Built-in desktop/tablet layout templates</li><li>Performance optimizations</li></ul><h3>🤝 Contribute</h3><p>Open for PRs, suggestions &amp; issues:</p><p>👉 GitHub: <a href="https://github.com/shyamexe/universal_breakpoints?utm_source=chatgpt.com">https://github.com/shyamexe/universal_breakpoints</a></p><p>If you find it useful, please ⭐ the repo — it helps a lot!</p><h3>🏁 Final Thoughts</h3><p>Flutter’s power lies in targeting <strong>every platform</strong> with one codebase — but truly adaptive UI still requires effort.</p><p>UniversalBreakpoints helps you:</p><ul><li>write cleaner responsive code</li><li>scale UI naturally</li><li>support multiple platforms elegantly</li><li>avoid boilerplate</li><li>future-proof your layout logic</li></ul><p>If you’re building modern Flutter apps, especially multi-device or multi-platform, I believe this package can significantly improve your workflow.</p><p>Try it out, share feedback, and let’s make Flutter responsive design easier for everyone! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f6f05dade1c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Environment Handling in Flutter - The Right Way]]></title>
            <link>https://medium.com/@1shyam2shyam/environment-handling-in-flutter-the-right-way-e8a4fd93cf7c?source=rss-9c3649b1c465------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8a4fd93cf7c</guid>
            <dc:creator><![CDATA[Shyam Jith]]></dc:creator>
            <pubDate>Thu, 16 Oct 2025 07:08:10 GMT</pubDate>
            <atom:updated>2025-10-16T07:08:10.160Z</atom:updated>
            <content:encoded><![CDATA[<p>When building Flutter apps, you’ll often need to handle <strong>different environments:</strong></p><ul><li>Development (local APIs, debug flags)</li><li>Staging (QA/testing servers)</li><li>Production (live API, minimal logs)</li></ul><p>Most JavaScript developers are used to. env files, but Flutter is different. Since Dart is compiled ahead-of-time (AOT), it can’t just load . env files at runtime. That’s where - - dart -define comes in.</p><h3>Why Not.env in Flutter?</h3><p>In React or Node.js apps,. env works fine because the runtime can read environment files dynamically.</p><p>But in Flutter:</p><ul><li>The code is compiled into native binaries, so runtime. env parsing doesn’t work the same way.</li><li>.env files (via flutter_dotenv) get bundled into the app as plain assets - which means anyone can unzip your APK and read them.</li><li>Cl/CD pipelines are harder to manage with. env files because you need multiple files for each environment.</li></ul><p>The Flutter team recommends using --dart-define for this reason.</p><h3>How --dart-define Works</h3><p>You inject values during build/run:</p><pre>flutter run --dart-define=BASE_URL=https://api.dev.example.com</pre><p>For release:</p><pre>flutter build apk --release --dart-define=BASE_URL=https://api.prod.example.com</pre><h4>Reading values in Dart</h4><pre>const String baseUrl = String.fromEnvironment(<br>  &#39;BASE_URL&#39;,<br>  defaultValue: &#39;https://api.default.com&#39;,<br>);<br><br>const bool enableLogs = bool.fromEnvironment(&#39;ENABLE_LOGS&#39;, defaultValue: false);<br>const int timeout = int.fromEnvironment(&#39;TIMEOUT&#39;, defaultValue: 30);</pre><p>These are compile-time constants injected into your build.</p><h3>Multiple Environments (Flavors + Dart Define)</h3><p>You can combine app flavors with --dart -de fine:</p><pre>flutter run --flavor dev --dart-define=BASE_URL=https://api.dev.example.com<br>flutter run --flavor staging --dart-define=BASE_URL=https://api.staging.example.com<br>flutter run --flavor prod --dart-define=BASE_URL=https://api.prod.example.com</pre><p>Then your Dart code stays clean:</p><pre>class EnvConfig {<br>  static const String baseUrl = String.fromEnvironment(&#39;BASE_URL&#39;);<br>}</pre><h3>Real-World Use Cases</h3><ul><li><strong>API URLs</strong> → Dev, Staging, Prod servers</li><li><strong>Feature flags</strong> → Enable/disable experimental features without code changes</li><li><strong>App branding</strong> → Different names/logos/colors per environment</li><li><strong>Logging</strong> → Turn on/off debug logs based on environment</li><li><strong>Secrets</strong> → API tokens (though critical secrets should always stay on the backend)</li></ul><h3>--dart-define-from-file (Flutter 3.7+)</h3><p>Instead of passing multiple flags, you can load values from a file.</p><p><strong>Example: env.dev.json</strong></p><pre>{<br>  &quot;BASE_URL&quot;: &quot;https://api.dev.example.com&quot;,<br>  &quot;APP_NAME&quot;: &quot;MyApp Dev&quot;,<br>  &quot;ENABLE_LOGS&quot;: &quot;true&quot;<br>}</pre><p>Run with:</p><pre>flutter run --dart-define-from-file=env.dev.json</pre><p>Cleaner and especially useful in CI/CD pipelines.</p><h3>CI/CD Example (GitHub Actions)</h3><pre>jobs:<br>  build:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - uses: actions/checkout@v3<br>      - uses: subosito/flutter-action@v2<br>        with:<br>          flutter-version: &#39;3.22.0&#39;<br>      - name: Build release APK<br>        run: flutter build apk --release \<br>          --dart-define=BASE_URL=${{ secrets.BASE_URL }} \<br>          --dart-define=APP_NAME=MyFlutterApp \<br>          --dart-define=ENABLE_LOGS=false</pre><p>Your secrets live in the pipeline, not inside your repo.</p><h3>.env VS --dart-define</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AiJvPXWFQIHcJaCce4V8Lg.png" /><figcaption>env approach vs dart difine approach</figcaption></figure><h3>Best Practices</h3><ol><li>Use --dart-de fine for production - safer and Cl/CD friendly.</li><li>Use. env only for local dev convenience (optional).</li><li>Never hardcode secrets in Dart code.</li><li>Prefer --dart-define- from-file for large configs.</li><li>Always set a defaultValue in case no value is passed.</li></ol><h3>Final Thoughts</h3><p>Flutter’s - -dart - define is the cleanest, most secure, and scalable way to handle environments. While. env can be handy for local testing, it’s not production-safe.</p><p>If your app still has hardcoded API URLs, migrate them today. Your future self - and your Cl/CD pipeline - will thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8a4fd93cf7c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Comprehensive Guide to Flutter Packaging and Plugins]]></title>
            <link>https://medium.com/@1shyam2shyam/a-comprehensive-guide-to-flutter-packaging-and-plugins-c0d1eaf389fc?source=rss-9c3649b1c465------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0d1eaf389fc</guid>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[create-package]]></category>
            <category><![CDATA[flutter-package]]></category>
            <category><![CDATA[pubdev]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Shyam Jith]]></dc:creator>
            <pubDate>Sat, 12 Oct 2024 18:16:41 GMT</pubDate>
            <atom:updated>2024-10-12T18:16:41.302Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="flutter package" src="https://cdn-images-1.medium.com/max/686/1*CFYD3ENelz-f1HAIzw2AoQ.jpeg" /></figure><p>Flutter, an open-source framework created by Google, has grown rapidly in popularity due to its ability to build natively compiled applications for mobile, web, and desktop from a single codebase. One of the standout features of Flutter is the ease with which developers can extend its capabilities by using packages and plugins. These tools allow developers to share code, tap into native device functionality, and create modular components to improve code reuse and maintainability.</p><p>In this blog, we will dive deep into Flutter packaging and plugin development, exploring what they are, how to create them, and why they are essential for building scalable and efficient applications.</p><h3>What Are Flutter Packages and Plugins?</h3><ul><li><strong>Packages: </strong>A Flutter package is a set of Dart libraries that provide functionalities which can be reused in various applications. These packages contain only Dart code and are primarily used to share code across different Flutter apps. Flutter’s ecosystem has thousands of packages, such as HTTP clients, JSON parsers, state management libraries, and much more.</li><li><strong>Plugins: </strong>Flutter plugins, on the other hand, are a special type of package that also include platform-specific code, typically in Swift (for iOS) or Kotlin (for Android), in addition to Dart. Plugins are used to access platform-specific APIs or native device features like the camera, GPS, or Bluetooth.</li></ul><p>In simple terms,<strong> all plugins are packages</strong>, but not all packages are plugins.</p><h3>Why Use Packages and Plugins?</h3><ul><li><strong>Code Reusability: </strong>Packages and plugins allow you to reuse code across different projects. Instead of writing common functionalities multiple times, you can create or use a package to save time and effort.</li><li><strong>Modularity: </strong>They enable you to break down complex applications into smaller, manageable, and reusable components.</li><li><strong>Community Support: </strong>The Flutter ecosystem has a wide array of community-created packages and plugins, allowing you to integrate a variety of features easily.</li></ul><h3>Getting Started with Flutter Packages</h3><p>Let’s start by exploring how to use existing packages in your Flutter application.</p><ol><li><strong>Adding a Package to Your Project </strong>You can find packages on <a href="https://pub.dev/">pub.dev</a>, which is Flutter’s package repository. Once you find a package you want to use, follow these steps:</li></ol><ul><li>Open your pubspec.yaml file.</li><li>Add the package under the dependencies section:</li></ul><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br>  http: ^0.14.0  # Add the package with its version</pre><ul><li>Run the following command to install the package:</li></ul><pre>flutter pub get</pre><p><strong>2. Importing and Using the Package </strong>After adding the package, import it into your Dart file:</p><pre>import &#39;package:http/http.dart&#39; as http;</pre><p>Then, you can use it as needed:</p><pre>var response = await http.get(Uri.parse(&#39;https://api.example.com/data&#39;));</pre><h3>Creating a Flutter Package</h3><p>To create a reusable package, follow these steps:</p><p><strong>Step 1: Set Up the Package</strong></p><ul><li>Open a terminal and run:</li></ul><pre>flutter create --template=package my_flutter_package</pre><ul><li>Navigate into your package directory:</li></ul><pre>cd my_flutter_package</pre><p><strong>Step 2: Define the Package </strong>Open the pubspec.yaml file and provide information about your package, such as the name, description, and dependencies.</p><p><strong>Step 3: Write Dart Code </strong>Inside the lib folder, create a .dart file that defines the functionality of your package. For example:</p><pre>library my_flutter_package;<br><br>class Calculator {<br>  int add(int a, int b) =&gt; a + b;<br>}</pre><p><strong>Step 4: Test Your Package </strong>Write tests to verify the functionality of your package:</p><pre>import &#39;package:test/test.dart&#39;;<br>import &#39;package:my_flutter_package/calculator.dart&#39;;<br><br>void main() {<br>  test(&#39;adds two numbers&#39;, () {<br>    expect(Calculator().add(2, 3), 5);<br>  });<br>}</pre><p><strong>Step 5: Publish Your Package</strong> Once your package is ready, you can publish it to <a href="https://pub.dev/">pub.dev</a>. Run the following command to validate your package:</p><pre>flutter pub publish --dry-run</pre><p>If everything is fine, publish the package using:</p><pre>flutter pub publish</pre><h3>Flutter Plugin Development</h3><p>Developing a plugin is slightly more complex since it involves writing platform-specific code. Here’s how you can create a simple plugin.</p><p><strong>Step 1: Create a Plugin </strong>Open a terminal and run:</p><pre>flutter create --template=plugin my_flutter_plugin</pre><p>This command will create a plugin structure with example, ios, android, and lib folders.</p><p><strong>Step 2: Write Platform-Specific Code </strong>In the lib folder, define the Dart interface for your plugin. For example:</p><pre>import &#39;dart:async&#39;;<br>import &#39;package:flutter/services.dart&#39;;<br><br>class MyFlutterPlugin {<br>  static const MethodChannel _channel = MethodChannel(&#39;my_flutter_plugin&#39;);<br><br>  static Future&lt;String?&gt; get platformVersion async {<br>    final String? version = await _channel.invokeMethod(&#39;getPlatformVersion&#39;);<br>    return version;<br>  }<br>}</pre><p>Now, you need to add platform-specific code in the android and ios folders to implement the getPlatformVersion method.</p><p><strong>Step 3: Implement Android Code</strong> Navigate to android/src/main/kotlin and open the generated Kotlin file. Implement the platform-specific code:</p><pre>class MyFlutterPlugin: FlutterPlugin, MethodCallHandler {<br>  override fun onMethodCall(call: MethodCall, result: Result) {<br>    if (call.method == &quot;getPlatformVersion&quot;) {<br>      result.success(&quot;Android ${android.os.Build.VERSION.RELEASE}&quot;)<br>    } else {<br>      result.notImplemented()<br>    }<br>  }<br>}</pre><p><strong>Step 4: Implement iOS Code</strong> Navigate to ios/Classes and open the Swift file. Implement the platform-specific code:</p><pre>public class SwiftMyFlutterPlugin: NSObject, FlutterPlugin {<br>  public static func register(with registrar: FlutterPluginRegistrar) {<br>    let channel = FlutterMethodChannel(name: &quot;my_flutter_plugin&quot;, binaryMessenger: registrar.messenger())<br>    let instance = SwiftMyFlutterPlugin()<br>    registrar.addMethodCallDelegate(instance, channel: channel)<br>  }<br><br>  public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {<br>    if call.method == &quot;getPlatformVersion&quot; {<br>      result(&quot;iOS &quot; + UIDevice.current.systemVersion)<br>    } else {<br>      result(FlutterMethodNotImplemented)<br>    }<br>  }<br>}</pre><p><strong>Step 5: Test Your Plugin </strong>Like packages, plugins come with an example app that you can use to test the functionality of your plugin. Run the example app and verify that it interacts correctly with platform-specific code.</p><p><strong>Step 6: Publish the Plugin</strong> Once your plugin is tested and ready, follow the same publishing steps as mentioned for packages to publish your plugin to <a href="https://pub.dev/">pub.dev</a>.</p><h3>Best Practices for Flutter Packaging and Plugin Development</h3><ul><li><strong>Follow Semantic Versioning:</strong> Always use <a href="https://semver.org/">semantic versioning</a> for your package/plugin to ensure compatibility.</li><li><strong>Provide Documentation: </strong>A well-documented package/plugin helps others understand how to use it. Make sure to include a detailed README file.</li><li><strong>Testing: </strong>Include comprehensive tests to ensure your package/plugin works correctly across various scenarios.</li><li><strong>Null Safety: </strong>Ensure your code is null-safe to comply with modern Flutter standards.</li><li><strong>Maintain and Update:</strong> Keep your packages/plugins up to date with the latest Flutter releases and community feedback.</li></ul><h3>Conclusion</h3><p>Flutter packaging and plugin development offer a great way to extend the framework’s capabilities and share reusable components with the Flutter community. Whether you are leveraging existing packages or creating your own, understanding the process can significantly improve your development efficiency. By following the best practices outlined in this blog, you can create high-quality, reusable packages and plugins that add value to your projects and the broader Flutter ecosystem.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0d1eaf389fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Flutter Animations: A Guide to Creating Stunning Motion in Your Apps]]></title>
            <link>https://medium.com/@1shyam2shyam/mastering-flutter-animations-a-guide-to-creating-stunning-motion-in-your-apps-0b7394cab953?source=rss-9c3649b1c465------2</link>
            <guid isPermaLink="false">https://medium.com/p/0b7394cab953</guid>
            <category><![CDATA[animation-courses]]></category>
            <category><![CDATA[animatedcontainer]]></category>
            <category><![CDATA[flutter-animation]]></category>
            <category><![CDATA[fluttter]]></category>
            <dc:creator><![CDATA[Shyam Jith]]></dc:creator>
            <pubDate>Thu, 03 Oct 2024 16:03:08 GMT</pubDate>
            <atom:updated>2024-10-03T16:03:08.207Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mzACT7PaKfJdj5g4ugNMig.png" /></figure><p>Animations can turn an ordinary Flutter app into an engaging and dynamic experience. Flutter provides powerful animation APIs that allow developers to create beautiful transitions, interactions, and effects with ease. Whether it’s simple transitions between pages or complex sequences of animation, Flutter has you covered.</p><p>In this blog, we will explore the fundamentals of animations in Flutter, walk through different animation techniques, and provide code examples to help you bring your app to life.</p><h3>Why Use Animations in Flutter?</h3><p>Animations are essential for enhancing the user experience. By using animations, you can:</p><ul><li>Guide users through your app with intuitive visual feedback.</li><li>Make UI interactions feel smooth and natural.</li><li>Highlight changes or draw attention to important elements.</li><li>Provide visual cues for better user comprehension.</li></ul><p>Flutter’s animation framework is rich and flexible, allowing you to create anything from simple fades to complex transitions.</p><h3>Types of Animations in Flutter</h3><p>There are several types of animations you can implement in Flutter:</p><ol><li>Implicit Animations<br>These are pre-built animations that automatically handle the animation details, making them easy to use for simple animations such as changing opacity, color, or position.</li><li>Explicit Animations<br>These animations give you more control and flexibility, but you have to manage the animation lifecycle manually, such as starting, stopping, and reversing the animation.</li></ol><h3>Implicit Animations: Simple and Effective</h3><p>Implicit animations are the easiest way to add motion to your app. Flutter offers several widgets for these animations, such as AnimatedOpacity, AnimatedContainer, AnimatedPositioned, and more.</p><p>Here’s an example of a basic AnimatedContainer:</p><pre>import &#39;package:flutter/material.dart&#39;;<br><br>class ImplicitAnimationExample extends StatefulWidget {<br>  @override<br>  _ImplicitAnimationExampleState createState() =&gt; _ImplicitAnimationExampleState();<br>}<br><br>class _ImplicitAnimationExampleState extends State&lt;ImplicitAnimationExample&gt; {<br>  bool isExpanded = false;<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(title: Text(&#39;Implicit Animation Example&#39;)),<br>      body: Center(<br>        child: GestureDetector(<br>          onTap: () {<br>            setState(() {<br>              isExpanded = !isExpanded;<br>            });<br>          },<br>          child: AnimatedContainer(<br>            duration: Duration(seconds: 1),<br>            curve: Curves.easeInOut,<br>            width: isExpanded ? 200.0 : 100.0,<br>            height: isExpanded ? 200.0 : 100.0,<br>            color: isExpanded ? Colors.blue : Colors.red,<br>            child: Center(child: Text(&#39;Tap me!&#39;)),<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>In this example, when the user taps the container, it smoothly transitions between two sizes and colors. The animation is defined using the duration and curve parameters, making it effortless to achieve smooth, responsive animations.</p><h3>Explicit Animations: Total Control Over Motion</h3><p>If you need more control over the animation’s lifecycle, such as starting, stopping, or reversing it, you’ll use explicit animations. In explicit animations, you’ll typically work with the AnimationController and Tween classes.</p><p>Here’s an example using AnimationController to create a bounce animation:</p><pre>import &#39;package:flutter/material.dart&#39;;<br><br>class BounceAnimationExample extends StatefulWidget {<br>  @override<br>  _BounceAnimationExampleState createState() =&gt; _BounceAnimationExampleState();<br>}<br><br>class _BounceAnimationExampleState extends State&lt;BounceAnimationExample&gt; with SingleTickerProviderStateMixin {<br>  late AnimationController _controller;<br>  late Animation&lt;double&gt; _animation;<br><br>  @override<br>  void initState() {<br>    super.initState();<br>    _controller = AnimationController(<br>      vsync: this,<br>      duration: Duration(seconds: 2),<br>    );<br>    _animation = CurvedAnimation(parent: _controller, curve: Curves.bounceOut)<br>      ..addListener(() {<br>        setState(() {});<br>      });<br>    _controller.repeat(reverse: true);<br>  }<br><br>  @override<br>  void dispose() {<br>    _controller.dispose();<br>    super.dispose();<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(title: Text(&#39;Bounce Animation Example&#39;)),<br>      body: Center(<br>        child: Transform.scale(<br>          scale: _animation.value,<br>          child: Container(<br>            width: 100.0,<br>            height: 100.0,<br>            color: Colors.blue,<br>            child: Center(child: Text(&#39;Bounce&#39;)),<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>This example demonstrates how to create a bounce animation using CurvedAnimation combined with the AnimationController. The repeat method keeps the animation looping in a reverse motion.</p><h3>Using Flutter’s Animation Widgets</h3><p>Flutter provides several widgets specifically designed for animation:</p><ol><li><strong>AnimatedBuilder<br></strong>This widget helps separate the animation logic from the widget tree, making it easier to manage animations without rebuilding unnecessary parts of the UI.</li><li><strong>Hero</strong><br>Hero animations are perfect for transitions between routes (pages). When moving from one screen to another, the Hero widget animates a shared element, such as an image or button.</li><li><strong>FadeTransition, ScaleTransition, SlideTransition, etc.</strong><br>These widgets make it easy to apply specific transitions like fading, scaling, or sliding to any widget.</li></ol><p>Here’s an example of a Hero animation:</p><pre>import &#39;package:flutter/material.dart&#39;;<br><br>class HeroFirstPage extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(title: Text(&#39;Hero Animation Example&#39;)),<br>      body: Center(<br>        child: GestureDetector(<br>          onTap: () {<br>            Navigator.push(<br>              context,<br>              MaterialPageRoute(builder: (context) =&gt; HeroSecondPage()),<br>            );<br>          },<br>          child: Hero(<br>            tag: &#39;hero-animation&#39;,<br>            child: Container(<br>              width: 100.0,<br>              height: 100.0,<br>              color: Colors.blue,<br>              child: Center(child: Text(&#39;Tap to view&#39;)),<br>            ),<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}<br><br>class HeroSecondPage extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(title: Text(&#39;Hero Second Page&#39;)),<br>      body: Center(<br>        child: Hero(<br>          tag: &#39;hero-animation&#39;,<br>          child: Container(<br>            width: 300.0,<br>            height: 300.0,<br>            color: Colors.blue,<br>            child: Center(child: Text(&#39;Hero Animation&#39;)),<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>This example demonstrates a Hero animation, where tapping on the small blue box smoothly transitions to a larger version on the next page.</p><h3>Best Practices for Animations in Flutter</h3><ol><li><strong>Keep Animations Smooth</strong><br>Make sure your animations are smooth and avoid unnecessary rebuilds. You can use AnimatedBuilder to optimize animations by reducing unnecessary re-rendering.</li><li><strong>Avoid Overuse</strong><br>While animations can improve the user experience, overusing them can slow down your app and overwhelm users. Use animations wisely and only where they add value.</li><li><strong>Control Animation Timing</strong><br>Experiment with different durations and easing curves (e.g., Curves.easeInOut, Curves.bounceIn) to make your animations feel natural.</li></ol><h3>Conclusion</h3><p>Flutter animations can elevate the user experience in your apps by adding dynamic interactions and guiding users intuitively. Whether you’re using implicit animations for simplicity or explicit animations for fine-grained control, Flutter provides all the tools you need to create smooth and visually stunning animations.</p><p>Start incorporating animations into your Flutter projects today and watch your app’s interactivity reach new heights! Happy animating!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0b7394cab953" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing MaterialPagination: A Customizable Flutter Pagination Widget]]></title>
            <link>https://medium.com/@1shyam2shyam/introducing-materialpagination-a-customizable-flutter-pagination-widget-9cf3d2003c6c?source=rss-9c3649b1c465------2</link>
            <guid isPermaLink="false">https://medium.com/p/9cf3d2003c6c</guid>
            <category><![CDATA[materials]]></category>
            <category><![CDATA[flutter-pagination]]></category>
            <category><![CDATA[pagination-in-flutter]]></category>
            <category><![CDATA[pagination]]></category>
            <category><![CDATA[material-pagination]]></category>
            <dc:creator><![CDATA[Shyam Jith]]></dc:creator>
            <pubDate>Thu, 03 Oct 2024 15:43:56 GMT</pubDate>
            <atom:updated>2024-10-03T15:43:56.810Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*rAEkZJB8IQLSw5TWscuReQ.png" /></figure><p>Are you building a Flutter application that needs to handle multiple pages of data with ease? Look no further than MaterialPagination, a customizable and flexible pagination widget designed for Flutter applications. Whether you’re working on an app with extensive data or a small blog with multiple posts, MaterialPagination simplifies the process of adding pagination controls with style and flexibility.</p><p>In this blog, we’ll dive into the features and customization options offered by this package, guiding you through how to integrate it into your Flutter projects.</p><h3>What is MaterialPagination?</h3><p>MaterialPagination is a Flutter package that provides an easy-to-use pagination widget. It includes numbered page buttons, next/previous arrows, and extensive customization options to fit the look and feel of your app. This package is designed to be lightweight, customizable, and adaptable to any theme.</p><h3>Features of MaterialPagination</h3><p>Here are some of the key features of this powerful pagination package:</p><ul><li><strong>Customisable Page Buttons</strong>: You can control the size, style, and color of the page buttons.</li><li><strong>Previous and Next Navigation:</strong> Easily navigate between pages using next/previous arrows.</li><li><strong>Supports a Large Number of Pages: </strong>You can configure the number of visible page buttons, regardless of how many pages there are.</li><li><strong>Active Page Indicator: </strong>A darkening effect highlights the active page for better user experience.</li><li><strong>Page Change Callback: </strong>Get real-time feedback with a callback function when a page is changed.</li><li><strong>Full Flexibility: </strong>Adapts to any design, light or dark theme, and works across all screen sizes.</li></ul><h3>How to Get Started</h3><p>To integrate MaterialPagination into your Flutter project, follow these simple steps:</p><ol><li>Add the package to your pubspec.yaml:</li></ol><pre>dependencies:<br>  material_pagination: ^1.0.0</pre><p>2. Run the following command to install the package:</p><pre>flutter pub get</pre><p>3. Now you can use the pagination widget in your project. Here’s a basic example:</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:material_pagination/material_pagination.dart&#39;;<br><br>class PaginationExample extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(title: Text(&#39;Pagination Example&#39;)),<br>      body: Center(<br>        child: MaterialPagination(<br>          currentPage: 1,<br>          totalPages: 10,<br>          onPageChanged: (page) {<br>            print(&#39;Page $page selected&#39;);<br>          },<br>          visiblePageCount: 5,<br>          activeColor: Colors.blue,<br>          inactiveColor: Colors.grey,<br>          fontStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>This code sets up a pagination control with 10 pages, where users can easily navigate between them, and the current page is displayed with a blue button.</p><h3>Customization Options</h3><p>One of the most powerful aspects of MaterialPagination is its flexibility in customization. You can tailor the widget to your app’s design using the following properties:</p><p>currentPage Defines the currently selected page.</p><p>totalPages The total number of pages to display.</p><p>onPageChanged Callback when a page is changed.</p><p>visiblePageCount Controls how many page buttons are visible.</p><p>activeColor Sets the color of the active page button.</p><p>inactiveColor Sets the color for inactive buttons.</p><p>fontStyle Customize the style of the page numbers.</p><p>buttonSize Adjust the size of each page button.</p><p>borderRadius Set the border radius for buttons and icons.</p><p><strong>Advanced Example:</strong></p><p>If you want more control over how the pagination looks, here’s an example with more customization:</p><pre>MaterialPagination(<br>  currentPage: 3,<br>  totalPages: 15,<br>  onPageChanged: (page) {<br>    setState(() {<br>      _currentPage = page;<br>    });<br>  },<br>  visiblePageCount: 7,<br>  activeColor: Colors.green,<br>  inactiveColor: Colors.grey,<br>  fontStyle: TextStyle(fontSize: 14, fontWeight: FontWeight.w500),<br>  buttonSize: 40.0,<br>  borderRadius: 10.0,<br>)</pre><h3>Advanced Customization: Dark Mode, Arrows, and More</h3><p>The MaterialPagination widget offers several additional features, such as support for dark themes, next/previous arrows, and button effects. For instance, you can customize the navigation arrows and how far users can scroll through pages with the iconSize and iconGap properties.</p><pre>MaterialPagination(<br>  currentPage: 5,<br>  totalPages: 50,<br>  onPageChanged: (page) {<br>    print(&#39;Page $page selected&#39;);<br>  },<br>  iconSize: 16.0,<br>  iconGap: 8.0,<br>)</pre><h3>Conclusion</h3><p>The MaterialPagination package is perfect for adding paginated content to your Flutter application. Whether you’re building an e-commerce app, blog, or any other app that requires pagination, this package offers a clean and customisable solution.</p><p>Give it a try today, and customise your pagination experience in a few simple steps! You can find more details and download the package on <a href="https://pub.dev/packages/material_pagination">pub.dev</a>.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9cf3d2003c6c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using GSAP with Next.js: A Guide to Animations]]></title>
            <link>https://medium.com/@1shyam2shyam/using-gsap-with-next-js-a-guide-to-animations-bc5b832a70f0?source=rss-9c3649b1c465------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc5b832a70f0</guid>
            <category><![CDATA[gsap]]></category>
            <category><![CDATA[nextjs-animation]]></category>
            <category><![CDATA[gsap-nextjs]]></category>
            <category><![CDATA[animation]]></category>
            <dc:creator><![CDATA[Shyam Jith]]></dc:creator>
            <pubDate>Thu, 03 Oct 2024 15:31:23 GMT</pubDate>
            <atom:updated>2024-10-03T15:31:23.626Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*mwBTI6QKucGdsjaqHIXX7g.jpeg" /></figure><p>When it comes to powerful, smooth animations in web development,<strong> GSAP (GreenSock Animation Platform) </strong>is one of the best tools. Integrating GSAP into Next.js allows you to create stunning animations with ease, and the @gsap/react library offers a React-specific integration that simplifies the process even more.</p><p>In this blog, we’ll explore how to use GSAP in Next.js, focusing on the useGSAP hook provided by @gsap/react. We&#39;ll cover:</p><ol><li>Setting up GSAP in Next.js</li><li>Using the useGSAP hook</li><li>Creating basic animations</li><li>Animating on scroll</li><li>Optimizing performance with GSAP</li></ol><h3>1. Setting Up GSAP in Next.js</h3><p>Before you can start using GSAP, you need to install the GSAP library along with its React integration, @gsap/react.</p><p><strong>Step 1: Install GSAP and </strong><strong>@gsap/react:</strong></p><pre>npm install gsap @gsap/react</pre><p><strong>Step 2: Import GSAP and the </strong><strong>useGSAP hook into your Next.js components:</strong></p><pre>import { useEffect, useRef } from &#39;react&#39;;<br>import { useGSAP } from &#39;@gsap/react&#39;;<br>import gsap from &#39;gsap&#39;;</pre><h3>2. Using the useGSAP Hook</h3><p>The useGSAP hook provided by @gsap/react simplifies the process of integrating GSAP animations within React components. You can use this hook to trigger animations during component mount or based on user interactions, such as scrolling or clicking.</p><p><strong>Basic </strong><strong>useGSAP Example:</strong></p><pre>import { useRef } from &#39;react&#39;;<br>import { useGSAP } from &#39;@gsap/react&#39;;<br>import gsap from &#39;gsap&#39;;<br><br>export default function AnimatedBox() {<br>  const boxRef = useRef(null);<br>  <br>  // Using useGSAP to run animation on mount<br>  useGSAP(() =&gt; {<br>    gsap.to(boxRef.current, { x: 200, duration: 1 });<br>  }, []);<br><br>  return &lt;div ref={boxRef} className=&quot;box&quot;&gt;I&#39;m animated!&lt;/div&gt;;<br>}</pre><p>In this example, the useGSAP hook triggers an animation when the component is rendered, moving the box 200px to the right.</p><h3>3. Creating Basic Animations</h3><p>GSAP provides a flexible syntax to animate any property of a DOM element, from basic properties like opacity and scale to more advanced properties such as rotation and skew.</p><p><strong>Basic Animation Example:</strong></p><pre>useGSAP(() =&gt; {<br>  gsap.fromTo(<br>    boxRef.current,<br>    { opacity: 0, scale: 0.5 },<br>    { opacity: 1, scale: 1, duration: 1.5 }<br>  );<br>}, []);</pre><p>Here, we animate the box’s opacity and scale properties from an initial state to the final state.</p><h3>4. Animating on Scroll</h3><p>GSAP also supports <strong>scroll-triggered</strong> animations using its ScrollTrigger plugin, which can be used to animate elements as they enter or exit the viewport.</p><p><strong>Step 1: Import ScrollTrigger:</strong></p><pre>import { ScrollTrigger } from &#39;gsap/ScrollTrigger&#39;;<br><br>gsap.registerPlugin(ScrollTrigger);</pre><p><strong>Scroll-triggered Animation Example:</strong></p><pre>useGSAP(() =&gt; {<br>  gsap.fromTo(<br>    boxRef.current,<br>    { opacity: 0, y: 50 },<br>    {<br>      opacity: 1,<br>      y: 0,<br>      scrollTrigger: {<br>        trigger: boxRef.current,<br>        start: &quot;top 80%&quot;,<br>        end: &quot;top 30%&quot;,<br>        scrub: true<br>      }<br>    }<br>  );<br>}, []);</pre><p>In this example, the box will fade in and move up as you scroll down the page.</p><h3>5. Optimizing Performance with GSAP</h3><p>GSAP is well-known for its performance optimizations. Here are some tips to ensure your animations run smoothly:</p><ul><li>Use <strong>will-change</strong>: Use the will-change CSS property on animated elements to hint at upcoming changes, improving GPU performance.</li></ul><pre>.box {<br>  will-change: transform, opacity;<br>}</pre><ul><li><strong>Batch Animations: </strong>Instead of animating individual elements, use batching to group animations together.</li><li><strong>Reduce </strong><strong>scrollTrigger</strong>: Avoid having too many scroll-triggered animations active at once. Use lazy: false in ScrollTrigger to optimize resource usage.</li></ul><h3>Conclusion</h3><p>Integrating GSAP into your Next.js project can elevate your website’s interactivity and visual appeal. Using the useGSAP hook provided by @gsap/react, you can easily trigger animations on mount, user interactions, or scroll events. With the power of GSAP and careful performance optimizations, your animations will run smoothly, providing a dynamic user experience.</p><p>Happy animating!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc5b832a70f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Next.js Data Fetching: Complete Guide]]></title>
            <link>https://medium.com/@1shyam2shyam/next-js-data-fetching-complete-guide-273bb668567b?source=rss-9c3649b1c465------2</link>
            <guid isPermaLink="false">https://medium.com/p/273bb668567b</guid>
            <category><![CDATA[json-server]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[nextjs-tutorial]]></category>
            <category><![CDATA[nextjs-data-fetching]]></category>
            <dc:creator><![CDATA[Shyam Jith]]></dc:creator>
            <pubDate>Thu, 03 Oct 2024 15:18:18 GMT</pubDate>
            <atom:updated>2024-10-03T15:18:18.743Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*CLfxHCCH3RQrYp1l-kd7OQ.gif" /></figure><p>Next.js provides a powerful data fetching system that integrates seamlessly with its server and client components. In this blog, we’ll cover different ways to fetch data in Next.js, manage loading and error states, set up a mock API with JSON Server, control caching, revalidate data, and explore client-side fetching.</p><h3>1. Fetching Data with Server Components</h3><p>By default, components in Next.js are <strong>Server Components</strong>, meaning that they can fetch data on the server without affecting the bundle size sent to the client. This provides better SEO and faster performance since the data fetching logic and the rendering happen server-side.</p><p><strong>Example of Fetching Data in a Server Component:</strong></p><pre>// app/users/page.tsx<br>export default async function UsersPage() {<br>  const res = await fetch(&#39;https://api.example.com/users&#39;);<br>  const users = await res.json();<br><br>  return (<br>    &lt;div&gt;<br>      {users.map((user: any) =&gt; (<br>        &lt;div key={user.id}&gt;{user.name}&lt;/div&gt;<br>      ))}<br>    &lt;/div&gt;<br>  );<br>}</pre><p>In the above example, the data is fetched on the server, and the rendered HTML is sent to the client, making it highly performant.</p><h3>2. Loading and Error States</h3><p>To handle loading and error states gracefully, Next.js provides built-in mechanisms. In Server Components, you can use Suspense boundaries to display fallback content while the data is being fetched.</p><p><strong>Loading State:</strong></p><pre>// app/users/loading.tsx<br>export default function Loading() {<br>  return &lt;div&gt;Loading...&lt;/div&gt;;<br>}</pre><p><strong>Error State:</strong></p><pre>// app/users/error.tsx<br>export default function Error() {<br>  return &lt;div&gt;Error loading data...&lt;/div&gt;;<br>}</pre><p>Next.js will automatically use these components when there’s a delay in fetching the data or if an error occurs.</p><h3>3. JSON Server Setup</h3><p>To create a mock API for testing purposes, you can set up a <strong>JSON Server. </strong>JSON Server allows you to serve a fake REST API quickly.</p><p><strong>Step 1: Install JSON Server</strong></p><pre>npm install -g json-server</pre><p><strong>Step 2: Create a </strong>db.json<strong> file</strong></p><pre>{<br>  &quot;users&quot;: [<br>    { &quot;id&quot;: 1, &quot;name&quot;: &quot;John Doe&quot; },<br>    { &quot;id&quot;: 2, &quot;name&quot;: &quot;Jane Doe&quot; }<br>  ]<br>}</pre><p><strong>Step 3: Run the JSON Server</strong></p><pre>json-server --watch db.json --port 3001</pre><p>Now, you can fetch data from http://localhost:3001/users in your Next.js app.</p><h3>4. Caching Data</h3><p>Next.js automatically caches responses from fetch requests in<strong> Server Components</strong> to optimize performance. This allows you to serve the same response for repeated requests without refetching the data unless revalidation is needed.</p><p><strong>Example with Caching:</strong></p><pre>export default async function CachedUsersPage() {<br>  const res = await fetch(&#39;https://api.example.com/users&#39;, {<br>    next: { revalidate: 60 }, // Revalidate data every 60 seconds<br>  });<br>  const users = await res.json();<br><br>  return &lt;div&gt;{users.map((user: any) =&gt; &lt;div key={user.id}&gt;{user.name}&lt;/div&gt;)}&lt;/div&gt;;<br>}</pre><p>Here, data is cached and revalidated every 60 seconds, reducing the number of fetch calls to the API.</p><h3>5. Opting Out of Caching</h3><p>If you need fresh data on every request, you can opt out of caching by setting the cache option to &quot;no-store&quot;.</p><pre>export default async function NoCachePage() {<br>  const res = await fetch(&#39;https://api.example.com/users&#39;, {<br>    cache: &#39;no-store&#39;,<br>  });<br>  const users = await res.json();<br><br>  return &lt;div&gt;{users.map((user: any) =&gt; &lt;div key={user.id}&gt;{user.name}&lt;/div&gt;)}&lt;/div&gt;;<br>}</pre><p>This will force Next.js to refetch the data every time the page is requested.</p><h3>6. Time-based Data Revalidation</h3><p>Revalidation allows Next.js to update the cached data periodically without forcing the user to wait for fresh content. Using the revalidate option in the fetch method, you can specify how often the data should be updated.</p><p><strong>Example of Revalidating Data Every 30 Seconds:</strong></p><pre>export default async function RevalidatePage() {<br>  const res = await fetch(&#39;https://api.example.com/users&#39;, {<br>    next: { revalidate: 30 }, // Revalidate data every 30 seconds<br>  });<br>  const users = await res.json();<br><br>  return &lt;div&gt;{users.map((user: any) =&gt; &lt;div key={user.id}&gt;{user.name}&lt;/div&gt;)}&lt;/div&gt;;<br>}</pre><p>This approach strikes a balance between keeping the data fresh and minimizing server load.</p><h3>7. Client-side Data Fetching</h3><p>Sometimes, you may need to fetch data on the client side for interactive or real-time features. You can use useEffect in <strong>Client Components</strong> to fetch data on the client.</p><p><strong>Client-side Data Fetching Example:</strong></p><pre>&quot;use client&quot;;<br><br>import { useState, useEffect } from &#39;react&#39;;<br><br>export default function ClientFetchComponent() {<br>  const [data, setData] = useState(null);<br>  const [loading, setLoading] = useState(true);<br><br>  useEffect(() =&gt; {<br>    async function fetchData() {<br>      const res = await fetch(&#39;https://api.example.com/users&#39;);<br>      const users = await res.json();<br>      setData(users);<br>      setLoading(false);<br>    }<br><br>    fetchData();<br>  }, []);<br><br>  if (loading) return &lt;div&gt;Loading...&lt;/div&gt;;<br><br>  return &lt;div&gt;{data.map((user: any) =&gt; &lt;div key={user.id}&gt;{user.name}&lt;/div&gt;)}&lt;/div&gt;;<br>}</pre><p>Client-side fetching is useful for dynamic pages or components that require real-time updates, such as charts or forms.</p><h3>Conclusion</h3><p>Next.js provides multiple ways to fetch data, ranging from server-side rendering with caching and revalidation to client-side fetching for interactive pages. By understanding the data-fetching model in Next.js, you can build performant applications that efficiently load and update data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=273bb668567b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Next.js Rendering: A Deep Dive]]></title>
            <link>https://medium.com/@1shyam2shyam/next-js-rendering-a-deep-dive-e2a2d6701672?source=rss-9c3649b1c465------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2a2d6701672</guid>
            <category><![CDATA[nextjs-rendering]]></category>
            <category><![CDATA[nextjs-tutorial]]></category>
            <category><![CDATA[server-side-rendering]]></category>
            <category><![CDATA[nextjs-ssr]]></category>
            <category><![CDATA[nextjs-csr]]></category>
            <dc:creator><![CDATA[Shyam Jith]]></dc:creator>
            <pubDate>Thu, 03 Oct 2024 15:03:21 GMT</pubDate>
            <atom:updated>2024-10-03T15:03:21.911Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*htU06RotX9OO1ai6I0RIbw.png" /></figure><p>Next.js offers various ways to render your pages and components, combining both server and client rendering capabilities to create fast, dynamic web applications. In this blog, we’ll cover the different approaches and concepts related to rendering in Next.js, focusing on server and client components, dynamic rendering, streaming, and more.</p><h3>1. Server and Client Components</h3><p>Next.js 13 introduced a hybrid rendering model with <strong>Server</strong> and <strong>Client</strong> Components. By default, components are <strong>Server Components</strong>, allowing you to fetch data on the server and send it to the client pre-rendered, improving performance and SEO.</p><p><strong>Server Component Example:</strong></p><pre>// app/page.tsx<br>export default async function Page() {<br>  const data = await fetchDataFromAPI();<br>  return &lt;div&gt;{data}&lt;/div&gt;;<br>}</pre><p>To make a component a Client Component, you need to use the &quot;use client&quot; directive at the top of the file. This makes the component fully interactive on the client-side.</p><p><strong>Client Component Example:</strong></p><pre>// app/component.tsx<br>&quot;use client&quot;;<br><br>export default function ClientComponent() {<br>  const [state, setState] = useState(0);<br>  <br>  return &lt;button onClick={() =&gt; setState(state + 1)}&gt;{state}&lt;/button&gt;;<br>}</pre><h3>2. Dynamic Rendering</h3><p>Dynamic rendering allows Next.js to render pages that change depending on external data or user interactions. This can be achieved using <strong>getServerSideProps</strong> (SSR) or <strong>getStaticProps</strong> (SSG) with revalidation, enabling pages to refresh at runtime or after a fixed time interval.</p><p><strong>Example of Server-side Rendering (SSR):</strong></p><pre>export async function getServerSideProps() {<br>  const data = await fetch(&#39;https://api.example.com/data&#39;);<br>  <br>  return { props: { data } };<br>}</pre><h3>3. Streaming</h3><p>Next.js supports <strong>streaming</strong>, enabling you to progressively send HTML to the client while the server fetches and renders data. This is ideal for improving perceived load time as the page content is sent in chunks.</p><p><strong>Example of Streaming in Next.js:</strong></p><pre>export async function GET() {<br>  const stream = new ReadableStream({<br>    start(controller) {<br>      controller.enqueue(&#39;&lt;h1&gt;First Chunk&lt;/h1&gt;&#39;);<br>      controller.close();<br>    }<br>  });<br>  <br>  return new Response(stream, { headers: { &#39;Content-Type&#39;: &#39;text/html&#39; } });<br>}</pre><h3>4. Server-only Code</h3><p>With <strong>Server Components,</strong> you can write code that never reaches the client. This is crucial for securely handling data like API secrets, database queries, or sensitive logic.</p><p><strong>Example:</strong></p><pre>export default async function Page() {<br>  const secretData = process.env.API_SECRET;<br>  const data = await fetchSecureData(secretData);<br>  <br>  return &lt;div&gt;{data}&lt;/div&gt;;<br>}</pre><h3>5. Third-Party Packages</h3><p>When using third-party packages, ensure that they are compatible with both server and client environments. Some packages, like those relying on browser APIs, need to be loaded in<strong> Client Components.</strong></p><p><strong>Example:</strong></p><pre>&quot;use client&quot;;<br>import { SomeBrowserAPI } from &#39;some-browser-api&#39;;<br><br>export default function ClientComponent() {<br>  SomeBrowserAPI.init();<br>  <br>  return &lt;div&gt;Using Third-Party API&lt;/div&gt;;<br>}</pre><h3>6. Context Providers</h3><p>Context Providers are essential for managing global state across your application. You can use React’s Context API within <strong>Client Components</strong> for state sharing, but you can also pass props from Server Components.</p><p>Example:</p><pre>&quot;use client&quot;;<br>import { createContext, useContext } from &#39;react&#39;;<br><br>const MyContext = createContext(null);<br><br>export function MyProvider({ children }) {<br>  const value = useMyState();<br>  return &lt;MyContext.Provider value={value}&gt;{children}&lt;/MyContext.Provider&gt;;<br>}<br><br>export function useMyContext() {<br>  return useContext(MyContext);<br>}</pre><h3>7. Client-only Code</h3><p>Client-only code must be restricted to components that explicitly opt into the &quot;use client&quot; directive. This includes interactivity, event listeners, and browser-specific logic like local storage access.</p><pre>&quot;use client&quot;;<br><br>export default function ClientOnlyComponent() {<br>  const [value, setValue] = useState(localStorage.getItem(&#39;key&#39;));<br>  <br>  return &lt;div&gt;{value}&lt;/div&gt;;<br>}</pre><h3>8. Client Component Placement</h3><p>You can strategically place<strong> Client Components</strong> only where necessary. This minimizes client-side JavaScript and keeps most of your components as <strong>Server Components</strong> for better performance.</p><p><strong>Example:</strong></p><pre>export default function Page() {<br>  return (<br>    &lt;div&gt;<br>      &lt;ServerComponent /&gt;<br>      &lt;ClientComponent /&gt; {/* Only this part is interactive */}<br>    &lt;/div&gt;<br>  );<br>}</pre><h3>9. Interleaving Server and Client Components</h3><p>You can interleave <strong>Server</strong> and <strong>Client Components</strong> within a single page. For example, load static data on the server but add interactivity with a client-side form or button.</p><pre>export default async function Page() {<br>  const data = await fetchDataFromAPI();<br><br>  return (<br>    &lt;div&gt;<br>      &lt;ServerComponent data={data} /&gt;<br>      &lt;ClientComponent /&gt; {/* Adds client-side interactivity */}<br>    &lt;/div&gt;<br>  );<br>}</pre><h3>Conclusion</h3><p>Next.js offers a flexible and powerful rendering system, allowing you to combine server-side logic with client-side interactivity. By understanding how to strategically use Server and Client Components, dynamic rendering, and more, you can build highly optimized and dynamic applications.</p><p><em>“The best way to predict the future is to invent it.”</em> — Alan Kay</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2a2d6701672" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>