<?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 Ayodya Banuka Fernando on Medium]]></title>
        <description><![CDATA[Stories by Ayodya Banuka Fernando on Medium]]></description>
        <link>https://medium.com/@ayodyabanukafernando?source=rss-30a664cf7d25------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*oiETG4iCwRYTLkgMLRbExg.jpeg</url>
            <title>Stories by Ayodya Banuka Fernando on Medium</title>
            <link>https://medium.com/@ayodyabanukafernando?source=rss-30a664cf7d25------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 20:08:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ayodyabanukafernando/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[ Building Custom JWT Auth in Next.js]]></title>
            <link>https://ayodyabanukafernando.medium.com/building-custom-jwt-auth-in-next-js-03e30ca6f42d?source=rss-30a664cf7d25------2</link>
            <guid isPermaLink="false">https://medium.com/p/03e30ca6f42d</guid>
            <dc:creator><![CDATA[Ayodya Banuka Fernando]]></dc:creator>
            <pubDate>Tue, 22 Jul 2025 15:59:32 GMT</pubDate>
            <atom:updated>2025-07-22T15:59:32.757Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mY0gd0FBbufAZbSfU0SncQ.png" /></figure><h3>🔐 Building Custom JWT Auth in Next.js Without Firebase — Introducing @ayodyabanuka/next-auth-custom</h3><blockquote><em>A flexible authentication helper for Next.js App Router projects with full control over your auth flow, token rotation, and cookie management.</em></blockquote><h3>👋 Hello developers,</h3><p>If you’ve ever built a <strong>Next.js</strong> app and wanted full control over <strong>authentication</strong>, you’ve probably wrestled with questions like:</p><ul><li>“How do I create secure JWT tokens?”</li><li>“How do I store them in HttpOnly cookies?”</li><li>“What’s the best way to refresh tokens and protect routes?”</li><li>“I don’t want to use Firebase Auth or NextAuth.js — I want control.”</li></ul><p>That’s exactly why I created <strong>@ayodyabanuka/next-auth-custom</strong> — a fully customizable, developer-friendly library that lets you build your own JWT-based authentication layer in <strong>Next.js 13/14+ (App Router)</strong>.</p><h3>✨ Why I Built This</h3><p>Modern apps need more than just simple login. We want:</p><ul><li>Secure token generation &amp; validation</li><li>Route protection (both API and pages)</li><li>Refresh token support</li><li>Cookie-based session handling</li><li>Device or session tracking</li></ul><p>But using a rigid auth framework can be limiting. With @ayodyabanuka/next-auth-custom, you get the <strong>tools to build a custom auth system</strong>, tailored for your stack — whether you&#39;re using Firestore, PostgreSQL, MongoDB, or any other backend.</p><h3>🔧 Key Features</h3><ul><li>✅ <strong>Custom JWT Access + Refresh Tokens</strong></li><li>🍪 <strong>HttpOnly Cookie Storage</strong> for secure session handling</li><li>🔄 <strong>Token Rotation Support</strong> (optional)</li><li>🛡️ <strong>Route Middleware Protection</strong></li><li>🧱 <strong>Database-Agnostic</strong> (use any DB: Firestore, Prisma, etc.)</li><li>⚡ <strong>Next.js App Router Compatible</strong></li><li>📱 <strong>Optional Device-Based Session Management</strong></li><li>🧑‍💻 Written in <strong>TypeScript</strong> with full DX in mind</li></ul><h3>🚀 Installation</h3><pre>npm install @ayodyabanuka/next-auth-custom</pre><h3>🧪 Quick Example</h3><pre>import {<br>  createAuthService,<br>  createDefaultAuthConfig,<br>  CookieUtil,<br>} from &#39;@ayodyabanuka/next-auth-custom&#39;;</pre><pre>const config = createDefaultAuthConfig({<br>  jwtSecret: process.env.JWT_SECRET!,<br>  jwtRefreshSecret: process.env.JWT_REFRESH_SECRET!,<br>});</pre><pre>const cookieUtil = new CookieUtil();<br>const authService = createAuthService(config, yourDatabaseAdapter);</pre><pre>// In your API route<br>const result = await authService.login({ email, password });<br>const response = NextResponse.json({ success: true });<br>cookieUtil.setAuthCookies(response, result.session.accessToken, result.session.refreshToken);</pre><h3>🗂️ File Structure Integration</h3><p>Here’s how you’d typically integrate this package in a real-world Next.js App Router project:</p><pre>/lib<br>  └── auth-config.ts<br>  └── database-adapter.ts<br>  └── auth-service.ts<br>/api/auth<br>  └── login/route.ts<br>  └── register/route.ts<br>  └── refresh/route.ts<br>  └── logout/route.ts<br>/middleware.ts</pre><blockquote><em>The package ships with built-in cookie utilities, token generators, middleware factory, and TypeScript types to make setup fast and clean.</em></blockquote><h3>🔒 Secure by Design</h3><p>Security is a top priority. This package handles:</p><ul><li>HttpOnly + Secure cookies (prevents XSS)</li><li>Refresh token validation against the database</li><li>Token expiry &amp; rotation</li><li>Optional device/session tracking</li><li>SSR-safe usage with App Router</li></ul><h3>📘 API Reference</h3><p>The library provides:</p><ul><li>createAuthService() — register, login, refresh, logout</li><li>createDefaultAuthConfig() — easy-to-extend config</li><li>JWTUtil — standalone JWT helper class</li><li>CookieUtil — simplified cookie handling for NextRequest/NextResponse</li><li>createAuthMiddleware() — protect routes via JWT middleware</li><li>Strongly typed interfaces: User, AuthConfig, DatabaseAdapter</li></ul><h3>🔄 Token Flow Diagram</h3><pre>Login → Access + Refresh tokens (stored in cookies)<br>       ↓<br>Protected Route → Uses access token via middleware<br>       ↓<br>Access Token Expires → Refresh API → New token pair issued<br>       ↓<br>Logout → Refresh token revoked, cookies cleared</pre><h3>🔧 Database Integration</h3><p>You just need to implement the DatabaseAdapter interface to hook into your DB:</p><pre>class MyAdapter implements DatabaseAdapter {<br>  async findUserByEmail() { ... }<br>  async validateRefreshToken() { ... }<br>  async revokeAllUserTokens() { ... }<br>  // etc.<br>}</pre><p>✅ Works great with Firestore, Prisma (PostgreSQL), Supabase, or even in-memory stores for prototyping.</p><h3>📚 Example Projects</h3><p>You can use this package to:</p><ul><li>Build a <strong>SaaS dashboard</strong></li><li>Secure an <strong>admin portal</strong></li><li>Add login/logout to <strong>e-commerce backends</strong></li><li>Protect <strong>Next.js API routes</strong></li></ul><h3>📦 Publish Ready</h3><p>The package is structured and published under:</p><p>🔗 npmjs.com/package/@ayodyabanuka/next-auth-custom</p><h3>🧠 Future Improvements</h3><p>I’m actively improving this library, with plans to add:</p><ul><li>Built-in support for OAuth2 strategies</li><li>Session expiry notifications</li><li>Magic link &amp; passwordless login</li></ul><h3>🤝 Contribute or Use It</h3><p>If you’re tired of rigid auth libraries or want full control over your security setup, give this a try.</p><p>Contributions are welcome, and I’d love to hear your feedback!<br> Star, fork, or use it in your own projects.</p><p>🔗 <a href="https://github.com/ayodyabanuka/next-auth-custom.git">https://github.com/ayodyabanuka/next-auth-custom.git</a><br> 📦 NPM Package</p><p>Thanks for reading 🙌<br> Let’s keep building tools that empower developers!</p><p>— <strong>Ayodya Banuka (AB)</strong><br> Software Engineer</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=03e30ca6f42d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Harnessing the Power of Redux in a Next.js Project]]></title>
            <link>https://ayodyabanukafernando.medium.com/harnessing-the-power-of-redux-in-a-next-js-project-04650b0a5a68?source=rss-30a664cf7d25------2</link>
            <guid isPermaLink="false">https://medium.com/p/04650b0a5a68</guid>
            <category><![CDATA[articles]]></category>
            <category><![CDATA[learning-and-development]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[abs]]></category>
            <dc:creator><![CDATA[Ayodya Banuka Fernando]]></dc:creator>
            <pubDate>Sat, 29 Jun 2024 10:34:23 GMT</pubDate>
            <atom:updated>2024-06-29T10:35:33.113Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QHkcOgwe8CyuciJMb4B8fg.png" /></figure><p>Next.js has quickly become a favorite among developers for building robust, server-rendered React applications. One of the common requirements for large-scale applications is state management, and Redux is a powerful library that helps manage state in a predictable manner. In this article, we’ll explore how to integrate Redux into a Next.js project with sample code to guide you through the process.</p><h3>Why Use Redux with Next.js?</h3><p>Redux provides a centralized store for managing the state of your application, which can be particularly useful in complex applications where state management becomes challenging. When combined with Next.js, Redux can help you manage state across different pages, components, and even server-side rendering (SSR).</p><h3>Setting Up a Next.js Project with Redux</h3><p>Let’s walk through setting up a Next.js project with Redux from scratch.</p><h3>Step 1: Initialize a Next.js Project</h3><p>First, create a new Next.js project if you haven’t already:</p><pre>npx create-next-app my-nextjs-redux-app<br>cd my-nextjs-redux-app</pre><h3>Step 2: Install Redux and Related Libraries</h3><p>Install Redux, React-Redux, and Redux Toolkit:</p><pre>npm install @reduxjs/toolkit react-redux</pre><h3>Step 3: Create the Redux Store</h3><p>Create a store.js file in your project. This file will set up the Redux store using Redux Toolkit’s configure store method:</p><pre>// store.js<br>import { configureStore } from &#39;@reduxjs/toolkit&#39;;<br>import { createSlice } from &#39;@reduxjs/toolkit&#39;;<br>const counterSlice = createSlice({<br>  name: &#39;counter&#39;,<br>  initialState: { value: 0 },<br>  reducers: {<br>    increment: (state) =&gt; {<br>      state.value += 1;<br>    },<br>    decrement: (state) =&gt; {<br>      state.value -= 1;<br>    },<br>    reset: (state) =&gt; {<br>      state.value = 0;<br>    },<br>  },<br>});<br>export const { increment, decrement, reset } = counterSlice.actions;<br>const store = configureStore({<br>  reducer: {<br>    counter: counterSlice.reducer,<br>  },<br>});<br>export default store;</pre><h3>Step 4: Set Up the Redux Provider</h3><p>Wrap your application with the Redux Provider in the _app.js or layout.tsx file. This will make the Redux store available to your entire application:</p><pre>// pages/_app.js<br>import { Provider } from &#39;react-redux&#39;;<br>import store from &#39;../store&#39;;<br>import &#39;../styles/globals.css&#39;;<br>function MyApp({ Component, pageProps }) {<br>  return (<br>    &lt;Provider store={store}&gt;<br>      &lt;Component {...pageProps} /&gt;<br>    &lt;/Provider&gt;<br>  );<br>}<br>export default MyApp;</pre><h3>Step 5: Create a Counter Component</h3><p>Create a simple counter component that uses Redux for state management:</p><pre>// components/Counter.js<br>import { useSelector, useDispatch } from &#39;react-redux&#39;;<br>import { increment, decrement, reset } from &#39;../store&#39;;<br>const Counter = () =&gt; {<br>  const count = useSelector((state) =&gt; state.counter.value);<br>  const dispatch = useDispatch();<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Counter: {count}&lt;/h1&gt;<br>      &lt;button onClick={() =&gt; dispatch(increment())}&gt;Increment&lt;/button&gt;<br>      &lt;button onClick={() =&gt; dispatch(decrement())}&gt;Decrement&lt;/button&gt;<br>      &lt;button onClick={() =&gt; dispatch(reset())}&gt;Reset&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>};<br>export default Counter;</pre><h3>Step 6: Use the Counter Component</h3><p>Finally, use the Counter component in one of your pages:</p><pre>// pages/index.js<br>import Counter from &#39;../components/Counter&#39;;<br>export default function Home() {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Welcome to Next.js with Redux&lt;/h1&gt;<br>      &lt;Counter /&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><h3>Server-Side Rendering with Redux</h3><p>One of the key benefits of Next.js is its support for server-side rendering. You can also integrate Redux with SSR in Next.js. Here’s an example of how to fetch initial state server-side and pass it to the Redux store:</p><pre>// pages/index.js<br>import { useDispatch, useSelector } from &#39;react-redux&#39;;<br>import { useEffect } from &#39;react&#39;;<br>import { increment, decrement, reset } from &#39;../store&#39;;<br>import Counter from &#39;../components/Counter&#39;;<br>export default function Home({ initialReduxState }) {<br>  const dispatch = useDispatch();<br>  useEffect(() =&gt; {<br>    // Initialize state or dispatch actions if necessary<br>  }, [dispatch]);<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Welcome to Next.js with Redux&lt;/h1&gt;<br>      &lt;Counter /&gt;<br>    &lt;/div&gt;<br>  );<br>}<br>export async function getServerSideProps() {<br>  // Fetch data or perform server-side logic<br>  const initialReduxState = { counter: { value: 5 } };<br>  return {<br>    props: {<br>      initialReduxState,<br>    },<br>  };<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=04650b0a5a68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Android 15 Beta 2.2: What’s New and Why It Matters]]></title>
            <link>https://ayodyabanukafernando.medium.com/exploring-android-15-beta-2-2-whats-new-and-why-it-matters-2f23c91f01e5?source=rss-30a664cf7d25------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f23c91f01e5</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mobile-update]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Ayodya Banuka Fernando]]></dc:creator>
            <pubDate>Thu, 13 Jun 2024 18:38:55 GMT</pubDate>
            <atom:updated>2024-06-13T18:38:55.272Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QbtpdW6bQvb0XpJtmQn8wg.png" /></figure><p>The tech world is abuzz with the release of Android 15 Beta 2.2, the latest iteration in Google’s evolving mobile operating system. As developers, tech enthusiasts, and industry professionals, we stand on the precipice of transformative updates that promise to enhance user experience, security, and performance. Let’s dive into what Android 15 Beta 2.2 brings to the table and why it’s a significant step forward.</p><h3>Enhanced User Interface and Experience</h3><p>One of the most noticeable changes in Android 15 Beta 2.2 is the refined user interface. Google has taken a minimalist yet functional approach, emphasizing simplicity and ease of navigation. The updates include:</p><ol><li>Dynamic Theming: Building on Material You, the dynamic theming feature now offers more customization options, allowing users to personalize their devices with even more precision.</li><li>Gesture Navigation Improvements: The gesture navigation system has been fine-tuned for smoother interactions, reducing accidental swipes and improving overall usability.</li><li>Revamped Notifications: Notifications are now smarter and more context-aware, providing relevant actions and responses directly within the notification shade.</li></ol><h3>Performance Boosts</h3><p>Performance enhancements are at the core of Android 15 Beta 2.2. Google has focused on optimizing system resources, leading to:</p><ol><li>Faster App Launch Times: Applications now open quicker, thanks to under-the-hood optimizations and better memory management.</li><li>Battery Efficiency: Improved power management algorithms help extend battery life without sacrificing performance, ensuring that users can rely on their devices for longer periods.</li><li>Smoother Animations: Enhanced rendering and animation techniques make interactions feel more fluid and responsive.</li></ol><h3>Security and Privacy Upgrades</h3><p>In today’s digital age, security and privacy are paramount. Android 15 Beta 2.2 introduces several key features to protect user data and ensure privacy:</p><ol><li>Enhanced Permissions: The new OS offers more granular control over app permissions, allowing users to grant temporary access to sensitive information.</li><li>Privacy Dashboard: This feature provides a comprehensive overview of how apps access personal data, empowering users to make informed decisions.</li><li>Stronger Encryption: Enhanced encryption protocols safeguard data, ensuring that user information remains secure both on the device and in transit.</li></ol><h3>Developer-Friendly Features</h3><p>For developers, Android 15 Beta 2.2 brings a suite of tools and features designed to streamline the development process and enhance app capabilities:</p><ol><li>Jetpack Compose Updates: The latest updates to Jetpack Compose simplify UI development, making it easier to create beautiful and functional apps.</li><li>Enhanced API Access: New and improved APIs offer deeper integration with the OS, allowing for more innovative and powerful applications.</li><li>Improved Emulator Performance: The Android Emulator has been optimized for faster performance and better simulation of real-world scenarios, aiding in efficient app testing and development.</li></ol><h3>Why It Matters</h3><p>Android 15 Beta 2.2 is more than just a collection of new features; it represents a forward-thinking approach to mobile OS design. By focusing on user experience, performance, security, and developer support, Google is setting the stage for a more connected, efficient, and secure digital ecosystem.</p><p>For businesses, staying ahead of the curve with the latest Android updates can provide a competitive edge, allowing for the creation of cutting-edge applications that leverage new features and improvements. For developers, the enhanced tools and APIs mean more opportunities for innovation and creativity.</p><p>As we look to the future, Android 15 Beta 2.2 signifies a pivotal moment in mobile technology, one that promises to shape the way we interact with our devices and the digital world at large. Embracing these changes and understanding their implications will be key to thriving in the ever-evolving tech landscape.</p><p>Are you excited about the new features in Android 15 Beta 2.2? How do you think these updates will impact your work or daily life? Share your thoughts and join the conversation!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f23c91f01e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hoesolve zsh: command not found: python issue]]></title>
            <link>https://ayodyabanukafernando.medium.com/hoesolve-zsh-command-not-found-python-issue-de6f603680a9?source=rss-30a664cf7d25------2</link>
            <guid isPermaLink="false">https://medium.com/p/de6f603680a9</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[error]]></category>
            <category><![CDATA[terminal-commands]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[macos]]></category>
            <dc:creator><![CDATA[Ayodya Banuka Fernando]]></dc:creator>
            <pubDate>Thu, 06 Jun 2024 18:22:51 GMT</pubDate>
            <atom:updated>2024-06-06T18:22:51.317Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to resolve zsh: command not found: python issue</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0dDmBOmm2aok4k_Q5TDZzQ.jpeg" /></figure><p>When running Python from the terminal, you might encounter the error:</p><pre>zsh: command not found: python</pre><p>This is particularly common on macOS since the native Python support was removed in macOS 12.3. Here’s how to resolve this issue:</p><h3>Step 1: Ensure Python is Installed</h3><p>First, confirm that Python is installed on your system. If it’s not, you can install it using Homebrew by running:</p><pre>brew install python</pre><p>Alternatively, you can download and install Python directly from the <a href="https://www.python.org/downloads/">official Python website</a>. Once installed, try running python from the terminal again. If the issue persists, proceed to the next step.</p><h3>Step 2: Add Python to zsh</h3><p>If Python is installed but the command still isn’t recognized, you’ll need to configure zsh to recognize the Python command. Run the following command in the terminal:</p><pre>echo &quot;alias python=/usr/bin/python3&quot; &gt;&gt; ~/.zshrc</pre><p>This command adds an alias to your zsh profile, telling it to use /usr/bin/python3 when you type python. Make sure the path /usr/bin/python3 matches where Python is installed on your system.</p><h3>Step 3: Restart the Terminal</h3><p>After updating your zsh configuration, restart your terminal. When you open it again, the python the command should now work correctly.</p><p>By following these steps, you should be able to resolve the zsh: command not found: python error and run Python from your terminal without any issues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de6f603680a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlock Offline Superpowers in Your React App with Service Workers!]]></title>
            <link>https://ayodyabanukafernando.medium.com/unlock-offline-superpowers-in-your-react-app-with-service-workers-238fe7839487?source=rss-30a664cf7d25------2</link>
            <guid isPermaLink="false">https://medium.com/p/238fe7839487</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[offline]]></category>
            <category><![CDATA[background]]></category>
            <category><![CDATA[no-internet-connection]]></category>
            <category><![CDATA[service-worker]]></category>
            <dc:creator><![CDATA[Ayodya Banuka Fernando]]></dc:creator>
            <pubDate>Thu, 06 Jun 2024 04:30:12 GMT</pubDate>
            <atom:updated>2024-06-06T04:30:12.084Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vn5as5mrpzh7pPyPck17tg.png" /></figure><p>If you are a front-end developer, you might have heard about service workers. If not, you can learn about service workers at the end of this article.</p><p>Service workers are scripts that run in the background of your browser. They are the core of offline systems, allowing web applications to work offline and offering features like push notifications and background synchronization. Unlike traditional JavaScript, service workers don’t have any direct connection with the DOM (Document Object Model), which means they don’t interact with the UI directly but work behind the scenes.</p><h3>Service Workers in React</h3><p>When you create a React application using create-react-app, service workers are automatically added to your project. This provides a good starting point for adding offline capabilities to your application. Here’s a deeper dive into how service workers are used in a React application created with create-react-app.</p><h4>Creating a React App with Service Workers</h4><p>To create a new React app with create-react-app, run the following command:</p><pre>npx create-react-app my-app</pre><p>This command sets up a new React project with a default configuration that includes a service worker. The service worker file is located at src/service-worker.js.</p><h4>Enabling the Service Worker</h4><p>By default, the service worker in a React app created with create-react-app is not enabled. To enable it, you need to modify the src/index.js file.</p><p>Open src/index.js.</p><p>Locate the line that imports serviceWorker:</p><pre>import * as serviceWorker from &#39;./serviceWorker&#39;;</pre><p>At the bottom of the file, you will find:</p><pre>// If you want your app to work offline and load faster, you can change<br>// unregister() to register() below. Note this comes with some pitfalls.<br>// Learn more about service workers: https://bit.ly/CRA-PWA<br>serviceWorker.unregister();</pre><p>Change serviceWorker.unregister() to serviceWorker.register():</p><pre>serviceWorker.register();</pre><p>This change will enable the service worker and start caching your app’s assets, allowing it to work offline.</p><h4>Usage of Service Workers</h4><p>Service workers offer several functionalities that enhance the performance and capabilities of web applications:</p><p><strong>Offline Support</strong>:</p><ul><li><strong>Caching</strong>: Service workers can cache files so that the application can function offline. This is particularly useful for ensuring that users can still view content even without an internet connection.</li><li><strong>Cache API</strong>: The Cache API allows service workers to store network requests and responses. This enables your application to serve content from the cache when offline.</li></ul><p><strong>Push Notifications</strong>:</p><ul><li>Service workers enable web push notifications, which allow you to send notifications to users even when the browser is closed. This is a great way to engage users and keep them informed about updates or important information.</li></ul><ol><li><strong>Background Sync</strong>:</li></ol><ul><li>Service workers can synchronize data in the background, ensuring that user actions taken offline are eventually synchronized with the server once the internet connection is restored. This ensures that data integrity is maintained even in fluctuating network conditions.</li></ul><h4>Example: Caching Assets</h4><p>Here’s a basic example of how to cache assets in a service worker:</p><ol><li>Open src/service-worker.js.</li><li>Add the following code to handle asset caching:</li></ol><pre>const CACHE_NAME = &#39;my-app-cache-v1&#39;;<br>const urlsToCache = [<br>  &#39;/&#39;,<br>  &#39;/index.html&#39;,<br>  &#39;/static/js/bundle.js&#39;,<br>  // Add other assets you want to cache<br>];<br>self.addEventListener(&#39;install&#39;, (event) =&gt; {<br>  event.waitUntil(<br>    caches.open(CACHE_NAME)<br>      .then((cache) =&gt; {<br>        return cache.addAll(urlsToCache);<br>      })<br>  );<br>});<br>self.addEventListener(&#39;fetch&#39;, (event) =&gt; {<br>  event.respondWith(<br>    caches.match(event.request)<br>      .then((response) =&gt; {<br>        if (response) {<br>          return response;<br>        }<br>        return fetch(event.request);<br>      })<br>  );<br>});</pre><p>This code sets up a basic service worker that caches specified assets during the installation phase and serves cached assets during the fetch phase.</p><h3>Conclusion</h3><p>Service workers are a powerful tool for modern web development, enabling offline capabilities, push notifications, and background synchronization. In a React application created with create-react-app, service workers are included by default, making it easier to add these features to your app. By understanding and utilizing service workers, you can significantly enhance the performance and user experience of your web applications.</p><p>For more detailed information about service workers, refer to the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API">Service Worker API documentation</a> on MDN Web Docs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=238fe7839487" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Can GPT-5 replace your job with a bot?]]></title>
            <link>https://ayodyabanukafernando.medium.com/can-gpt-5-replace-your-job-with-a-bot-c8029318c257?source=rss-30a664cf7d25------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8029318c257</guid>
            <category><![CDATA[chatgpt5]]></category>
            <category><![CDATA[new-features]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[chatgpt]]></category>
            <dc:creator><![CDATA[Ayodya Banuka Fernando]]></dc:creator>
            <pubDate>Sun, 02 Jun 2024 20:27:20 GMT</pubDate>
            <atom:updated>2024-06-02T20:27:20.645Z</atom:updated>
            <content:encoded><![CDATA[<p>ChatGPT-5 is here, and it’s the latest and greatest in the world of AI chatbots. If you thought ChatGPT-4 was impressive, get ready to be amazed by what ChatGPT-5 can do. Let’s break down the key improvements in a simple way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lb7A9y2kieR3AahjEUEvbA.jpeg" /></figure><h4>What’s New and Exciting in ChatGPT-5?</h4><ol><li><strong>Better Understanding</strong>: ChatGPT-5 can understand what you’re saying much better. It gets the context and can handle more complicated questions and topics without getting confused.</li><li><strong>Longer Conversations</strong>: Ever had a chatbot forget what you were talking about? ChatGPT-5 has a better memory, so it can keep up with longer conversations and remember details from past chats.</li><li><strong>More Than Just Text</strong>: This version can work with text, images, and even audio. So, you can have richer interactions that aren’t just limited to typing.</li><li><strong>Tailored Responses</strong>: ChatGPT-5 can adjust its responses to fit your style and preferences, making conversations feel more personal and natural.</li><li><strong>Safer and More Ethical</strong>: Safety is a big focus. ChatGPT-5 is designed to avoid generating harmful or inappropriate content, making it a safer AI to use.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xwurnpMyxKP4lo97q-4CSQ.jpeg" /></figure><h4>How Can ChatGPT-5 Help?</h4><ul><li><strong>Customer Service</strong>: It can provide better and more personalized help, answering a wider range of questions and remembering previous interactions.</li><li><strong>Healthcare</strong>: It can assist doctors and patients by providing medical information, helping with diagnoses, and supporting telemedicine.</li><li><strong>Education</strong>: It can act as a tutor, offering explanations, visual aids, and interactive learning.</li><li><strong>Content Creation</strong>: Writers and creators can use it for brainstorming, drafting, and editing, speeding up their work.</li><li><strong>Accessibility</strong>: It can help people with disabilities by offering text and audio interactions, making technology more inclusive.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8029318c257" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What's New with NextJs 15 RC]]></title>
            <link>https://ayodyabanukafernando.medium.com/whats-new-with-nextjs-15-rc-1fdb66b10ff0?source=rss-30a664cf7d25------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fdb66b10ff0</guid>
            <category><![CDATA[updates]]></category>
            <category><![CDATA[whatsnewupdate]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[nextjs-15]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Ayodya Banuka Fernando]]></dc:creator>
            <pubDate>Mon, 27 May 2024 18:43:18 GMT</pubDate>
            <atom:updated>2024-05-27T18:43:18.097Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yAT49FuiFRe9BlBS5dI5dg.png" /></figure><p>The web development community is abuzz with the release of the Next.js 15 Release Candidate (RC). This early version offers developers a chance to explore and test the latest features before the stable release hits the market. In this article, we’ll dive into the key updates and enhancements introduced in Next.js 15 RC, including support for React 19 RC, significant changes in caching, experimental features like Partial Prerendering and next/after, updates to create-next-app, and new options for bundling external packages.</p><p>To get started with Next.js 15 RC, try it now using the following command:</p><pre>npx create-next-app@rc</pre><h3>React 19 RC Support and Enhancements</h3><p>One of the most anticipated updates in Next.js 15 RC is the support for React 19 RC. This integration includes:</p><ul><li>React Compiler (Experimental): A new experimental compiler aimed at optimizing the performance and efficiency of React applications.</li><li>Hydration Error Improvements: Enhancements to the hydration process to make it more robust and error-resistant, ensuring smoother transitions from server-rendered HTML to fully interactive React components.</li></ul><p>These updates are designed to provide developers with cutting-edge tools and improvements, allowing them to build more efficient and powerful React applications.</p><h3>Caching Overhaul</h3><p>Caching behavior in Next.js 15 RC has seen significant changes:</p><ul><li>fetch Requests: Fetch requests are no longer cached by default, offering more control and flexibility over how data fetching is handled.</li><li>GET Route Handlers: Similar to fetch requests, GET route handlers will not cache responses by default, ensuring that the latest data is always served.</li><li>Client Navigations: Navigations on the client side now bypass the cache, providing a more predictable and dynamic user experience.</li></ul><p>These changes give developers finer control over caching mechanisms, enabling more precise management of data freshness and performance.</p><h3>Partial Prerendering (Experimental)</h3><p>A notable experimental feature in Next.js 15 RC is Partial Prerendering:</p><ul><li>New Layout and Page Config Option: This feature introduces a new configuration option that allows for incremental adoption of partial prerendering. Developers can selectively prerender parts of their application, improving load times and performance without requiring a complete overhaul of the existing codebase.</li></ul><p>Partial Prerendering aims to strike a balance between static site generation and server-side rendering, providing the benefits of both approaches.</p><h3>Introducing next/after (Experimental)</h3><p>The next/after API is another experimental addition in Next.js 15 RC:</p><ul><li>Execute Code After Response Streaming: This new API enables developers to execute code after a response has finished streaming. This capability can be used for various purposes, such as logging, cleanup tasks, or additional asynchronous operations that should not block the response to the client.</li></ul><p>This feature enhances the flexibility and power of server-side code execution in Next.js applications.</p><h3>create-next-app Updates</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*485gPTt43s5S4GdiPYbTYQ.png" /></figure><p>The create-next-app tool, a staple for bootstrapping new Next.js projects, has received a facelift:</p><ul><li>Updated Design: A refreshed design makes the tool more intuitive and user-friendly.</li><li>New Flag for Turbopack: Developers can now use a new flag to enable Turbopack in local development. Turbopack, a new bundler, aims to significantly speed up the development process with faster builds and reloads.</li></ul><p>These updates make it easier for developers to get started with Next.js projects and leverage the latest advancements in build tooling.</p><h3>Bundling External Packages (Stable)</h3><p>Lastly, Next.js 15 RC introduces stable support for bundling external packages:</p><ul><li>New Config Options: Developers using both the App and Pages Router can now take advantage of new configuration options for bundling external packages. This flexibility allows for better optimization and customization of the build process.</li></ul><p>This update ensures that developers have more control over their project’s dependencies and build configurations, leading to more efficient and tailored applications.</p><h3>Conclusion</h3><p>The Next.js 15 Release Candidate is packed with exciting new features and improvements that push the boundaries of what’s possible in modern web development. From support for React 19 RC and significant caching changes to experimental features like Partial Prerendering and next/after, this release candidate offers a wealth of opportunities for developers to innovate and optimize their applications. With the updated create-next-app tool and new options for bundling external packages, getting started with Next.js has never been easier or more powerful.</p><p>As always, the Next.js team encourages developers to try out the RC and provide feedback to help refine these features for the upcoming stable release. Dive into the future of web development with Next.js 15 RC and start exploring the possibilities today by running:</p><pre>npx create-next-app@rc</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fdb66b10ff0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SSR in Next.js]]></title>
            <link>https://ayodyabanukafernando.medium.com/ssr-in-next-js-5b771deaccf6?source=rss-30a664cf7d25------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b771deaccf6</guid>
            <category><![CDATA[server-side-rendering]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[fast-loading-website]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Ayodya Banuka Fernando]]></dc:creator>
            <pubDate>Sun, 26 May 2024 19:39:05 GMT</pubDate>
            <atom:updated>2024-05-26T19:39:05.532Z</atom:updated>
            <content:encoded><![CDATA[<p>Next.js simplifies the implementation of SSR with its intuitive API and configuration. Here’s a step-by-step guide to getting started with SSR in Next.js.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wZJDGKG83TrfbieiGPyvVA.png" /></figure><h3>Setting Up a Next.js Project</h3><p>First, ensure you have Node.js and npm installed. Then, create a new Next.js project:</p><pre>npx create-next-app my-nextjs-app<br>cd my-nextjs-app<br>npm run dev</pre><h3>Implementing SSR</h3><p>Next.js uses the getServerSideProps function to enable SSR for a specific page. This function fetches data on each request and passes it as props to your component.</p><p>Here’s an example:</p><pre>export async function getServerSideProps() {<br>  const res = await fetch(&#39;https://api.example.com/data&#39;);<br>  const data = await res.json();</pre><pre>  return {<br>    props: { data }, // will be passed to the page component as props<br>  };<br>}</pre><pre>const HomePage = ({ data }) =&gt; {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Server-Side Rendered Page&lt;/h1&gt;<br>      &lt;pre&gt;{JSON.stringify(data, null, 2)}&lt;/pre&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><pre>export default HomePage;</pre><p>In this example, getServerSideProps fetches data from an API and passes it to HomePage as props. When a user requests this page, Next.js fetches the data on the server and renders the page with the data included.</p><h3>Handling Errors</h3><p>Error handling in SSR can be managed by returning an error status code and a custom error page. Next.js provides a default error page, but you can customize it.</p><pre>export async function getServerSideProps() {<br>  try {<br>    const res = await fetch(&#39;https://api.example.com/data&#39;);<br>    if (!res.ok) {<br>      throw new Error(&#39;Failed to fetch&#39;);<br>    }<br>    const data = await res.json();</pre><pre>    return {<br>      props: { data },<br>    };<br>  } catch (error) {<br>    return {<br>      props: { error: &#39;Failed to load data&#39; },<br>    };<br>  }<br>}</pre><pre>const HomePage = ({ data, error }) =&gt; {<br>  if (error) {<br>    return &lt;div&gt;Error: {error}&lt;/div&gt;;<br>  }</pre><pre>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Server-Side Rendered Page&lt;/h1&gt;<br>      &lt;pre&gt;{JSON.stringify(data, null, 2)}&lt;/pre&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><pre>export default HomePage;</pre><h3>Performance Considerations</h3><p>While SSR improves initial load performance and SEO, it can introduce latency due to server-side data fetching. To mitigate this, consider:</p><ul><li>Caching: Implement caching strategies to store and reuse server-rendered pages.</li><li>CDN: Use a Content Delivery Network (CDN) to distribute your content globally, reducing server load and latency.</li><li>Optimized Data Fetching: Minimize the data fetched and optimize API calls.</li></ul><h3>Combining SSR with Static Generation</h3><p>Next.js also supports Static Site Generation (SSG), allowing you to combine the benefits of static and server-rendered pages. For example, you might use SSG for blog posts and SSR for frequently updated content.</p><pre>export async function getStaticPaths() {<br>  const res = await fetch(&#39;https://api.example.com/posts&#39;);<br>  const posts = await res.json();</pre><pre>  const paths = posts.map((post) =&gt; ({<br>    params: { id: post.id.toString() },<br>  }));</pre><pre>  return { paths, fallback: false };<br>}</pre><pre>export async function getStaticProps({ params }) {<br>  const res = await fetch(`https://api.example.com/posts/${params.id}`);<br>  const post = await res.json();</pre><pre>  return { props: { post } };<br>}</pre><pre>const PostPage = ({ post }) =&gt; {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;{post.title}&lt;/h1&gt;<br>      &lt;p&gt;{post.content}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><pre>export default PostPage;</pre><p>In this example, getStaticPaths and getStaticProps are used to statically generate blog post pages at build time, providing a hybrid approach.</p><h3>Conclusion</h3><p>Server-Side Rendering in Next.js is a powerful feature that enhances performance, SEO, and user experience. By leveraging getServerSideProps, developers can create dynamic, data-rich applications that are rendered on the server and delivered efficiently to the client. Coupled with Next.js&#39;s support for static generation and other optimizations, SSR becomes a vital tool in the modern web developer&#39;s toolkit. Whether you&#39;re building a content-rich website or a high-performance application, understanding and implementing SSR in Next.js will undoubtedly contribute to your project&#39;s success.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b771deaccf6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Server-Side Rendering (SSR)]]></title>
            <link>https://ayodyabanukafernando.medium.com/understanding-server-side-rendering-ssr-a3c2957a6c3b?source=rss-30a664cf7d25------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3c2957a6c3b</guid>
            <category><![CDATA[fast-loading-website]]></category>
            <category><![CDATA[load-time-optimization]]></category>
            <category><![CDATA[seo-friendly-website]]></category>
            <category><![CDATA[server-side-rendering]]></category>
            <category><![CDATA[ssrs]]></category>
            <dc:creator><![CDATA[Ayodya Banuka Fernando]]></dc:creator>
            <pubDate>Fri, 24 May 2024 18:46:51 GMT</pubDate>
            <atom:updated>2024-05-24T18:46:51.702Z</atom:updated>
            <content:encoded><![CDATA[<p>In the evolving landscape of web development, delivering fast, efficient, and SEO-friendly web applications is crucial. One powerful technique that facilitates this is Server-Side Rendering (SSR).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HvFABkUqrH1B9kK7hAaxWA.png" /></figure><h3>What is Server-Side Rendering (SSR)?</h3><p>Server-side rendering (SSR) is the process of rendering web pages on the server rather than in the client’s browser. Unlike traditional client-side rendering, where the browser downloads a minimal HTML page and then populates it with JavaScript, SSR sends a fully rendered HTML page from the server in response to a request.</p><h3>Benefits of SSR</h3><ol><li>Improved Performance: SSR can significantly reduce the time to first meaningful paint (TTFMP), enhancing the perceived performance of your application.</li><li>SEO Optimization: Since search engines can easily crawl and index fully rendered HTML, SSR improves SEO.</li><li>Enhanced User Experience: Users see the content faster, leading to better engagement and lower bounce rates.</li></ol><blockquote>Let&#39;s talk about how to use SSR in NextJs in the next article….</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3c2957a6c3b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Backbone of Modern Internet : CDN]]></title>
            <link>https://ayodyabanukafernando.medium.com/the-backbone-of-modern-internet-cdn-f54808292734?source=rss-30a664cf7d25------2</link>
            <guid isPermaLink="false">https://medium.com/p/f54808292734</guid>
            <dc:creator><![CDATA[Ayodya Banuka Fernando]]></dc:creator>
            <pubDate>Tue, 21 May 2024 13:49:28 GMT</pubDate>
            <atom:updated>2024-05-21T13:49:28.024Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Backbone of Modern Internet: CDN</h3><p>In today’s fast-paced digital world, where instantaneous access to information is the norm, the performance and reliability of websites and applications are paramount. This is where Content Delivery Networks (CDNs) come into play. CDNs are essential for delivering content quickly, securely, and reliably to users around the globe. But what exactly are CDNs, and how do they work? Let’s dive in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KK4AqRrKtUtkInGAEBh2qg.jpeg" /></figure><h3>What is a CDN?</h3><p>A Content Delivery Network is a system of distributed servers that deliver web content to a user based on their geographic location. The primary goal of a CDN is to reduce latency — the delay between a user request and the delivery of content. By serving content from a location closer to the user, CDNs significantly speed up the load times of web pages, improve the user experience, and reduce the strain on the origin server.</p><h3>How Do CDNs Work?</h3><p>At its core, a CDN works by caching content in multiple locations around the world, known as Points of Presence (PoPs). Each PoP contains a number of caching servers responsible for delivering content to users in its vicinity. Here’s a step-by-step breakdown of how a CDN operates:</p><ol><li>Content is Distributed: When a website owner integrates a CDN, their static content (like images, stylesheets, and scripts) is copied to multiple PoPs across the globe.</li><li>User Request: When a user requests a web page, the CDN redirects the request to the nearest PoP, ensuring that the content travels the shortest distance.</li><li>Content Delivery: The CDN delivers the cached content from the PoP to the user, significantly reducing load times.</li><li>Dynamic Content Handling: For dynamic content that changes frequently, CDNs can also employ strategies such as edge computing, where computations are performed at the edge of the network, closer to the user.</li></ol><h3>Benefits of Using a CDN</h3><p>The use of CDNs offers numerous benefits for both users and website owners:</p><h3>1. Improved Load Times</h3><p>By serving content from a location closer to the user, CDNs drastically reduce the time it takes for web pages to load. Faster load times lead to better user experiences and can increase the time users spend on a site.</p><h3>2. Reduced Bandwidth Costs</h3><p>CDNs can help reduce bandwidth consumption by offloading traffic from the origin server. This is particularly beneficial for websites with high traffic volumes, as it can lead to significant cost savings.</p><h3>3. Enhanced Security</h3><p>Many CDNs offer robust security features, including DDoS protection, web application firewalls (WAFs), and secure sockets layer (SSL) encryption. These features help protect websites from various cyber threats.</p><h3>4. Increased Reliability</h3><p>CDNs improve the reliability of content delivery by providing redundancy. If one server fails, requests can be rerouted to another server in the network, ensuring uninterrupted access to content.</p><h3>5. Scalability</h3><p>CDNs can easily handle spikes in traffic, such as during a major product launch or a viral event. This scalability ensures that websites remain responsive even under heavy loads.</p><h3>Real-World Applications of CDNs</h3><p>CDNs are used by a wide range of industries and services. Here are a few examples:</p><ul><li>E-commerce: Online retailers use CDNs to ensure that product images and descriptions load quickly, enhancing the shopping experience and reducing cart abandonment rates.</li><li>Streaming Services: Video and music streaming services rely on CDNs to deliver high-quality content without buffering, providing a seamless viewing experience.</li><li>Online Gaming: Gaming companies use CDNs to reduce latency and provide a smooth, real-time gaming experience for players around the world.</li><li>News Websites: Media outlets use CDNs to quickly deliver breaking news and multimedia content to a global audience.</li></ul><h3>Conclusion</h3><p>In an era where digital presence is crucial for businesses and organizations, CDNs play a vital role in ensuring that web content is delivered quickly, securely, and reliably. By leveraging a network of distributed servers, CDNs help reduce latency, lower bandwidth costs, enhance security, and improve overall user experience. As the internet continues to evolve, the importance of CDNs in delivering high-quality, uninterrupted content will only grow.</p><p>Embracing CDN technology is not just an option but a necessity for any organization looking to stay competitive in the digital landscape. Whether you are a small business owner or a large enterprise, investing in a CDN can provide significant returns in terms of performance, security, and user satisfaction.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f54808292734" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>