<?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 Amir on Medium]]></title>
        <description><![CDATA[Stories by Amir on Medium]]></description>
        <link>https://medium.com/@amirjld?source=rss-9f72c1e4b97b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*uOzC38iiPoh2tuOa</url>
            <title>Stories by Amir on Medium</title>
            <link>https://medium.com/@amirjld?source=rss-9f72c1e4b97b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 16:23:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amirjld/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[10 Tiny Next.js Tricks You’ll Wish You Knew Earlier]]></title>
            <link>https://medium.com/@amirjld/10-tiny-next-js-tricks-youll-wish-you-knew-earlier-5b4a671a24d6?source=rss-9f72c1e4b97b------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b4a671a24d6</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[nextjs-tutorial]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Thu, 05 Feb 2026 17:51:03 GMT</pubDate>
            <atom:updated>2026-02-05T17:51:03.623Z</atom:updated>
            <content:encoded><![CDATA[<h4>Next.js is packed with small features that most developers overlook — even though they can make your app cleaner, faster, and easier to maintain.</h4><p>Here are 10 bite-sized tricks that instantly level up your App Router workflow.</p><h3>1. notFound() Instantly Returns a 404 (No Extra Page Needed)</h3><p>Instead of manually redirecting:</p><pre>if (!post) return &lt;div&gt;Not found&lt;/div&gt;;</pre><p>Use:</p><pre>import { notFound } from &quot;next/navigation&quot;;<br><br>if (!post) notFound();</pre><p>Cleaner, standard, and automatically uses /not-found.</p><h3>2. Named Route Groups Don’t Affect the URL Structure</h3><p>You can organize routes without changing the URL:</p><pre>app<br> └── (dashboard)<br>     └── settings<br>         └── page.tsx</pre><p>URL is still:</p><pre>/settings</pre><p>Amazing for large codebases.</p><h3>3. You Can generateMetadata() Using Async Fetch Calls</h3><p>Dynamic SEO → fully supported.</p><pre>export async function generateMetadata({ params }) {<br>  const post = await fetchPost(params.slug);<br><br>  return {<br>    title: post.title,<br>    description: post.excerpt,<br>  };<br>}</pre><p>No more static metadata files.</p><h3>4. Built-in redirect() Works Anywhere on the Server</h3><pre>import { redirect } from &quot;next/navigation&quot;;<br><br>if (!isLoggedIn) redirect(&quot;/login&quot;);</pre><p>No getServerSideProps. No hacks.</p><h3>5. Server Components Support Promises Directly</h3><p>This works:</p><pre>export default async function Page() {<br>  const data = getData(); // returns a Promise<br><br>  return &lt;pre&gt;{JSON.stringify(await data)}&lt;/pre&gt;;<br>}</pre><p>React automatically handles streams + suspension.</p><h3>6. You Can Create Instant API Proxies With fetch</h3><p>Instead of:</p><pre>export async function GET() {<br>  const data = await axios.get(&quot;https://api.example.com/data&quot;);<br>  return Response.json(data.data);<br>}</pre><p>Just use fetch:</p><pre>export async function GET() {<br>  return fetch(&quot;https://api.example.com/data&quot;);<br>}</pre><p>Next.js streams the response directly.</p><h3>7. Use cookies() Inside Server Components to Read Auth Tokens</h3><pre>import { cookies } from &quot;next/headers&quot;;<br><br>const token = cookies().get(&quot;session&quot;)?.value;</pre><p>Zero client-side JavaScript.<br> No context providers.<br> Authentication becomes <em>simple</em>.</p><h3>8. You Can Stream Partial UI Using Suspense (Instant TTI)</h3><pre>export default function Page() {<br>  return (<br>    &lt;&gt;<br>      &lt;Header /&gt;<br>      &lt;Suspense fallback={&lt;LoadingPosts /&gt;}&gt;<br>        &lt;Posts /&gt;<br>      &lt;/Suspense&gt;<br>    &lt;/&gt;<br>  );<br>}</pre><p>Your layout renders immediately; the heavy components stream in later.</p><h3>9. Use (.), (..), and (...) Folders to Create Partial Route Overlays</h3><p>Next.js supports “partial routing,” like mobile-style modals:</p><pre>app<br> ├── photos<br> ├── photos<br> │    └── (..)modal</pre><p>This renders the modal <strong>over the previous UI</strong> instead of replacing it.</p><p>Perfect for Instagram-style image previews.</p><h3>10. Server Actions Don’t Need Forms — You Can Call Them Like RPC</h3><p>Most tutorials only show:</p><pre>&lt;form action={createPost}&gt;…&lt;/form&gt;</pre><p>But you can call them directly:</p><pre>&quot;use server&quot;;<br><br>export async function createPost() { … }</pre><p>Client usage:</p><pre>await createPost();</pre><p>It’s basically a built-in RPC layer.</p><h3>Conclusion</h3><p>These tiny Next.js tricks can save hours of debugging and make your code much more elegant:</p><ol><li>notFound()</li><li>Route groups</li><li>Dynamic metadata</li><li>redirect()</li><li>Async server components</li><li>API proxying</li><li>Cookie access</li><li>Streaming UI</li><li>Partial route overlays</li><li>Server Actions as RPC</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b4a671a24d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The 5 Most Common Next.js App Router Mistakes And How to Fix Them]]></title>
            <link>https://medium.com/@amirjld/the-5-most-common-next-js-app-router-mistakes-and-how-to-fix-them-632565a5fb96?source=rss-9f72c1e4b97b------2</link>
            <guid isPermaLink="false">https://medium.com/p/632565a5fb96</guid>
            <category><![CDATA[nextjs-app-router]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Wed, 04 Feb 2026 23:26:17 GMT</pubDate>
            <atom:updated>2026-02-04T23:26:17.807Z</atom:updated>
            <content:encoded><![CDATA[<p>The Next.js App Router is powerful — layouts, React Server Components, Server Actions, caching, streaming — but most developers hit the same handful of mistakes when they start using it in real projects.</p><p>Here are the <strong>5 most common pitfalls</strong> I see over and over — and how to fix them immediately.</p><h3>1. Putting Client Components Where They Don’t Belong</h3><p><strong>The mistake:</strong><br> Wrapping entire pages in &quot;use client&quot; because something “doesn’t work.”</p><pre>// ❌ Don&#39;t do this<br>&quot;use client&quot;;<br><br>export default function Page() {<br>  return &lt;Dashboard /&gt;;<br>}</pre><p>This forces <strong>the whole subtree</strong> to become client-side, disabling:</p><ul><li>server-side data fetching</li><li>automatic caching</li><li>reduced bundle size</li><li>streaming</li></ul><p><strong>Correct approach:</strong><br> Only make the smallest component client-side.</p><pre>export default function Page() {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Dashboard&lt;/h1&gt;<br>      &lt;ChartClientComponent /&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><h3>2. Forgetting That fetch() Is Cached by Default</h3><p>Default caching surprises everyone at least once.</p><pre>// ❌ This will be cached forever by default<br>const data = await fetch(&quot;https://api.example.com/stats&quot;).then(r =&gt; r.json());</pre><p>Symptoms:</p><ul><li>Your UI doesn’t update</li><li>Stale results</li><li>Data appears “stuck”</li></ul><p><strong>Fix:</strong><br> Decide intentionally how you want to cache it:</p><p><strong>Disable caching</strong></p><pre>await fetch(url, { cache: &quot;no-store&quot; });</pre><p><strong>Set revalidation</strong></p><pre>await fetch(url, { next: { revalidate: 10 } });</pre><p><strong>Force one-time server fetch</strong></p><pre>await fetch(url, { cache: &quot;no-cache&quot; });</pre><p>This alone fixes 80% of “why is my data stale?” issues.</p><h3>3. Misusing Layouts for Stateful Logic</h3><p>Layouts are <strong>shared</strong>, meaning they <strong>do not remount between routes</strong>.</p><p>Common mistake:</p><pre>// ❌ layout.tsx<br>&quot;use client&quot;;<br><br>export default function RootLayout({ children }) {<br>  const [count, setCount] = useState(0); // persists between pages!<br>}</pre><p>This leads to:</p><ul><li>State leaking between pages</li><li>UI not resetting</li><li>Confusing behavior</li></ul><p><strong>Fix:</strong><br> Only put <strong>system-level</strong> or <strong>global</strong> UI in layouts:</p><ul><li>Theme provider</li><li>Navbar</li><li>Footer</li><li>Auth wrappers</li><li>Global CSS</li></ul><p>Anything interactive should live in the page or a client component inside the page.</p><h3>4. Using Route Handlers for “Everything”</h3><p>Some devs treat /api/* like a traditional backend.</p><pre>// ❌ next.js is NOT a full Express replacement<br>app.get(&quot;/api/users&quot;, ...)</pre><p>But Route Handlers are best for:</p><ul><li>simple CRUD</li><li>server actions helpers</li><li>webhooks</li><li>simple utilities</li></ul><p>They are <strong>not</strong> meant for:</p><ul><li>complex request routing</li><li>authentication middlewares</li><li>chained middlewares</li><li>big monolithic APIs</li></ul><p><strong>Fix:</strong><br> If the logic is heavy:</p><ul><li>Use <strong>server actions</strong> for UI-driven mutations</li><li>Use <strong>a dedicated backend</strong> for large APIs</li><li>Or keep Route Handlers tight by splitting logic into modules</li></ul><h3>5. Triggering Revalidation Incorrectly</h3><p>Many beginners assume revalidatePath() updates everything everywhere.</p><p>It doesn’t.</p><p>Example mistake:</p><pre>&quot;use server&quot;;<br><br>export async function updatePost() {<br>  await db.post.update(...);<br><br>  revalidatePath(&quot;/&quot;);<br>}</pre><p>But the stale data is inside:</p><pre>/posts/[id]</pre><p><strong>Fix:</strong><br> You must revalidate the exact path or segment:</p><pre>revalidatePath(`/posts/${id}`);</pre><p>Or if the data affects a layout segment:</p><pre>revalidatePath(&quot;/posts&quot;, &quot;layout&quot;);</pre><p><strong>General rule:</strong></p><blockquote><em>Revalidate the closest segment where the data is fetched.</em></blockquote><h3>Conclusion</h3><p>These five issues cause 90% of App Router confusion:</p><ol><li>Misplaced client components</li><li>Confusing fetch() caching</li><li>Stateful logic inside layouts</li><li>Overusing Route Handlers</li><li>Incorrect revalidation patterns</li></ol><p>Fix these, and your Next.js app will become:</p><ul><li>faster</li><li>cleaner</li><li>more predictable</li><li>more scalable</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=632565a5fb96" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Push Notifications in Next.js using Web Push and Server Actions]]></title>
            <link>https://medium.com/@amirjld/implementing-push-notifications-in-next-js-using-web-push-and-server-actions-f4b95d68091f?source=rss-9f72c1e4b97b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4b95d68091f</guid>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Thu, 22 Jan 2026 01:18:52 GMT</pubDate>
            <atom:updated>2026-01-22T01:18:52.560Z</atom:updated>
            <content:encoded><![CDATA[<h4>This guide walks you through <strong>end‑to‑end implementation of Web Push Notifications</strong> in <strong>Next.js (App Router)</strong> using <strong>Service Workers, Web Push Protocol, VAPID keys, and Server Actions</strong>.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TFj-UsWxRu5aRrcQrwVtJw.png" /></figure><p>By the end, you’ll have:</p><ul><li>A working push notification system</li><li>Browser permission handling</li><li>Push subscription storage</li><li>Server‑side notification sending</li></ul><h3>Table of Contents</h3><ol><li>What Are Web Push Notifications?</li><li>Architecture Overview</li><li>Prerequisites</li><li>Project Setup</li><li>Generating VAPID Keys</li><li>Service Worker Setup</li><li>Requesting Notification Permission</li><li>Subscribing the User</li><li>Storing Subscriptions</li><li>Sending Push Notifications (Server Actions)</li><li>Testing &amp; Debugging</li><li>Common Pitfalls</li><li>Production Considerations</li><li>Conclusion</li></ol><h3>1. What Are Web Push Notifications?</h3><p>Web Push Notifications allow websites to send messages to users even when the site is closed.</p><p>Key components:</p><ul><li><strong>Service Worker</strong> — Runs in the background</li><li><strong>Push API</strong> — Subscribes users</li><li><strong>Notification API</strong> — Displays notifications</li><li><strong>Application Server</strong> — Sends messages</li></ul><h3>2. Architecture Overview</h3><pre>Browser<br> ├── Service Worker<br> ├── Push Subscription<br> └── Notification UI<br>        ↑<br>        │ Web Push Protocol<br>        ↓<br>Next.js Server Actions<br> ├── VAPID Auth<br> ├── Subscription Store<br> └── Push Sender</pre><h3>3. Prerequisites</h3><ul><li>Node.js 18+</li><li>Next.js 13+ (App Router)</li><li>HTTPS (required for push)</li><li>Basic React knowledge</li></ul><h3>4. Project Setup</h3><pre>npx create-next-app@latest web-push-demo<br>cd web-push-demo<br>npm install web-push</pre><h3>5. Generating VAPID Keys</h3><p>VAPID keys authenticate your server with push services.</p><pre>npx web-push generate-vapid-keys</pre><p>You’ll get:</p><pre>Public Key:  BOP...<br>Private Key: 9Yx...</pre><p>Add them to .env.local:</p><pre>NEXT_PUBLIC_VAPID_PUBLIC_KEY=your_public_key<br>VAPID_PRIVATE_KEY=your_private_key</pre><h3>6. Service Worker Setup</h3><p>Create a file in public/sw.js:</p><pre>self.addEventListener(&#39;push&#39;, event =&gt; {<br>  const data = event.data?.json();<br>  event.waitUntil(<br>    self.registration.showNotification(data.title, {<br>      body: data.body,<br>      icon: &#39;/icon.png&#39;<br>    })<br>  );<br>});</pre><p>Service workers <strong>must</strong> live in /public.</p><p><strong>NOTE : You have to make your website PWA , for that you can use </strong><a href="https://medium.com/@amirjld/how-to-implement-pwa-progressive-web-app-in-next-js-app-router-2026-f25a6797d5e6"><strong>this guide</strong></a></p><h3>7. Registering the Service Worker</h3><pre>&#39;use client&#39;;<br><br>useEffect(() =&gt; {<br>  if (&#39;serviceWorker&#39; in navigator) {<br>    navigator.serviceWorker.register(&#39;/sw.js&#39;);<br>  }<br>}, []);</pre><h3>8. Requesting Notification Permission</h3><pre>export async function requestPermission() {<br>  const permission = await Notification.requestPermission();<br>  return permission === &#39;granted&#39;;<br>}</pre><p>Best practice: request permission <strong>after user interaction</strong>.</p><h3>9. Subscribing the User to Push</h3><pre>async function subscribeUser() {<br>  const registration = await navigator.serviceWorker.ready;<br><br>  const subscription = await registration.pushManager.subscribe({<br>    userVisibleOnly: true,<br>    applicationServerKey: urlBase64ToUint8Array(<br>      process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY!<br>    ),<br>  });<br><br>  await saveSubscription(subscription);<br>}</pre><p>Helper function:</p><pre>function urlBase64ToUint8Array(base64String: string) {<br>  const padding = &#39;=&#39;.repeat((4 - base64String.length % 4) % 4);<br>  const base64 = (base64String + padding)<br>    .replace(/-/g, &#39;+&#39;)<br>    .replace(/_/g, &#39;/&#39;);<br>  const rawData = atob(base64);<br><br>  return Uint8Array.from([...rawData].map(c =&gt; c.charCodeAt(0)));<br>}</pre><h3>10. Saving Subscriptions (Server Action)</h3><pre>&#39;use server&#39;;<br><br>let subscriptions: PushSubscription[] = [];<br><br>export async function saveSubscription(sub: PushSubscription) {<br>  subscriptions.push(sub);<br>}</pre><blockquote><em>⚠️ In production, use a database.</em></blockquote><h3>11. Sending Push Notifications</h3><pre>&#39;use server&#39;;<br><br>import webpush from &#39;web-push&#39;;<br><br>webpush.setVapidDetails(<br>  &#39;admin@example.com&#39;,<br>  process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY!,<br>  process.env.VAPID_PRIVATE_KEY!<br>);<br><br>export async function sendNotification(message: string) {<br>  const payload = JSON.stringify({<br>    title: &#39;New Notification&#39;,<br>    body: message,<br>  });<br><br>  await Promise.all(<br>    subscriptions.map(sub =&gt;<br>      webpush.sendNotification(sub, payload)<br>    )<br>  );<br>}</pre><h3>12. Triggering from UI</h3><pre>&lt;button onClick={() =&gt; sendNotification(&#39;Hello from Next.js!&#39;)}&gt;<br>  Send Notification<br>&lt;/button&gt;</pre><h3>13. Testing &amp; Debugging</h3><ul><li>Chrome DevTools → Application → Service Workers</li><li>Clear subscriptions on errors</li><li>Check HTTPS</li></ul><h3>14. Common Pitfalls</h3><ul><li>❌ Using HTTP instead of HTTPS</li><li>❌ Requesting permission on page load</li><li>❌ Forgetting userVisibleOnly: true</li><li>❌ Invalid VAPID keys</li></ul><h3>15. Production Considerations</h3><ul><li>Store subscriptions per user</li><li>Handle expired subscriptions (410 Gone)</li><li>Add click actions</li><li>Rate‑limit notifications</li></ul><h3>16. Conclusion</h3><p>Web Push with Next.js Server Actions gives you:</p><ul><li>No separate backend</li><li>Secure push delivery</li><li>Native browser notifications</li></ul><p>This stack is perfect for SaaS dashboards, alerts, and engagement features.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4b95d68091f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Set Up a Turborepo with Next.js, TypeScript, Tailwind CSS v4, and shadcn/ui]]></title>
            <link>https://medium.com/@amirjld/how-to-set-up-a-turborepo-with-next-js-typescript-tailwind-css-v4-and-shadcn-ui-1d0535ea160f?source=rss-9f72c1e4b97b------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d0535ea160f</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[turborepo]]></category>
            <category><![CDATA[tailwind-css]]></category>
            <category><![CDATA[shadcn]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Wed, 07 Jan 2026 21:35:01 GMT</pubDate>
            <atom:updated>2026-02-01T05:39:24.608Z</atom:updated>
            <content:encoded><![CDATA[<h4>A practical guide to building a fast, type-safe monorepo with shared UI components</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d8_YphIJuH1md5Te1AwchQ.png" /></figure><p><strong>Let’s skip the fluff and get straight into the setup.</strong></p><h3>Step 1: Create a New Turborepo</h3><p>Start by generating a fresh Turborepo project. This template already includes two Next.js applications.</p><pre>bunx create-turbo@latest</pre><p>You’ll be prompted to choose:</p><ul><li>A project name</li><li>Your preferred package manager (this guide uses <strong>Bun</strong>)</li></ul><p>Once the command finishes successfully, open the project in your IDE.</p><p>You should see two main directories:</p><pre>apps/<br>packages/</pre><p>Navigate to:</p><pre>packages/ui/src</pre><p>Delete any existing components inside this folder. We’ll be using <strong>shadcn/ui</strong> instead of the default components.</p><h3>Step 2: Install Tailwind CSS in the UI Package</h3><p>Move into the UI package:</p><pre>cd packages/ui</pre><p>Install Tailwind CSS and its PostCSS dependencies:</p><p><strong>in /apps/web run : </strong>bun add -D @tailwindcss/postcss postcss</p><p>And Then in /packages/ui run :</p><pre>bun add tailwindcss @tailwindcss/postcss postcss</pre><h3>Step 3: Configure PostCSS</h3><p>Create a PostCSS config file:</p><p><strong>/packages/ui/postcss.config.mjs</strong></p><pre>export default {<br>  plugins: {<br>    &quot;@tailwindcss/postcss&quot;: {},<br>  },<br>}</pre><h3>Step 4: Add Global Styles</h3><p>Create the following file:</p><p><strong>/packages/ui/src/styles/globals.css</strong></p><pre>@import &quot;tailwindcss&quot;;</pre><p>This file will act as the shared global stylesheet for your UI package.</p><h3>Step 5: Manually Configure shadcn/ui</h3><p>We’ll now prepare the UI package so it works smoothly with shadcn in a Turborepo setup.</p><h3>Install Required Dependencies</h3><p>From inside packages/ui, run:</p><pre>bun add class-variance-authority clsx tailwind-merge lucide-react tw-animate-css</pre><h3>Configure TypeScript Path Aliases</h3><p>Update the UI package’s tsconfig.json:</p><pre>{<br>  &quot;extends&quot;: &quot;@repo/typescript-config/react-library.json&quot;,<br>  &quot;compilerOptions&quot;: {<br>    &quot;baseUrl&quot;: &quot;.&quot;,<br>    &quot;paths&quot;: {<br>      &quot;@repo/ui/*&quot;: [&quot;./src/*&quot;]<br>    }<br>  },<br>  &quot;include&quot;: [&quot;src&quot;],<br>  &quot;exclude&quot;: [&quot;node_modules&quot;, &quot;dist&quot;]<br>}</pre><h3>Define Global Theme Styles</h3><p>Open <strong>/packages/ui/src/styles/globals.css</strong> and replace its contents with:</p><pre>@import &quot;tailwindcss&quot;;</pre><pre>@import &quot;tailwindcss&quot;;<br>@import &quot;tw-animate-css&quot;;<br><br>@custom-variant dark (&amp;:is(.dark *));<br><br>:root {<br>  --background: oklch(1 0 0);<br>  --foreground: oklch(0.145 0 0);<br>  --card: oklch(1 0 0);<br>  --card-foreground: oklch(0.145 0 0);<br>  --popover: oklch(1 0 0);<br>  --popover-foreground: oklch(0.145 0 0);<br>  --primary: oklch(0.205 0 0);<br>  --primary-foreground: oklch(0.985 0 0);<br>  --secondary: oklch(0.97 0 0);<br>  --secondary-foreground: oklch(0.205 0 0);<br>  --muted: oklch(0.97 0 0);<br>  --muted-foreground: oklch(0.556 0 0);<br>  --accent: oklch(0.97 0 0);<br>  --accent-foreground: oklch(0.205 0 0);<br>  --destructive: oklch(0.577 0.245 27.325);<br>  --destructive-foreground: oklch(0.577 0.245 27.325);<br>  --border: oklch(0.922 0 0);<br>  --input: oklch(0.922 0 0);<br>  --ring: oklch(0.708 0 0);<br>  --chart-1: oklch(0.646 0.222 41.116);<br>  --chart-2: oklch(0.6 0.118 184.704);<br>  --chart-3: oklch(0.398 0.07 227.392);<br>  --chart-4: oklch(0.828 0.189 84.429);<br>  --chart-5: oklch(0.769 0.188 70.08);<br>  --radius: 0.625rem;<br>  --sidebar: oklch(0.985 0 0);<br>  --sidebar-foreground: oklch(0.145 0 0);<br>  --sidebar-primary: oklch(0.205 0 0);<br>  --sidebar-primary-foreground: oklch(0.985 0 0);<br>  --sidebar-accent: oklch(0.97 0 0);<br>  --sidebar-accent-foreground: oklch(0.205 0 0);<br>  --sidebar-border: oklch(0.922 0 0);<br>  --sidebar-ring: oklch(0.708 0 0);<br>}<br><br>.dark {<br>  --background: oklch(0.145 0 0);<br>  --foreground: oklch(0.985 0 0);<br>  --card: oklch(0.145 0 0);<br>  --card-foreground: oklch(0.985 0 0);<br>  --popover: oklch(0.145 0 0);<br>  --popover-foreground: oklch(0.985 0 0);<br>  --primary: oklch(0.985 0 0);<br>  --primary-foreground: oklch(0.205 0 0);<br>  --secondary: oklch(0.269 0 0);<br>  --secondary-foreground: oklch(0.985 0 0);<br>  --muted: oklch(0.269 0 0);<br>  --muted-foreground: oklch(0.708 0 0);<br>  --accent: oklch(0.269 0 0);<br>  --accent-foreground: oklch(0.985 0 0);<br>  --destructive: oklch(0.396 0.141 25.723);<br>  --destructive-foreground: oklch(0.637 0.237 25.331);<br>  --border: oklch(0.269 0 0);<br>  --input: oklch(0.269 0 0);<br>  --ring: oklch(0.439 0 0);<br>  --chart-1: oklch(0.488 0.243 264.376);<br>  --chart-2: oklch(0.696 0.17 162.48);<br>  --chart-3: oklch(0.769 0.188 70.08);<br>  --chart-4: oklch(0.627 0.265 303.9);<br>  --chart-5: oklch(0.645 0.246 16.439);<br>  --sidebar: oklch(0.205 0 0);<br>  --sidebar-foreground: oklch(0.985 0 0);<br>  --sidebar-primary: oklch(0.488 0.243 264.376);<br>  --sidebar-primary-foreground: oklch(0.985 0 0);<br>  --sidebar-accent: oklch(0.269 0 0);<br>  --sidebar-accent-foreground: oklch(0.985 0 0);<br>  --sidebar-border: oklch(0.269 0 0);<br>  --sidebar-ring: oklch(0.439 0 0);<br>}<br><br>@theme inline {<br>  --color-background: var(--background);<br>  --color-foreground: var(--foreground);<br>  --color-card: var(--card);<br>  --color-card-foreground: var(--card-foreground);<br>  --color-popover: var(--popover);<br>  --color-popover-foreground: var(--popover-foreground);<br>  --color-primary: var(--primary);<br>  --color-primary-foreground: var(--primary-foreground);<br>  --color-secondary: var(--secondary);<br>  --color-secondary-foreground: var(--secondary-foreground);<br>  --color-muted: var(--muted);<br>  --color-muted-foreground: var(--muted-foreground);<br>  --color-accent: var(--accent);<br>  --color-accent-foreground: var(--accent-foreground);<br>  --color-destructive: var(--destructive);<br>  --color-destructive-foreground: var(--destructive-foreground);<br>  --color-border: var(--border);<br>  --color-input: var(--input);<br>  --color-ring: var(--ring);<br>  --color-chart-1: var(--chart-1);<br>  --color-chart-2: var(--chart-2);<br>  --color-chart-3: var(--chart-3);<br>  --color-chart-4: var(--chart-4);<br>  --color-chart-5: var(--chart-5);<br>  --radius-sm: calc(var(--radius) - 4px);<br>  --radius-md: calc(var(--radius) - 2px);<br>  --radius-lg: var(--radius);<br>  --radius-xl: calc(var(--radius) + 4px);<br>  --color-sidebar: var(--sidebar);<br>  --color-sidebar-foreground: var(--sidebar-foreground);<br>  --color-sidebar-primary: var(--sidebar-primary);<br>  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);<br>  --color-sidebar-accent: var(--sidebar-accent);<br>  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);<br>  --color-sidebar-border: var(--sidebar-border);<br>  --color-sidebar-ring: var(--sidebar-ring);<br>}<br><br>@layer base {<br>  * {<br>    @apply border-border outline-ring/50;<br>  }<br>  body {<br>    @apply bg-background text-foreground;<br>  }<br>}</pre><h3>Add the cn Utility Function</h3><p>Create this helper file:</p><p><strong>/packages/ui/src/lib/utils.ts</strong></p><pre>import { clsx, type ClassValue } from &quot;clsx&quot;<br>import { twMerge } from &quot;tailwind-merge&quot;<br><br>export function cn(...inputs: ClassValue[]) {<br>  return twMerge(clsx(inputs))<br>}</pre><p>This utility is used by most shadcn components to merge Tailwind class names correctly.</p><h3>Add components.json for shadcn</h3><p>Create the following file in the UI package root:</p><p><strong>/packages/ui/components.json</strong></p><pre>{<br>  &quot;$schema&quot;: &quot;https://ui.shadcn.com/schema.json&quot;,<br>  &quot;style&quot;: &quot;new-york&quot;,<br>  &quot;rsc&quot;: false,<br>  &quot;tsx&quot;: true,<br>  &quot;tailwind&quot;: {<br>    &quot;config&quot;: &quot;&quot;,<br>    &quot;css&quot;: &quot;src/styles/globals.css&quot;,<br>    &quot;baseColor&quot;: &quot;neutral&quot;,<br>    &quot;cssVariables&quot;: true,<br>    &quot;prefix&quot;: &quot;&quot;<br>  },<br>  &quot;aliases&quot;: {<br>    &quot;components&quot;: &quot;@repo/ui/components&quot;,<br>    &quot;ui&quot;: &quot;@repo/ui/components&quot;,<br>    &quot;utils&quot;: &quot;@repo/ui/lib/utils&quot;,<br>    &quot;lib&quot;: &quot;@repo/ui/lib&quot;,<br>    &quot;hooks&quot;: &quot;@repo/ui/hooks&quot;<br>  },<br>  &quot;iconLibrary&quot;: &quot;lucide&quot;<br>}</pre><h3>Important Tailwind Source Configuration</h3><p>To ensure Tailwind picks up classes used in the UI package, update <strong>globals.css</strong> again:</p><pre>@import &quot;tailwindcss&quot;;<br>@import &quot;tw-animate-css&quot;;<br><br>@source &quot;../../../../packages/ui/src/**/*.{js,ts,jsx,tsx}&quot;; /* Add This line */</pre><p>This prevents Tailwind from purging styles used in shared components.</p><h3>Adding shadcn Components</h3><p>From inside the UI package, you can now add components:</p><pre>bunx --bun shadcn@latest add button</pre><p>This will generate:</p><pre>src/components/button.tsx</pre><h3>Export UI Package Files</h3><p>Update <strong>/packages/ui/package.json</strong>:</p><pre>{<br>  &quot;exports&quot;: {<br>    &quot;./globals.css&quot;: &quot;./src/styles/globals.css&quot;,<br>    &quot;./postcss.config&quot;: &quot;./postcss.config.mjs&quot;,<br>    &quot;./lib/*&quot;: &quot;./src/lib/*.ts&quot;,<br>    &quot;./hooks/*&quot;: [<br>      &quot;./src/hooks/*.ts&quot;,<br>      &quot;./src/hooks/*.tsx&quot;<br>    ],<br>    &quot;./components/*&quot;: &quot;./src/components/*.tsx&quot;<br>  }<br>}</pre><h3>Using the UI Package in a Next.js App</h3><h3>Add the Dependency</h3><p>Inside your Next.js app (/apps/web), ensure @repo/ui is listed:</p><pre>{<br>  &quot;dependencies&quot;: {<br>    &quot;@repo/ui&quot;: &quot;*&quot;<br>  }<br>}</pre><p>Then install dependencies:</p><pre>bun install</pre><h3>Configure PostCSS in Next.js</h3><p>Create:</p><p><strong>/apps/web/postcss.config.mjs</strong></p><pre>export { default } from &quot;@repo/ui/postcss.config&quot;;</pre><h3>Update TypeScript Paths</h3><p>Modify <strong>/apps/web/tsconfig.json</strong>:</p><pre>{<br>  &quot;paths&quot;: {<br>    &quot;@/*&quot;: [&quot;./src/*&quot;],<br>    &quot;@repo/ui/*&quot;: [&quot;../../packages/ui/src/*&quot;]<br>  }<br>}</pre><h3>Update Next.js Configuration</h3><p>Edit <strong>/apps/web/next.config.ts</strong>:</p><pre>import type { NextConfig } from &quot;next&quot;;<br><br>const nextConfig: NextConfig = {<br>  transpilePackages: [&quot;@repo/ui&quot;],<br>};<br><br>export default nextConfig;</pre><p>This ensures Next.js properly transpiles the shared UI package.</p><h3>Add shadcn Config for the App</h3><p>Create:</p><p><strong>/apps/web/components.json</strong></p><pre>{<br>  &quot;$schema&quot;: &quot;https://ui.shadcn.com/schema.json&quot;,<br>  &quot;style&quot;: &quot;new-york&quot;,<br>  &quot;rsc&quot;: true,<br>  &quot;tsx&quot;: true,<br>  &quot;tailwind&quot;: {<br>    &quot;config&quot;: &quot;&quot;,<br>    &quot;css&quot;: &quot;../../packages/ui/src/styles/globals.css&quot;,<br>    &quot;baseColor&quot;: &quot;neutral&quot;,<br>    &quot;cssVariables&quot;: true<br>  },<br>  &quot;iconLibrary&quot;: &quot;lucide&quot;,<br>  &quot;aliases&quot;: {<br>    &quot;components&quot;: &quot;@/components&quot;,<br>    &quot;hooks&quot;: &quot;@/hooks&quot;,<br>    &quot;lib&quot;: &quot;@/lib&quot;,<br>    &quot;utils&quot;: &quot;@repo/ui/lib/utils&quot;,<br>    &quot;ui&quot;: &quot;@repo/ui/components&quot;<br>  }<br>}</pre><h3>Import Shared Global Styles</h3><p>Delete the default globals.css in your Next.js app and import the shared one in your root layout:</p><p><strong>/apps/web/app/layout.tsx</strong></p><pre>import &quot;@repo/ui/globals.css&quot;;</pre><h3>🎉 You’re All Set</h3><p>You can now use shadcn components directly from your shared UI package:</p><pre>import { Button, buttonVariants } from &quot;@repo/ui/components/button&quot;;</pre><p>This setup gives you:</p><ul><li>A clean Turborepo structure</li><li>Shared Tailwind styles</li><li>Centralized shadcn components</li><li>Full type safety across apps</li></ul><h4><strong>Sample repo : https://github.com/amirjld/turborepo-sample</strong></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d0535ea160f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Deploy a Next.js Application on a VPS + Nginx]]></title>
            <link>https://medium.com/@amirjld/how-to-deploy-a-next-js-application-on-a-vps-01ce7461dddc?source=rss-9f72c1e4b97b------2</link>
            <guid isPermaLink="false">https://medium.com/p/01ce7461dddc</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[vps]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[deployment]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Wed, 07 Jan 2026 16:47:21 GMT</pubDate>
            <atom:updated>2026-02-04T00:33:54.270Z</atom:updated>
            <content:encoded><![CDATA[<h4>Using Nginx, PM2, and npm (Production Guide)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OYMAYgXybjcCwZ-FwdaLlw.png" /></figure><p>Deploying a Next.js application to your own <strong>VPS</strong> gives you full control, lower long-term costs, and zero platform lock-in.</p><p>This guide walks through a <strong>production-ready setup</strong> using:</p><ul><li><strong>npm</strong> for dependencies</li><li><strong>PM2</strong> for process management</li><li><strong>Nginx</strong> as a reverse proxy</li><li>A Linux VPS (Ubuntu recommended)</li></ul><p>No Docker. No platform magic. Just a clean, reliable deployment.</p><h3>🧰 What You’ll Need</h3><p>Before starting, make sure you have:</p><ul><li>A VPS</li><li>Ubuntu 20.04+ installed</li><li>A domain name (optional but recommended)</li><li>SSH access with a non-root user</li></ul><h3>Tech Stack Overview</h3><ul><li><strong>Next.js</strong> (production build)</li><li><strong>Node.js</strong> (LTS)</li><li><strong>npm</strong></li><li><strong>PM2</strong> (process manager)</li><li><strong>Nginx</strong> (reverse proxy + SSL)</li></ul><h3>1️⃣ Connect to Your VPS</h3><pre>ssh user@your_server_ip</pre><h3>Update the system:</h3><pre>sudo apt update &amp;&amp; sudo apt upgrade -y</pre><h3>2️⃣ Install Node.js &amp; npm</h3><p>Install Node.js LTS (recommended via NodeSource):</p><pre>curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -<br>sudo apt install nodejs -y</pre><p>Verify installation:</p><pre>node -v<br>npm -v</pre><h3>3️⃣ Upload Your Next.js App</h3><p><strong>Clone from GitHub</strong></p><pre>git clone https://github.com/yourusername/your-nextjs-app.git<br>cd your-nextjs-app</pre><h3>4️⃣ Install Dependencies &amp; Build</h3><p>Inside your project directory:</p><pre>npm install<br>npm run build</pre><p>This creates the optimized production build.</p><h3>5️⃣ Start Next.js with PM2</h3><p>Install PM2 globally:</p><pre>sudo npm install -g pm2</pre><p>Start your app:</p><pre>pm2 start npm --name &quot;nextjs-app&quot; -- start</pre><p>Check status:</p><pre>pm2 status</pre><p>Enable auto-restart on server reboot:</p><pre>pm2 startup<br>pm2 save</pre><h3>6️⃣ Configure Nginx as a Reverse Proxy</h3><p>Install Nginx:</p><pre>sudo apt install nginx -y</pre><p>Create a new config file:</p><pre>sudo nano /etc/nginx/sites-available/nextjs-app</pre><p>Paste the following:</p><pre>server {<br>    listen 80;<br>    server_name yourdomain.com www.yourdomain.com;<br><br>    location / {<br>        proxy_pass http://localhost:3000;<br>        proxy_http_version 1.1;<br><br>        proxy_set_header Upgrade $http_upgrade;<br>        proxy_set_header Connection &#39;upgrade&#39;;<br>        proxy_set_header Host $host;<br>        proxy_set_header X-Real-IP $remote_addr;<br>        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>        proxy_set_header X-Forwarded-Proto $scheme;<br>        proxy_set_header X-Forwarded-Host $host;<br><br>        proxy_cache_bypass $http_upgrade;<br>    }<br>}</pre><p>Enable the site:</p><pre>sudo ln -s /etc/nginx/sites-available/nextjs-app /etc/nginx/sites-enabled/<br>sudo nginx -t<br>sudo systemctl restart nginx</pre><h3>7️⃣ Allow Firewall Access (Optional but Recommended)</h3><pre>sudo ufw allow OpenSSH<br>sudo ufw allow &#39;Nginx Full&#39;<br>sudo ufw enable</pre><h3>8️⃣ Add HTTPS with Let’s Encrypt (Free SSL)</h3><p>Install Certbot:</p><pre>sudo apt install certbot python3-certbot-nginx -y</pre><p>Generate SSL:</p><pre>sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com</pre><p>Auto-renew SSL:</p><pre>sudo certbot renew --dry-run</pre><h3>✅ Final Result</h3><p>Your Next.js app is now:</p><ul><li>Running via <strong>PM2</strong></li><li>Served through <strong>Nginx</strong></li><li>Secured with <strong>HTTPS</strong></li><li>Hosted on your own <strong>VPS</strong></li></ul><p>Visit:</p><pre>https://yourdomain.com</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01ce7461dddc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Server Actions in Next.js App Router: When & How to Use Them (Next.js 16 Edition)]]></title>
            <link>https://medium.com/@amirjld/server-actions-in-next-js-app-router-when-how-to-use-them-next-js-16-edition-9ed24a49ab4d?source=rss-9f72c1e4b97b------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ed24a49ab4d</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[server-action]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Sun, 04 Jan 2026 22:32:16 GMT</pubDate>
            <atom:updated>2026-01-04T22:32:16.628Z</atom:updated>
            <content:encoded><![CDATA[<p>Next.js has been steadily moving toward a <strong>simpler, more powerful full-stack model</strong>, and with <strong>Next.js 16</strong>, that vision is clearer than ever.</p><p>At the center of this shift are <strong>Server Actions</strong> — a feature that eliminates much of the boilerplate we’ve traditionally written for APIs, form submissions, and data mutations. Combined with Next.js 16’s <strong>new explicit caching system</strong>, Server Actions enable a cleaner, faster, and more predictable way to build modern web applications.</p><p>In this article, we’ll cover:</p><ul><li>What Server Actions are</li><li>When you should (and shouldn’t) use them</li><li>How they fit into the App Router</li><li>What’s new in Next.js 16 around caching</li><li>Practical examples and best practices</li></ul><h3>What Are Server Actions?</h3><p><strong>Server Actions</strong> are asynchronous functions that always run on the server but can be triggered directly from your React components — including client components.</p><p>They remove the need for:</p><ul><li>Custom API routes</li><li>Client-side fetch calls for mutations</li><li>Manual serialization and error handling</li></ul><p>You define them using a simple directive:</p><pre>&#39;use server&#39;</pre><p>Once defined, Server Actions can be passed directly to a &lt;form&gt; or invoked from a client component — and Next.js handles the network layer for you.</p><h3>Why Server Actions Matter</h3><p>Server Actions solve a long-standing problem in full-stack React:</p><blockquote>“Why do we need to build an API just to submit a form?”</blockquote><p>With Server Actions:</p><ul><li>Business logic lives on the server</li><li>Sensitive code never reaches the browser</li><li>The UI stays declarative and minimal</li><li>They are especially useful for:</li><li>Creating, updating, and deleting data</li><li>Handling form submissions</li><li>Triggering cache invalidation</li><li>Coordinating UI updates after mutations</li></ul><h3>Server Actions in the App Router</h3><p>The <strong>App Router</strong> (/app) is built around <strong>React Server Components (RSC)</strong>. Server Actions are a natural extension of this architecture.</p><h3>Typical Flow</h3><ol><li>Server Component fetches data</li><li>UI renders</li><li>User submits a form or triggers an action</li><li>Server Action runs</li><li>Cache is revalidated</li><li>UI updates automatically</li></ol><p>No API routes. No client-side data mutation logic.</p><h3>Basic Server Action Example</h3><pre>// app/actions/create-post.ts<br>export async function createPost(formData: FormData) {<br>  &#39;use server&#39;;<br><br>  await db.post.create({<br>    data: {<br>      title: formData.get(&#39;title&#39;),<br>      content: formData.get(&#39;content&#39;),<br>    },<br>  });<br>}</pre><p>Usage in a component:</p><pre>&lt;form action={createPost}&gt;<br>  &lt;input name=&quot;title&quot; /&gt;<br>  &lt;textarea name=&quot;content&quot; /&gt;<br>  &lt;button type=&quot;submit&quot;&gt;Publish&lt;/button&gt;<br>&lt;/form&gt;</pre><p>This is already production-ready — no API routes required.</p><h3>What’s New in Next.js 16: Explicit Caching</h3><p>One of the biggest changes in <strong>Next.js 16</strong> is how caching works.</p><h3>🔄 Before</h3><p>Caching was often implicit and confusing.</p><h3>✅ Now</h3><p>Caching is <strong>explicit and opt-in</strong>.</p><p>By default, everything is <strong>dynamic</strong> unless you explicitly cache it.</p><h3>Using use cache</h3><p>Next.js 16 introduces the use cache directive to explicitly mark functions or components as cacheable.</p><pre>&#39;use cache&#39;;<br><br>export async function getPosts() {<br>  return fetch(&#39;https://example.com/posts&#39;).then(res =&gt; res.json());<br>}</pre><p>This makes the behavior predictable and easier to reason about — a major improvement for large applications.</p><h3>Cache Tags &amp; Revalidation (Game Changer)</h3><p>Next.js 16 also introduces <strong>tag-based cache invalidation</strong>, which pairs perfectly with Server Actions.</p><h3>Cache with Tags</h3><pre>import { cacheTag } from &#39;next/cache&#39;;<br><br>export async function getPosts() {<br>  &#39;use cache&#39;;<br>  cacheTag(&#39;posts&#39;);<br>  return fetch(&#39;/api/posts&#39;).then(res =&gt; res.json());<br>}</pre><h3>Revalidate from a Server Action</h3><pre>import { revalidateTag } from &#39;next/cache&#39;;<br><br>export async function createPost(data) {<br>  &#39;use server&#39;;<br><br>  await db.post.create(data);<br>  revalidateTag(&#39;posts&#39;);<br>}</pre><p>This ensures:</p><ul><li>Only relevant cache entries are invalidated</li><li>The UI updates immediately</li><li>Performance remains optimal</li></ul><h3>When Should You Use Server Actions?</h3><h3>✅ Use Server Actions When:</h3><ul><li>You need to mutate data</li><li>You’re handling forms</li><li>You want tight integration with caching</li><li>You want to avoid unnecessary API layers</li></ul><h3>❌ Avoid Server Actions When:</h3><ul><li>You need a public API</li><li>You’re building a mobile client</li><li>You need WebSocket or long-lived connections</li></ul><p>Server Actions are <strong>not a replacement for APIs</strong>, but they are a superior choice for <strong>internal app logic</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ed24a49ab4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Implement PWA ( Progressive Web App) in Next.js App router 2026]]></title>
            <link>https://medium.com/@amirjld/how-to-implement-pwa-progressive-web-app-in-next-js-app-router-2026-f25a6797d5e6?source=rss-9f72c1e4b97b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f25a6797d5e6</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[progressive-web-app]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Sun, 04 Jan 2026 09:57:38 GMT</pubDate>
            <atom:updated>2026-01-04T09:58:29.768Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post we will implement the PWA in our Next.js App without using any 3rd party packages.</p><p><strong>Lets get straight to the point</strong></p><p><strong>1.Create Your Next.js App</strong></p><pre>npx create-next-app@latest my-app --yes</pre><ul><li>--yes skips prompts using saved preferences or defaults. The default setup enables TypeScript, Tailwind, ESLint, App Router, and Turbopack, with import alias @/*.</li></ul><p><strong>2.Create Manifest File</strong></p><p>Next.js provides built-in support for creating a <a href="https://nextjs.org/docs/app/api-reference/file-conventions/metadata/manifest">web app manifest</a> using the App Router. You can create either a static or dynamic manifest file</p><p>For example, create a app/manifest.ts or app/manifest.json file</p><pre>import type { MetadataRoute } from &#39;next&#39;<br> <br>export default function manifest(): MetadataRoute.Manifest {<br>  return {<br>    name: &#39;Next.js PWA&#39;,<br>    short_name: &#39;NextPWA&#39;,<br>    description: &#39;A Progressive Web App built with Next.js&#39;,<br>    start_url: &#39;/&#39;,<br>    display: &#39;standalone&#39;,<br>    background_color: &#39;#ffffff&#39;,<br>    theme_color: &#39;#000000&#39;,<br>    icons: [<br>      {<br>        src: &#39;/icon-192x192.png&#39;,<br>        sizes: &#39;192x192&#39;,<br>        type: &#39;image/png&#39;,<br>      },<br>      {<br>        src: &#39;/icon-512x512.png&#39;,<br>        sizes: &#39;512x512&#39;,<br>        type: &#39;image/png&#39;,<br>      },<br>    ],<br>  }<br>}</pre><p>This file should contain information about the name, icons, and how it should be displayed as an icon on the user’s device. This will allow users to install your PWA on their home screen, providing a native app-like experience.</p><p><strong>NOTE : To ensure your application can be installed to a mobile home screen, you must have:</strong></p><ol><li><strong>A valid web app manifest</strong></li><li><strong>The website served over HTTPS</strong></li></ol><p><strong>Modern browsers will automatically show an installation prompt to users when these criteria are met. You can provide a custom installation button with </strong><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeinstallprompt_event"><strong>beforeinstallprompt</strong></a><strong>, however, we do not recommend this as it is not cross browser and platform (does not work on Safari iOS).</strong></p><p>For Testing Locally + HTTPS use this command<br> next dev --experimental-https</p><p>Thats it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f25a6797d5e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top 5 UI Libraries to Build Stunning Interfaces Faster P2]]></title>
            <link>https://medium.com/@amirjld/top-5-ui-libraries-to-build-stunning-interfaces-faster-p2-7386a3075f18?source=rss-9f72c1e4b97b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7386a3075f18</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[shadcn]]></category>
            <category><![CDATA[ui-library]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Fri, 02 Jan 2026 23:57:37 GMT</pubDate>
            <atom:updated>2026-01-05T00:33:50.674Z</atom:updated>
            <content:encoded><![CDATA[<p>Choosing the right UI library can save you hundreds of hours. Here’s my breakdown of the next top 5 contenders to consider for your next project.</p><p><strong>Lets get straight to the point.</strong></p><p><strong>1.</strong><a href="https://www.cult-ui.com/"><strong>Cult UI</strong></a></p><p>Free and open source components. Shadcn compatible blocks, full stack nextjs templates and more. Built by design engineers, configured for vibe coding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZGCax73hW12qgXriG11BKg.png" /></figure><p><a href="https://evilcharts.com/"><strong>2.Evil Charts</strong></a></p><p>Explore the world of charts with EvilCharts. Animated &amp; Interactive charts for your next project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rGClrDKpaxJs6X3dlJZ2AQ.png" /></figure><p><a href="https://efferd.com/"><strong>3.Efferd</strong></a></p><p>Save hours of design time with clean, ready-to-use shadcn blocks<br>that just work — modern, responsive, and built for speed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*njqioufAXou13x0de7QkLA.png" /></figure><p><a href="https://www.solaceui.com/"><strong>4.Solace UI</strong></a></p><p>Production-ready sections, animated components, and full-page templates for Next.js, Tailwind CSS &amp; Framer Motion</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Km9-vE3uRIBAPM5aI1RTIg.png" /></figure><p><a href="https://www.fancycomponents.dev/"><strong>5.Fancy Components</strong></a></p><p>with a growing library of ready-to-use react components &amp; microinteractions. free &amp; open source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IBSPMGQw42neI16sR_hVyg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7386a3075f18" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top 5 UI Libraries to Build Stunning Interfaces Faster]]></title>
            <link>https://medium.com/@amirjld/top-5-ui-libraries-to-build-stunning-interfaces-faster-4c9431b97a8b?source=rss-9f72c1e4b97b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c9431b97a8b</guid>
            <category><![CDATA[shadcn]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ui-library]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Fri, 02 Jan 2026 00:22:03 GMT</pubDate>
            <atom:updated>2026-01-02T00:22:03.247Z</atom:updated>
            <content:encoded><![CDATA[<p>Choosing the right UI library can save you hundreds of hours. Here’s my breakdown of the top 5 contenders to consider for your next project.</p><p><strong>Lets get straight to the point.</strong></p><ol><li><a href="https://ui.shadcn.com/"><strong>Shadcn</strong></a></li></ol><p>Forget heavy frameworks. shadcn isn’t a traditional library — it’s a collection of beautifully designed, copy-paste React components you own and fully control.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C7kWSGYNHJ_9sy8CFLCrbg.png" /></figure><p>2. <a href="https://www.rigidui.com/"><strong>RigidUI</strong></a></p><p>Professional <em>Powerful components</em> that scale with your<strong> needs</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JSWgd_CpEyLnnMVKiKJjsQ.png" /></figure><p>3. <a href="https://www.kibo-ui.com/"><strong>Kibo UI</strong></a></p><p>Kibo UI is a custom registry of composable, accessible and extensible components designed for use with shadcn/ui. Free and open source, forever.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Ru7VrG9UlXH6KKv2hwftw.png" /></figure><p>4. <a href="https://coss.com/ui"><strong>Coss UI</strong></a></p><p>A new, modern UI component library built on top of Base UI. Built for developers and AI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F9pSWta2IA2G6KuLPZnqVw.png" /></figure><p>5. <a href="https://kokonutui.com/"><strong>Kokonut UI</strong></a></p><p>100+ Beautiful, modern UI components built with Tailwind CSS, shadcn/ui, and Motion to use on your Websites.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7tD-C3mm-Vrg4eGz0oqQtA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c9431b97a8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Complete Guide to Google Auth & One-Tap in Next.js Using Better Auth + MongoDB]]></title>
            <link>https://medium.com/@amirjld/a-complete-guide-to-google-auth-one-tap-in-next-js-using-better-auth-mongodb-ebe2de45c691?source=rss-9f72c1e4b97b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebe2de45c691</guid>
            <category><![CDATA[better-auth]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Wed, 03 Dec 2025 23:05:46 GMT</pubDate>
            <atom:updated>2025-12-03T23:05:46.242Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn how to integrate Better Auth with Google Login and One Tap to create a smooth, modern authentication flow in your Next.js application.</h4><p>Lets get straight to the point.</p><p><strong>1.Install the better auth package using Bun , Npm or what ever you want.</strong></p><pre>bun add better-auth</pre><p><strong>2.Create an auth object</strong></p><pre>// src/lib/auth.js<br><br>import mongoose from &quot;mongoose&quot;;<br>import connectDB from &quot;@/server/db&quot;;<br><br>import { betterAuth } from &quot;better-auth&quot;;<br>import { mongodbAdapter } from &quot;better-auth/adapters/mongodb&quot;;<br>import { oneTap } from &quot;better-auth/plugins&quot;;<br><br>let dbInstance;<br>let clientInstance;<br><br>// Lazily initialize the MongoDB connection (prevents multiple connections)<br>const getMongoDBInstances = async () =&gt; {<br>  if (!dbInstance || !clientInstance) {<br>    await connectDB(); // ensures mongoose connection is created<br>    clientInstance = mongoose.connection.getClient(); // get raw Mongo client<br>    dbInstance = clientInstance.db(); // get DB instance<br>  }<br>  return { db: dbInstance, client: clientInstance };<br>};<br><br>const { db, client } = await getMongoDBInstances();<br><br>export const auth = betterAuth({<br>  // MongoDB adapter — handles user, session, and account storage<br>  database: mongodbAdapter(db, {<br>    client,<br>    collectionNames: {<br>      user: &quot;users&quot;,<br>      session: &quot;sessions&quot;,<br>      account: &quot;accounts&quot;,<br>    },<br>  }),<br><br>  // Enable email + password login<br>  emailAndPassword: {<br>    enabled: true, // optional, can remove if only social auth is used<br>  },<br><br>  // Social provider: Google OAuth<br>  socialProviders: {<br>    google: {<br>      clientId: process.env.GOOGLE_CLIENT_ID,<br>      clientSecret: process.env.GOOGLE_CLIENT_SECRET,<br><br>      // Normalize Google profile structure → Better Auth user fields<br>      async profile(profile) {<br>        return {<br>          id: profile.id,<br>          email: profile.email,<br>          name: profile.name,<br>          image: profile.picture,<br>        };<br>      },<br>    },<br>  },<br><br>  // Session handling (7 days expiry)<br>  session: {<br>    expiresIn: 60 * 60 * 24 * 7, // refresh window<br>    updateAge: 60 * 60 * 24, // extend session every 24h<br>    cookieCache: {<br>      enabled: true,<br>      maxAge: 5 * 60, // tiny optimization for fewer DB reads<br>    },<br>  },<br><br>  // How user fields map to your MongoDB schema<br>  user: {<br>    fields: {<br>      email: &quot;email&quot;,<br>      name: &quot;fullName&quot;, // maps to your schema field<br>      image: &quot;image&quot;,<br>    },<br>    modelName: &quot;users&quot;, // points to the &quot;users&quot; collection<br>  },<br><br>  // Allowed frontend origins (required for One Tap)<br>  trustedOrigins: [<br>    process.env.NEXT_PUBLIC_BASE_URL,<br>    &quot;http://localhost&quot;,<br>  ],<br><br>  // Public base URL of your app<br>  baseURL: process.env.NEXT_PUBLIC_BASE_URL,<br><br>  // Secret key for signing sessions/JWTs<br>  secret: process.env.BETTER_AUTH_SECRET || process.env.JWT_SECRET,<br><br>  appName: &quot;YOUR APP NAME&quot;,<br><br>  // Enable Google One Tap<br>  plugins: [oneTap()],<br>});</pre><p><strong>3.Now Configure the API route</strong></p><pre>// src/app/api/auth/[...all]/route.js<br><br>import { auth } from &quot;@/lib/auth&quot;;<br>import { toNextJsHandler } from &quot;better-auth/next-js&quot;;<br><br>export const { GET, POST } = toNextJsHandler(auth);</pre><p><strong>4.Connect DB function + model design</strong></p><pre>// Simple function to connect to the databasae<br><br>import mongoose from &quot;mongoose&quot;;<br><br>const connectDB = async () =&gt; {<br>  if (mongoose.connection.readyState &gt;= 1) return;<br><br>  try {<br>    await mongoose.connect(process.env.MONGODB_URI);<br>    console.log(&quot;Connected to DB.&quot;);<br>  } catch (error) {<br>    console.error(&quot;Error connecting to DB:&quot;, error);<br>  }<br>};<br><br>export default connectDB;</pre><pre>// User model <br><br>import mongoose from &quot;mongoose&quot;;<br><br>const schema = new mongoose.Schema(<br>  {<br>    fullName: {<br>      type: String,<br>      required: true,<br>      trim: true,<br>    },<br>    email: {<br>      type: String,<br>      unique: true,<br>      required: true,<br>      lowercase: true,<br>      trim: true,<br>    },<br>    password: {<br>      type: String,<br>      default: &quot;&quot;,<br>    },<br>    image: {<br>      type: String,<br>    },<br>    googleId: {<br>      type: String,<br>      unique: true,<br>      sparse: true,<br>    },<br>  },<br>  {<br>    timestamps: true,<br>  }<br>);<br><br>export default mongoose.models.User || mongoose.model(&quot;User&quot;, schema);</pre><p><strong>5. Create Auth client</strong></p><pre>// src/lib/auth-client.js<br><br>import { createAuthClient } from &quot;better-auth/react&quot;;<br>import { oneTapClient } from &quot;better-auth/client/plugins&quot;;<br><br>const GOOGLE_CLIENT_ID = &quot;YOUR_GOOGLE_CLIENT_ID&quot;;<br><br>export const authClient = createAuthClient({<br>  baseURL: process.env.NEXT_PUBLIC_BASE_URL // your website url,<br>  plugins: [<br>    oneTapClient({<br>      clientId: GOOGLE_CLIENT_ID,<br>      autoSelect: true,<br>      cancelOnTapOutside: false,<br>      context: &quot;signin&quot;,<br>      uxMode: &quot;popup&quot;,<br>      promptOptions: {<br>        baseDelay: 3000,<br>        maxAttempts: 5,<br>      },<br>    }),<br>  ],<br>});<br><br>export const {<br>  signIn,<br>  signUp,<br>  signOut,<br>  useSession,<br>  forgetPassword,<br>  resetPassword,<br>  verifyEmail,<br>  requestPasswordReset,<br>} = authClient;</pre><p><strong>6. Use auth client to sign in or sign up users</strong></p><pre>await signIn.email({<br>        email: &quot;EMAIL@gmail.com&quot;,<br>        password: &quot;PASSWORD&quot;,<br>        callbackURL: &quot;/dashboard&quot; , // after login<br>});</pre><pre>await signUp.email({<br>        email: &quot;EMAIL@gmail.com&quot;,<br>        password: &quot;PASSWORD&quot;,<br>        callbackURL: &quot;/dashboard&quot; , // after login<br>});</pre><pre>// to login with google use <br><br>await signIn.social({<br>        provider: &quot;google&quot;,<br>        callbackURL: &quot;/dashboard&quot; ,<br>});</pre><p><strong>MAKE SURE YOU HAVE THESE IN YOUR .env FILE</strong></p><pre>BETTER_AUTH_SECRET=mysecret -&gt; Use some strong secret key<br>BETTER_AUTH_URL=http://localhost:3000 -&gt; Your Website url</pre><p><strong>IMPLEMENT THE ONE TAP POPUP</strong></p><pre>&quot;use client&quot;;<br><br>import { authClient, useSession } from &quot;@/lib/auth-client&quot;;<br>import { useEffect, useRef } from &quot;react&quot;;<br><br>const OneTap = () =&gt; {<br>  const oneTapInitialized = useRef(false);<br><br>  const { data, isPending } = useSession();<br><br>  useEffect(() =&gt; {<br>    // do not show the popup if the user is already logged in<br>    if (data?.user || isPending || oneTapInitialized.current) return;<br><br>    const triggerOneTap = async () =&gt; {<br>      oneTapInitialized.current = true;<br><br>      try {<br>        await authClient.oneTap({<br>          fetchOptions: {<br>            onSuccess: (context) =&gt; {<br>              if (context?.data?.user) {<br>                window.location.reload();<br>              }<br>            },<br>            onError: (context) =&gt; {<br>              console.error(&quot;OneTap authentication failed:&quot;, context.error);<br>              oneTapInitialized.current = false;<br>            },<br>          },<br>        });<br>      } catch (error) {<br>        console.error(&quot;OneTap initialization failed:&quot;, error);<br>        oneTapInitialized.current = false;<br>      }<br>    };<br><br>    triggerOneTap();<br>  }, [data?.user, isPending]);<br><br>  return null;<br>};<br><br>export default OneTap;</pre><p>Now use this OneTap component in your root layout and Thats it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebe2de45c691" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>