<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Naser Rasouli</title>
    <description>The latest articles on DEV Community by Naser Rasouli (@naserrasouli).</description>
    <link>https://dev.to/naserrasouli</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2939002%2Faa0f7677-2e52-442a-a796-caa57b212aae.jpg</url>
      <title>DEV Community: Naser Rasouli</title>
      <link>https://dev.to/naserrasouli</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/naserrasouli"/>
    <language>en</language>
    <item>
      <title>Role &amp; Permission Based Access Control in React (Static Access)</title>
      <dc:creator>Naser Rasouli</dc:creator>
      <pubDate>Tue, 09 Sep 2025 06:09:57 +0000</pubDate>
      <link>https://dev.to/naserrasouli/role-permission-based-access-control-in-react-static-access-4ac2</link>
      <guid>https://dev.to/naserrasouli/role-permission-based-access-control-in-react-static-access-4ac2</guid>
      <description>&lt;p&gt;When building an admin panel, one of the most important concerns is how to handle access control. Not every user should be able to see or do everything. For example, admins may be able to create and delete users, while editors can only view and update, and viewers should only see information without making changes.&lt;br&gt;
There are many ways to implement access control, but in this article we’ll focus on a simple and static approach. This means roles and permissions are defined in the codebase (not coming from an API), which is often enough for small to medium projects or when your access rules are not supposed to change frequently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We’ll break it down into two parts:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Route-level access: making sure users can only navigate to the pages they are allowed to.&lt;/li&gt;
&lt;li&gt;Component-level access: showing or hiding specific buttons, menus, or features inside a page depending on permissions.
This approach keeps your project clean, scalable, and ready to extend if later you decide to fetch permissions dynamically from your backend.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  1. Define Roles and Permissions
&lt;/h2&gt;

&lt;p&gt;The first step is to define the roles and their associated permissions. Since we are working with static access control, we can hardcode them inside a roles.ts file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// roles.ts
export const ROLES = {
  ADMIN: "ADMIN",
  EDITOR: "EDITOR",
  VIEWER: "VIEWER",
} as const;

export const PERMISSIONS = {
  USER_CREATE: "USER_CREATE",
  USER_DELETE: "USER_DELETE",
  USER_VIEW: "USER_VIEW",
} as const;

export const roleAccess = {
  [ROLES.ADMIN]: ["dashboard", "users", "settings"],
  [ROLES.EDITOR]: ["dashboard", "users"],

};

export const rolePermissions = {
  [ROLES.ADMIN]: [PERMISSIONS.USER_CREATE, PERMISSIONS.USER_DELETE, PERMISSIONS.USER_VIEW],


};

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we defined:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ROLES: user types (admin, editor, viewer).&lt;/li&gt;
&lt;li&gt;PERMISSIONS: actions that can be allowed (create, delete, view).&lt;/li&gt;
&lt;li&gt;roleAccess: which pages each role can access.&lt;/li&gt;
&lt;li&gt;rolePermissions: which actions each role can perform.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Route-Level Access with ProtectedRoute
&lt;/h2&gt;

&lt;p&gt;We need to prevent unauthorized users from accessing certain routes. For example, a viewer should not be able to open the users management page.&lt;br&gt;
We can build a ProtectedRoute component that checks if the current user’s role is included in the allowed list. If not, it redirects them to an “unauthorized” page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ProtectedRoute.tsx
import { Navigate } from "react-router-dom";
import { useAuth } from "@/hooks/useAuth";
import { roleAccess, ROLES } from "./roles";

export const ProtectedRoute = ({
  children,
  allowed,
}: {
  children: JSX.Element;
  allowed: string[];
}) =&amp;gt; {
  const { role } = useAuth();

  if (!role || !allowed.includes(role)) {
    return &amp;lt;Navigate to="/unauthorized" replace /&amp;gt;;
  }

  return children;
};

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And we can use it in our routes configuration like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// routes.tsx
import { ProtectedRoute } from "./ProtectedRoute";
import { roleAccess, ROLES } from "./roles";
import DashboardPage from "@/features/dashboard/pages/DashboardPage";
import UsersPage from "@/features/users/pages/UsersPage";

export const routes = [
  {
    path: "/dashboard",
    element: (
      &amp;lt;ProtectedRoute allowed={roleAccess[ROLES.VIEWER]}&amp;gt;
        &amp;lt;DashboardPage /&amp;gt;
      &amp;lt;/ProtectedRoute&amp;gt;
    ),
  },
  {
    path: "/users",
    element: (
      &amp;lt;ProtectedRoute allowed={roleAccess[ROLES.EDITOR]}&amp;gt;
        &amp;lt;UsersPage /&amp;gt;
      &amp;lt;/ProtectedRoute&amp;gt;
    ),
  },
];

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, only the roles listed in roleAccess will be able to visit these routes.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Component-Level Access with AccessControl
&lt;/h2&gt;

&lt;p&gt;Route-level control is not always enough. Often you’ll want to hide or show specific UI elements inside a page depending on the user’s permissions. For example, only admins should see a “Delete User” button.&lt;br&gt;
We can create an AccessControl component that checks for a specific permission.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// AccessControl.tsx
import { ReactNode } from "react";
import { useAuth } from "@/hooks/useAuth";
import { rolePermissions } from "./roles";

interface Props {
  permission: string;
  children: ReactNode;
}

export const AccessControl = ({ permission, children }: Props) =&amp;gt; {
  const { role } = useAuth();

  if (!role) return null;

  const permissions = rolePermissions[role] || [];

  return permissions.includes(permission) ? &amp;lt;&amp;gt;{children}&amp;lt;/&amp;gt; : null;
};

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Usage example inside a page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { AccessControl } from "@/components/AccessControl";
import { PERMISSIONS } from "@/routes/roles";

function UsersPage() {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;User List&amp;lt;/h1&amp;gt;

      &amp;lt;AccessControl permission={PERMISSIONS.USER_CREATE}&amp;gt;
        &amp;lt;button&amp;gt;Add User&amp;lt;/button&amp;gt;
      &amp;lt;/AccessControl&amp;gt;

      &amp;lt;AccessControl permission={PERMISSIONS.USER_DELETE}&amp;gt;
        &amp;lt;button&amp;gt;Delete User&amp;lt;/button&amp;gt;
      &amp;lt;/AccessControl&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
With just a few simple steps, we created a clean static access control system in React:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ProtectedRoute handles route-level access.&lt;/li&gt;
&lt;li&gt;AccessControl handles UI-level access.&lt;/li&gt;
&lt;li&gt;Roles and permissions are defined in one place, making it easy to manage.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This approach is perfect for projects where roles and permissions are not changing often. Later, if you want to fetch permissions dynamically from an API, you can simply replace the hardcoded roleAccess and rolePermissions with values coming from your backend.&lt;br&gt;
This makes your admin panel more secure, maintainable, and scalable.&lt;br&gt;
Happy coding 🚀&lt;/p&gt;

</description>
      <category>react</category>
      <category>typescript</category>
      <category>javascript</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Mastering Record in TypeScript: The Clean Way to Map Enums to Labels and Colors</title>
      <dc:creator>Naser Rasouli</dc:creator>
      <pubDate>Fri, 22 Aug 2025 11:31:30 +0000</pubDate>
      <link>https://dev.to/naserrasouli/mastering-record-in-typescript-the-clean-way-to-map-enums-to-labels-and-colors-46bh</link>
      <guid>https://dev.to/naserrasouli/mastering-record-in-typescript-the-clean-way-to-map-enums-to-labels-and-colors-46bh</guid>
      <description>&lt;p&gt;“Have you ever needed to display user-friendly labels, icons, or colors for numeric enums in TypeScript? Many devs either use switch statements or ad-hoc objects — but there’s a cleaner, type-safe way: Record.”&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Record in TypeScript?
&lt;/h2&gt;

&lt;p&gt;Short definition: Record is an object type with keys of type K and values of type T.&lt;br&gt;
Think of it as a type-safe way to define “maps” from a known set of keys to specific values.&lt;br&gt;
Here’s a very simple example using a union type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Union type of possible roles
type UserRole = "admin" | "user" | "guest";

// Record&amp;lt;UserRole, string&amp;gt; means:
//   - keys must be "admin" | "user" | "guest"
//   - values must be strings
const roles: Record&amp;lt;UserRole, string&amp;gt; = {
  admin: "Administrator",
  user: "Regular User",
  guest: "Guest User",
};

// ✅ Safe lookup
console.log(roles.admin); // "Administrator"

// ❌ Error: TypeScript won’t let you add an unknown key
// roles.superAdmin = "Super Admin";

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures you don’t forget a key, and you can’t accidentally add extra ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Record with enums (real-world example)
&lt;/h2&gt;

&lt;p&gt;Union types are nice, but in real-world projects we often work with enums. Let’s say you have an enum that represents payment statuses in your application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;enum PaymentStatus {
  Unpaid = 0,
  Paid = 1,
  Failed = 2,
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to display labels and colors in your UI for each status, the naive way would be a bunch of switch statements. Instead, Record gives us a cleaner, safer approach:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const PaymentStatusMeta: Record&amp;lt;
PaymentStatus, 
{ label: string; color: string }
&amp;gt; = {
  [PaymentStatus.Unpaid]: { label: "Unpaid", color: "orange" },
  [PaymentStatus.Paid]: { label: "Paid", color: "green" },
  [PaymentStatus.Failed]: { label: "Failed", color: "red" },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, wherever you need metadata for a given status:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const status = PaymentStatus.Paid;
console.log(PaymentStatusMeta[status].label); // "Paid"
console.log(PaymentStatusMeta[status].color); // "green"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Helper function for cleaner usage&lt;/strong&gt;&lt;br&gt;
Instead of directly accessing PaymentStatusMeta every time, you can wrap it in a function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function getPaymentStatusMeta(status: PaymentStatus) {
  return PaymentStatusMeta[status];
}

// Usage
const info = getPaymentStatusMeta(PaymentStatus.Failed);
console.log(info.label); // "Failed"
console.log(info.color); // "red"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes the code more expressive and also helps if later you need to add logic (like localization or formatting) inside the function without touching the rest of your codebase.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why use Record? (Advantages)
&lt;/h2&gt;

&lt;p&gt;Using Record in TypeScript to map enums (or unions) to metadata brings several benefits:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Full coverage enforced by TypeScript&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TypeScript ensures that every key in your enum or union is included in the Record.&lt;/li&gt;
&lt;li&gt;Forgetting a case results in a compile-time error, preventing runtime bugs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Strong type safety&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Values inside the Record must match the type you specify.&lt;/li&gt;
&lt;li&gt;No more accidentally assigning a string where an object is expected.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Extensible with metadata&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can easily add more fields, like icon, tooltip, localeLabel, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cleaner than switch/case statements&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No repeated switch statements scattered across your codebase.&lt;/li&gt;
&lt;li&gt;Lookup is simple and readable: PaymentStatusMeta[status].label&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Predictable and maintainable&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Future developers immediately know where to find mappings.
Adding a new enum value only requires updating one place.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you found this guide useful:&lt;br&gt;
✅ Save it for future reference.&lt;br&gt;
🔁 Share it with your team or developer friends.&lt;br&gt;
💬 Comment below with your favorite TypeScript patterns or how you handle enum metadata in your projects.&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;

</description>
      <category>enums</category>
      <category>frontend</category>
      <category>javascript</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Ant Design vs MUI: Which UI Library is Better for Your Next React Project?</title>
      <dc:creator>Naser Rasouli</dc:creator>
      <pubDate>Fri, 08 Aug 2025 13:12:23 +0000</pubDate>
      <link>https://dev.to/naserrasouli/ant-design-vs-mui-which-ui-library-is-better-for-your-next-react-project-532n</link>
      <guid>https://dev.to/naserrasouli/ant-design-vs-mui-which-ui-library-is-better-for-your-next-react-project-532n</guid>
      <description>&lt;p&gt;When building user interfaces in React, choosing the right UI library can have a significant impact on your development speed, code quality, and user experience.&lt;br&gt;
Among the many options available, two libraries stand out: Ant Design and MUI (Material UI). Both are powerful, widely-used, and well-documented — but which one is best for your project?&lt;br&gt;
As a frontend developer who has worked with both Ant Design and MUI in real-world projects, I’ve had the chance to experience their strengths, weaknesses, and subtle differences firsthand. In this article, I’ll share a detailed comparison based on practical use — not just surface-level features.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔹 What Are Ant Design and MUI?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;MUI (Material UI)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Developed by the MUI team.&lt;/li&gt;
&lt;li&gt;Based on Google’s Material Design.&lt;/li&gt;
&lt;li&gt;Offers 90+ components.&lt;/li&gt;
&lt;li&gt;Known for great documentation and strong TypeScript support.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Ant Design&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Developed by Alibaba.&lt;/li&gt;
&lt;li&gt;Focused on enterprise-level design with a clean, Eastern-inspired aesthetic.&lt;/li&gt;
&lt;li&gt;Great for building admin panels and business dashboards.&lt;/li&gt;
&lt;li&gt;Offers a full design system with layout, components, icons, and utilities.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1. Developer Experience (DX)&lt;/strong&gt;&lt;br&gt;
Both libraries offer a solid developer experience, but with different tools and styles.&lt;br&gt;
MUI uses Emotion or styled-components for styling, giving you full power of CSS-in-JS and React’s ecosystem.&lt;br&gt;
Ant Design uses Less, which can be powerful but requires extra configuration in Webpack/Vite for customization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Documentation&lt;/strong&gt;&lt;br&gt;
MUI provides in-depth documentation with live examples, clear explanations, and customization guides.&lt;br&gt;
Ant Design also has decent documentation, but some advanced topics (like dynamic forms or theme customization) can feel lacking or scattered.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Design and Aesthetics (UI/UX)&lt;/strong&gt;&lt;br&gt;
There’s a clear difference in design philosophy:&lt;br&gt;
MUI looks modern, clean, and mobile-friendly. It’s a perfect fit for apps that follow Material Design guidelines.&lt;br&gt;
Ant Design feels more professional and formal, making it ideal for enterprise dashboards or B2B applications.&lt;br&gt;
For example:&lt;br&gt;
Ant’s Form component is much more powerful than MUI’s out of the box.&lt;br&gt;
MUI’s typography and spacing system is more intuitive for custom layouts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Customization &amp;amp; Theming&lt;/strong&gt;&lt;br&gt;
MUI offers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A powerful theming system with full TypeScript support.&lt;/li&gt;
&lt;li&gt;Light/dark mode out of the box.&lt;/li&gt;
&lt;li&gt;Theme customization using the ThemeProvider.
Ant Design allows theme customization using Less variables, but:&lt;/li&gt;
&lt;li&gt;You need additional setup with Webpack/Vite plugins.&lt;/li&gt;
&lt;li&gt;Real-time theme switching is harder to implement.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5. TypeScript Support&lt;/strong&gt;&lt;br&gt;
Both libraries support TypeScript, but:&lt;br&gt;
MUI has excellent TypeScript support, with strong typing for generics and customizable components.&lt;br&gt;
Ant Design also works well with TS, though complex components like Form or Table can get tricky.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. RTL Support (Right-to-Left)&lt;/strong&gt;&lt;br&gt;
MUI provides built-in RTL support. Just set direction: "rtl" in your theme.&lt;br&gt;
Ant Design supports RTL, but requires manual setup and injecting RTL-specific styles using ConfigProvider.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Performance &amp;amp; Tree-Shaking&lt;/strong&gt;&lt;br&gt;
MUI is designed to support tree-shaking, meaning you can import only what you use, keeping bundle sizes small.&lt;br&gt;
Ant Design is heavier by default, but you can optimize it using babel-plugin-import or Vite’s plugin to enable on-demand loading.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✅ Final Thoughts: Which One Should You Choose?&lt;/strong&gt;&lt;br&gt;
It depends on your project needs and design direction:&lt;br&gt;
🔹 Choose MUI if you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prefer Google’s Material Design&lt;/li&gt;
&lt;li&gt;Need easy theming and light/dark mode&lt;/li&gt;
&lt;li&gt;Want better TypeScript support&lt;/li&gt;
&lt;li&gt;Prioritize mobile-friendly design&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🔸 Choose Ant Design if you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Are building enterprise dashboards or admin panels&lt;/li&gt;
&lt;li&gt;Need powerful table and form components&lt;/li&gt;
&lt;li&gt;Prefer a more formal, structured UI&lt;/li&gt;
&lt;li&gt;Don’t mind using Less and extra config&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There’s no one-size-fits-all answer — both libraries are excellent. Just pick the one that matches your team’s skills and your project’s priorities.&lt;/p&gt;

</description>
      <category>react</category>
      <category>antdesign</category>
      <category>mui</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>Scalable React Projects with Feature-Based Architecture</title>
      <dc:creator>Naser Rasouli</dc:creator>
      <pubDate>Sun, 18 May 2025 11:46:23 +0000</pubDate>
      <link>https://dev.to/naserrasouli/scalable-react-projects-with-feature-based-architecture-117c</link>
      <guid>https://dev.to/naserrasouli/scalable-react-projects-with-feature-based-architecture-117c</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
scaling React apps gets messy quickly as they grow. Flat structures like components/, pages/, and hooks/ don't scale well for real-world applications.&lt;br&gt;
As your application grows, you'll end up with hundreds of unrelated components and hooks dumped into global folders. Searching and maintaining becomes a nightmare.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is Feature-Based Architecture?
&lt;/h2&gt;

&lt;p&gt;Feature-Based Architecture is an organizational pattern where code is grouped by feature or domain, instead of by file type. In traditional React project structures, it's common to see directories like components/, pages/, hooks/, and utils/ at the top level. This might work for small projects, but it quickly becomes hard to manage as the app grows.&lt;br&gt;
In contrast, feature-based architecture groups all files related to a specific functionality (e.g., Posts, Products, Users) together in one directory. Each feature becomes a self-contained module with its own UI components, logic, hooks, types, tests, and even routing if needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧩 Traditional Structure (By File Type)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/
├── components/
│   ├── PostItem.tsx
│   ├── PostList.tsx
├── pages/
│   └── PostsPage.tsx
├── hooks/
│   └── usePost.ts
├── types/
│   └── post.types.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;❌ This leads to scattered logic. If you're working on "Posts", you’ll jump across multiple folders to maintain or update code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✅ Feature-Based Structure&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;├── core/       # Global configurations, assets, context providers, styles
│   ├── assets/
│   │   └── css/
│   │       └── App.css
│   └── config/ # App-wide config files (e.g., api config, constants)
│       └── env.ts
│
├── layouts/    # Application-level layouts
│   ├── Header.tsx
│   └── FullLayout.tsx
│
├── features/
│   └── Post/
│       ├── components/
│       │   ├── PostItem.tsx
│       │   └── PostList.tsx
│       ├── hooks/
│       │   └── usePost.ts
│       ├── types/
│       │   └── post.types.ts
│       ├── views/
│       │   └── PostView.tsx
│       └── routes.ts
│
├── router.ts     # Application-wide routing
├── main.tsx      # React entry point
└── index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;📌 Notes&lt;/strong&gt;&lt;br&gt;
core/: This is where you put global, app-wide concerns that aren't tied to a specific feature. Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Global CSS or theming&lt;/li&gt;
&lt;li&gt;API clients&lt;/li&gt;
&lt;li&gt;Context providers (like AuthProvider, ThemeProvider)&lt;/li&gt;
&lt;li&gt;Application configuration files (env.ts, routes.config.ts)&lt;/li&gt;
&lt;li&gt;layouts/: Layout components that define page structure (headers, sidebars, wrappers)&lt;/li&gt;
&lt;li&gt;features/: Each folder represents a self-contained domain, including everything that feature needs (UI, logic, routing, etc.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🔍 With this layout, the root-level src/ is clean and clearly segmented into global utilities (core/, layouts/) and isolated business logic (features/).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;📦 Example Repository&lt;/strong&gt;&lt;br&gt;
To help you get started, I’ve built a sample boilerplate using the exact structure described in this article.&lt;/p&gt;

&lt;p&gt;You can check it out on GitHub:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/naserrasoulii/feature-based-react" rel="noopener noreferrer"&gt;https://github.com/naserrasoulii/feature-based-react&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to fork it, use it as a base for your own projects, or contribute improvements!&lt;/p&gt;

</description>
      <category>react</category>
      <category>typescript</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Mastering Git Commit Messages with Conventional Commits</title>
      <dc:creator>Naser Rasouli</dc:creator>
      <pubDate>Sun, 04 May 2025 18:10:49 +0000</pubDate>
      <link>https://dev.to/naserrasouli/mastering-git-commit-messages-with-conventional-commits-2p96</link>
      <guid>https://dev.to/naserrasouli/mastering-git-commit-messages-with-conventional-commits-2p96</guid>
      <description>&lt;p&gt;&lt;strong&gt;✳️ Why Should We Care About Commit Message Structure?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In any software project, every small change made to the codebase is recorded in Git history. This history is not just a log of what happened — it's a crucial tool for tracking changes, collaborating with others, managing releases, and automating development workflows.&lt;br&gt;
But when commit messages are written inconsistently or without structure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It becomes hard to understand why a change was made&lt;/li&gt;
&lt;li&gt;Generating changelogs becomes manual and time-consuming&lt;/li&gt;
&lt;li&gt;CI/CD tools can’t effectively leverage the commit history&lt;/li&gt;
&lt;li&gt;And in team environments, others struggle to follow your changes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where Conventional Commits come into play. It’s a simple but powerful convention that allows us to write commit messages in a structured, readable, and machine-parsable way — making life easier for both developers and tools.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧠 What is &lt;a href="https://www.conventionalcommits.org/" rel="noopener noreferrer"&gt;Conventional Commits&lt;/a&gt;?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Conventional Commits is a standardized convention for writing commit messages in Git. It helps developers write structured, meaningful, and automatable messages to track changes more effectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🏗 Commit Message Structure&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;type&amp;gt;(optional scope): &amp;lt;short description&amp;gt;
[optional body]
[optional footer(s)]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Main Components:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;type&lt;/strong&gt;: The type of change (required)&lt;br&gt;
&lt;strong&gt;scope&lt;/strong&gt;: The section of the codebase affected (optional)&lt;br&gt;
&lt;strong&gt;description&lt;/strong&gt;: A concise summary of the change (required)&lt;br&gt;
&lt;strong&gt;body&lt;/strong&gt;: A more detailed explanation (optional)&lt;br&gt;
&lt;strong&gt;footer&lt;/strong&gt;: Used for issue references or breaking changes (optional)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧩 Common Commit Types&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| Type     | Purpose                                          |
| -------- | ------------------------------------------------ |
| feat     | A new feature                                    |
| fix      | A bug fix                                        |
| docs     | Documentation-only changes                       |
| style    | Code formatting (whitespace, etc.)               |
| refactor | Code changes that don’t fix bugs or add features |
| test     | Adding or updating tests                         |
| chore    | Miscellaneous tasks (build tools, etc.)          |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;🧪 Real-World Examples&lt;/strong&gt;&lt;br&gt;
Now that you understand the structure and purpose of Conventional Commits, let’s see how they’re actually used in real development workflows.&lt;br&gt;
In this section, we’ll walk through practical examples of commit messages for common scenarios — from adding features and fixing bugs to making documentation updates and handling breaking changes.&lt;br&gt;
These examples will help you apply the convention correctly and consistently in your own projects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Adding a New Feature&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;feat(cart): add quantity selector to cart items
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Fixing a Bug&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fix(auth): resolve issue with token refresh on expiration
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Documentation Update&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docs(readme): update usage example for CLI
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Styling Change&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;style(ui): reformat buttons and inputs using Tailwind
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Code Refactoring&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;refactor(api): simplify data fetch logic in product service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Breaking Change (Incompatible)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;feat!: drop support for Node.js v12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;✅ Final Thoughts&lt;/strong&gt;&lt;br&gt;
Conventional Commits help create a clean, consistent, and automatable Git history. This is especially beneficial in team-based, open-source, or large-scale projects that rely on version control and automation.&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>gitlab</category>
    </item>
    <item>
      <title>Mastering Git Flow: A Developer’s Guide to Branching Strategies</title>
      <dc:creator>Naser Rasouli</dc:creator>
      <pubDate>Tue, 29 Apr 2025 08:15:56 +0000</pubDate>
      <link>https://dev.to/naserrasouli/mastering-git-flow-a-developers-guide-to-branching-strategies-2hej</link>
      <guid>https://dev.to/naserrasouli/mastering-git-flow-a-developers-guide-to-branching-strategies-2hej</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is Git Flow?&lt;/strong&gt;&lt;br&gt;
Git Flow is a popular branching strategy that helps manage the clean and organized development of applications. It was introduced by Vincent Driessen in 2010 to provide developers with a structured workflow using Git. Git Flow focuses on isolating different types of work (features, releases, hotfixes) to avoid dangerous conflicts and miscodes in applications.&lt;/p&gt;

&lt;p&gt;Git Flow defines &lt;strong&gt;important branches&lt;/strong&gt;, each with a specific purpose:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Main (Master)&lt;/strong&gt;&lt;br&gt;
The main (or master) branch always contains the production-ready version &lt;br&gt;
of the application.&lt;br&gt;
It must remain stable at all times. Only fully tested and approved code &lt;br&gt;
is merged into main, typically from a release or hotfix branch.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Release&lt;/strong&gt;&lt;br&gt;
The release branch is used for final testing and debugging before &lt;br&gt;
merging into main.&lt;br&gt;
It is created from the develop branch when the development of a new &lt;br&gt;
version is complete.&lt;br&gt;
Only bug fixes or final adjustments are made here. Once testing is &lt;br&gt;
complete, this branch is merged into both main and develop.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Develop&lt;/strong&gt;&lt;br&gt;
The develop branch acts as the integration branch for features under &lt;br&gt;
active development.&lt;br&gt;
All new feature branches are created from develop, and once completed, &lt;br&gt;
they are merged back into it.&lt;br&gt;
It always contains the latest development changes and serves as a base &lt;br&gt;
for creating release branches.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Features&lt;/strong&gt;&lt;br&gt;
A feature branch is used to develop a single feature, such as &lt;br&gt;
authentication or payment integration.&lt;br&gt;
Each feature should be isolated in its own branch to keep development &lt;br&gt;
focused and avoid conflicts.&lt;br&gt;
Once the feature is complete and tested, the branch is merged into &lt;br&gt;
develop and then deleted.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hotfix&lt;/strong&gt;&lt;br&gt;
A hotfix branch is created when a critical issue needs to be fixed in &lt;br&gt;
production.&lt;br&gt;
It is branched off directly from the main, and after the fix, it is &lt;br&gt;
merged into both main and develop to ensure consistency.&lt;br&gt;
This allows urgent patches to be deployed without waiting for the next &lt;br&gt;
release cycle.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Git Flow?&lt;/strong&gt;&lt;br&gt;
Using Git Flow brings structure and clarity to the development process, helping teams manage features, fixes, and releases more efficiently—reducing errors, improving collaboration, and ensuring a smoother path from development to production.&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>gitlab</category>
      <category>softwareengineering</category>
    </item>
  </channel>
</rss>
