<?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: GT Hironobu</title>
    <description>The latest articles on DEV Community by GT Hironobu (@gt_hironobu_fc367732cd350).</description>
    <link>https://dev.to/gt_hironobu_fc367732cd350</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%2F3636206%2F7d4e8033-24ec-4eef-827a-1622cddaaf27.png</url>
      <title>DEV Community: GT Hironobu</title>
      <link>https://dev.to/gt_hironobu_fc367732cd350</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gt_hironobu_fc367732cd350"/>
    <language>en</language>
    <item>
      <title>Building Micro-Frontends with React Router v7 RSC and Module Federation</title>
      <dc:creator>GT Hironobu</dc:creator>
      <pubDate>Sat, 29 Nov 2025 14:21:52 +0000</pubDate>
      <link>https://dev.to/gt_hironobu_fc367732cd350/building-micro-frontends-with-react-router-v7-rsc-and-module-federation-ajk</link>
      <guid>https://dev.to/gt_hironobu_fc367732cd350/building-micro-frontends-with-react-router-v7-rsc-and-module-federation-ajk</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;React Router v7 introduces experimental support for React Server Components (RSC). In this comprehensive guide, we'll explore how to implement a micro-frontend architecture using RSC mode with Module Federation, creating a scalable user management system.&lt;/p&gt;

&lt;h3&gt;
  
  
  What You'll Learn
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;React Router v7 RSC mode fundamentals&lt;/li&gt;
&lt;li&gt;Module Federation configuration and setup&lt;/li&gt;
&lt;li&gt;Server Components vs Client Components patterns&lt;/li&gt;
&lt;li&gt;Dynamic remote component loading&lt;/li&gt;
&lt;li&gt;Building a production-ready user management system&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Tech Stack
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;React Router v7.9.2 (RSC mode)&lt;/li&gt;
&lt;li&gt;Vite 7.1.6&lt;/li&gt;
&lt;li&gt;@originjs/vite-plugin-federation&lt;/li&gt;
&lt;li&gt;TypeScript&lt;/li&gt;
&lt;li&gt;Tailwind CSS&lt;/li&gt;
&lt;li&gt;Drizzle ORM + SQLite&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Project Architecture
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;workspace/
├── atomic-shared/          # Remote component library
│   ├── src/
│   │   └── components/
│   │       ├── atoms/      # Button, Input, Label
│   │       ├── molecules/  # FormField, ConfirmDialog
│   │       └── organisms/  # UserForm, UserCard
│   └── vite.config.ts
└── react-router-rsc-app/   # Host application
    ├── app/
    │   ├── routes/         # Route definitions
    │   ├── components/     # Client Components
    │   ├── services/       # Business logic
    │   └── utils/          # Utilities
    └── vite.config.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Part 1: Setting Up the Remote Application
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1.1 Vite Configuration for Module Federation
&lt;/h3&gt;

&lt;p&gt;We'll create a component library following Atomic Design principles and expose it via Module Federation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import federation from '@originjs/vite-plugin-federation'

export default defineConfig({
  plugins: [
    react(),
    federation({
      name: 'atomicShared',
      filename: 'remoteEntry.js',
      exposes: {
        './Button': './src/components/atoms/Button',
        './Input': './src/components/atoms/Input',
        './Label': './src/components/atoms/Label',
        './FormField': './src/components/molecules/FormField',
        './ConfirmDialog': './src/components/molecules/ConfirmDialog',
        './UserForm': './src/components/organisms/UserForm',
        './UserCard': './src/components/organisms/UserCard',
      },
      shared: ['react', 'react-dom'],
    }),
  ],
  build: {
    modulePreload: false,
    target: 'esnext',
    minify: false,
    cssCodeSplit: false,
  },
  server: {
    port: 5001,
    cors: true,
  },
  preview: {
    port: 5001,
    cors: true,
  },
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1.2 Building Atomic Components
&lt;/h3&gt;

&lt;p&gt;Let's create reusable components following the Atomic Design pattern.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Atom: Button Component&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;import React from 'react';

export interface ButtonProps extends React.ButtonHTMLAttributes&amp;lt;HTMLButtonElement&amp;gt; {
  variant?: 'primary' | 'secondary' | 'danger';
  children: React.ReactNode;
}

export function Button({ 
  variant = 'primary', 
  children, 
  className = '',
  ...props 
}: ButtonProps) {
  const baseStyles = 'px-4 py-2 rounded font-medium transition-colors';
  const variantStyles = {
    primary: 'bg-blue-600 text-white hover:bg-blue-700',
    secondary: 'bg-gray-200 text-gray-800 hover:bg-gray-300',
    danger: 'bg-red-600 text-white hover:bg-red-700',
  };

  return (
    &amp;lt;button
      className={`${baseStyles} ${variantStyles[variant]} ${className}`}
      {...props}
    &amp;gt;
      {children}
    &amp;lt;/button&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Atom: Input Component&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;import React from 'react';

export interface InputProps extends React.InputHTMLAttributes&amp;lt;HTMLInputElement&amp;gt; {}

export function Input({ className = '', ...props }: InputProps) {
  return (
    &amp;lt;input
      className={`w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${className}`}
      {...props}
    /&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Molecule: FormField Component&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;import React from 'react';
import { Input, InputProps } from '../atoms/Input';
import { Label } from '../atoms/Label';

export interface FormFieldProps extends Omit&amp;lt;InputProps, 'id'&amp;gt; {
  label: string;
  name: string;
  error?: string;
}

export function FormField({ 
  label, 
  name, 
  error, 
  ...inputProps 
}: FormFieldProps) {
  return (
    &amp;lt;div className="space-y-1"&amp;gt;
      &amp;lt;Label htmlFor={name}&amp;gt;{label}&amp;lt;/Label&amp;gt;
      &amp;lt;Input
        id={name}
        name={name}
        {...inputProps}
      /&amp;gt;
      {error &amp;amp;&amp;amp; (
        &amp;lt;p className="text-sm text-red-600"&amp;gt;{error}&amp;lt;/p&amp;gt;
      )}
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Part 2: Configuring the Host Application
&lt;/h2&gt;

&lt;h3&gt;
  
  
  2.1 Enabling RSC Mode in Vite
&lt;/h3&gt;

&lt;p&gt;Configure React Router v7 with RSC support.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { unstable_reactRouterRSC as reactRouterRSC } from "@react-router/dev/vite";
import tailwindcss from "@tailwindcss/vite";
import rsc from "@vitejs/plugin-rsc";
import { defineConfig } from "vite";
import devtoolsJson from "vite-plugin-devtools-json";
import tsconfigPaths from "vite-tsconfig-paths";

export default defineConfig({
  plugins: [
    tailwindcss(),
    tsconfigPaths(),
    reactRouterRSC(),  // Enable RSC mode
    rsc(),             // Vite RSC plugin
    devtoolsJson(),
  ],
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.2 TypeScript Configuration
&lt;/h3&gt;

&lt;p&gt;Add type definitions for remote modules.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;declare module "atomicShared/Button" {
  export interface ButtonProps extends React.ButtonHTMLAttributes&amp;lt;HTMLButtonElement&amp;gt; {
    variant?: 'primary' | 'secondary' | 'danger';
    children: React.ReactNode;
  }
  export function Button(props: ButtonProps): JSX.Element;
}

declare module "atomicShared/Input" {
  export interface InputProps extends React.InputHTMLAttributes&amp;lt;HTMLInputElement&amp;gt; {}
  export function Input(props: InputProps): JSX.Element;
}

declare module "atomicShared/Label" {
  export interface LabelProps extends React.LabelHTMLAttributes&amp;lt;HTMLLabelElement&amp;gt; {
    children: React.ReactNode;
  }
  export function Label(props: LabelProps): JSX.Element;
}

declare module "atomicShared/FormField" {
  import { InputProps } from "atomicShared/Input";

  export interface FormFieldProps extends Omit&amp;lt;InputProps, 'id'&amp;gt; {
    label: string;
    name: string;
    error?: string;
  }
  export function FormField(props: FormFieldProps): JSX.Element;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.3 Remote Module Loader
&lt;/h3&gt;

&lt;p&gt;In RSC mode, remote modules can only be loaded on the client side.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import * as React from "react";
import * as ReactDOM from "react-dom";

type RemoteModule = {
  get: (module: string) =&amp;gt; Promise&amp;lt;() =&amp;gt; any&amp;gt;;
  init: (shared: any) =&amp;gt; void;
};

const remoteUrl = "http://localhost:5001/assets/remoteEntry.js";
let remoteModule: RemoteModule | null = null;
let remoteInitialized = false;

async function loadRemoteEntry(): Promise&amp;lt;RemoteModule&amp;gt; {
  if (typeof window === "undefined") {
    throw new Error("Remote modules can only be loaded on the client side");
  }

  if (remoteModule) {
    return remoteModule;
  }

  console.log(`[MF] Loading remote entry from: ${remoteUrl}`);

  // Import remote entry as ES module
  const remote = await import(/* @vite-ignore */ remoteUrl);

  remoteModule = remote as RemoteModule;
  return remoteModule;
}

async function initRemote(): Promise&amp;lt;void&amp;gt; {
  if (remoteInitialized) {
    return;
  }

  const remote = await loadRemoteEntry();

  // Initialize with shared dependencies
  remote.init({
    react: {
      "19.2.0": {
        get: () =&amp;gt; Promise.resolve(() =&amp;gt; React),
        loaded: true,
        from: "host",
      },
    },
    "react-dom": {
      "19.2.0": {
        get: () =&amp;gt; Promise.resolve(() =&amp;gt; ReactDOM),
        loaded: true,
        from: "host",
      },
    },
  });

  remoteInitialized = true;
  console.log("[MF] Remote initialized");
}

export async function loadRemoteModule&amp;lt;T = any&amp;gt;(moduleName: string): Promise&amp;lt;T&amp;gt; {
  // Client-side only
  if (typeof window === "undefined") {
    throw new Error("Remote modules can only be loaded on the client side");
  }

  try {
    await initRemote();

    if (!remoteModule) {
      throw new Error("Remote not initialized");
    }

    const factory = await remoteModule.get(moduleName);
    const module = factory();
    return module;
  } catch (error) {
    console.error(`[MF] Failed to load module ${moduleName}:`, error);
    throw error;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.4 Remote Component Wrappers
&lt;/h3&gt;

&lt;p&gt;Wrap remote components as Client Components.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"use client";

import { lazy } from "react";
import { loadRemoteModule } from "~/utils/loadRemoteModule";

/**
 * Remote Components from atomic-shared via Module Federation
 * 
 * These components require "use client" directive because:
 * - They are dynamically loaded from a remote source
 * - They use React hooks and interactive features
 * - Module Federation operates on the client side
 */

export const RemoteButton = lazy(() =&amp;gt;
  loadRemoteModule("./Button").then((m) =&amp;gt; ({ default: m.Button }))
);

export const RemoteInput = lazy(() =&amp;gt;
  loadRemoteModule("./Input").then((m) =&amp;gt; ({ default: m.Input }))
);

export const RemoteLabel = lazy(() =&amp;gt;
  loadRemoteModule("./Label").then((m) =&amp;gt; ({ default: m.Label }))
);

export const RemoteFormField = lazy(() =&amp;gt;
  loadRemoteModule("./FormField").then((m) =&amp;gt; ({ default: m.FormField }))
);

export const RemoteUserForm = lazy(() =&amp;gt;
  loadRemoteModule("./UserForm").then((m) =&amp;gt; ({ default: m.UserForm }))
);

export const RemoteUserCard = lazy(() =&amp;gt;
  loadRemoteModule("./UserCard").then((m) =&amp;gt; ({ default: m.UserCard }))
);

export const RemoteConfirmDialog = lazy(() =&amp;gt;
  loadRemoteModule("./ConfirmDialog").then((m) =&amp;gt; ({ default: m.ConfirmDialog }))
);

// Re-export types
export type { ButtonProps } from "atomicShared/Button";
export type { InputProps } from "atomicShared/Input";
export type { LabelProps } from "atomicShared/Label";
export type { FormFieldProps } from "atomicShared/FormField";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Part 3: Implementing Routes with RSC
&lt;/h2&gt;

&lt;h3&gt;
  
  
  3.1 User Registration Page (Server Component)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { redirect } from "react-router";
import type { Route } from "./+types/register";
import { userService } from "~/services/user.service";
import { RegisterForm } from "~/components/RegisterForm";

export function meta({}: Route.MetaArgs) {
  return [
    { title: "Register - User Management System (RSC)" },
    { name: "description", content: "Create a new account" },
  ];
}

// Server-side action
export async function action({ request }: Route.ActionArgs) {
  const formData = await request.formData();
  const username = formData.get("username") as string;
  const email = formData.get("email") as string;
  const password = formData.get("password") as string;

  const result = await userService.createUser({
    username,
    email,
    password,
  });

  if (!result.success) {
    return { errors: result.errors || {} };
  }

  return redirect("/login");
}

/**
 * Register Page - Server Component
 * 
 * This is a React Server Component that renders on the server.
 * The form itself is a Client Component for interactivity.
 */
export function ServerComponent({ actionData }: Route.ComponentProps) {
  return (
    &amp;lt;div className="min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8"&amp;gt;
      &amp;lt;div className="max-w-md w-full space-y-8"&amp;gt;
        &amp;lt;div&amp;gt;
          &amp;lt;h2 className="mt-6 text-center text-3xl font-extrabold text-gray-900"&amp;gt;
            Create Your Account
          &amp;lt;/h2&amp;gt;
          &amp;lt;p className="mt-2 text-center text-sm text-gray-600"&amp;gt;
            Or{' '}
            &amp;lt;a
              href="/login"
              className="font-medium text-blue-600 hover:text-blue-500"
            &amp;gt;
              sign in to your account
            &amp;lt;/a&amp;gt;
          &amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;

        &amp;lt;div className="mt-8 bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10"&amp;gt;
          &amp;lt;div className="mb-4 p-4 bg-blue-50 border border-blue-200 rounded-md"&amp;gt;
            &amp;lt;p className="text-sm text-blue-800"&amp;gt;
              🚀 &amp;lt;strong&amp;gt;React Server Component:&amp;lt;/strong&amp;gt; This page is rendered on the server
            &amp;lt;/p&amp;gt;
          &amp;lt;/div&amp;gt;

          &amp;lt;RegisterForm errors={actionData?.errors} /&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.2 Registration Form (Client Component with Module Federation)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"use client";

import { Suspense, useState } from "react";
import { Form, useNavigation } from "react-router";
import { RemoteFormField, RemoteButton } from "./RemoteComponents";

interface RegisterFormProps {
  errors?: {
    username?: string;
    email?: string;
    password?: string;
  };
}

/**
 * RegisterForm - Client Component with Module Federation
 * 
 * Uses atomic-shared components via Module Federation
 */
export function RegisterForm({ errors }: RegisterFormProps) {
  const [username, setUsername] = useState("");
  const [email, setEmail] = useState("");
  const [password, setPassword] = useState("");
  const navigation = useNavigation();
  const isSubmitting = navigation.state === "submitting";

  return (
    &amp;lt;Suspense fallback={&amp;lt;div className="text-center"&amp;gt;Loading...&amp;lt;/div&amp;gt;}&amp;gt;
      &amp;lt;Form method="post" className="space-y-6"&amp;gt;
        &amp;lt;RemoteFormField
          label="Username"
          name="username"
          value={username}
          onChange={(e) =&amp;gt; setUsername(e.target.value)}
          error={errors?.username}
          required
        /&amp;gt;

        &amp;lt;RemoteFormField
          label="Email Address"
          name="email"
          type="email"
          value={email}
          onChange={(e) =&amp;gt; setEmail(e.target.value)}
          error={errors?.email}
          required
        /&amp;gt;

        &amp;lt;RemoteFormField
          label="Password"
          name="password"
          type="password"
          value={password}
          onChange={(e) =&amp;gt; setPassword(e.target.value)}
          error={errors?.password}
          required
        /&amp;gt;

        &amp;lt;RemoteButton
          type="submit"
          variant="primary"
          className="w-full"
          disabled={isSubmitting}
        &amp;gt;
          {isSubmitting ? "Creating Account..." : "Create Account"}
        &amp;lt;/RemoteButton&amp;gt;
      &amp;lt;/Form&amp;gt;
    &amp;lt;/Suspense&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.3 Login Page
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { redirect } from "react-router";
import type { Route } from "./+types/login";
import { authService } from "~/services/auth.service";
import { sessionService } from "~/services/session.service";
import { LoginForm } from "~/components/LoginForm";

export function meta({}: Route.MetaArgs) {
  return [
    { title: "Login - User Management System (RSC)" },
    { name: "description", content: "Sign in to your account" },
  ];
}

export async function action({ request }: Route.ActionArgs) {
  const formData = await request.formData();
  const email = formData.get("email") as string;
  const password = formData.get("password") as string;

  const authResult = await authService.login(email, password);

  if (!authResult.success || !authResult.user) {
    return { error: authResult.error || "Login failed" };
  }

  const session = await sessionService.createSession(authResult.user.id);

  return redirect("/dashboard", {
    headers: {
      "Set-Cookie": `sessionId=${session.id}; Path=/; HttpOnly; SameSite=Lax; Max-Age=${24 * 60 * 60}`,
    },
  });
}

export function ServerComponent({ actionData }: Route.ComponentProps) {
  return (
    &amp;lt;div className="min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8"&amp;gt;
      &amp;lt;div className="max-w-md w-full space-y-8"&amp;gt;
        &amp;lt;div&amp;gt;
          &amp;lt;h2 className="mt-6 text-center text-3xl font-extrabold text-gray-900"&amp;gt;
            Sign In to Your Account
          &amp;lt;/h2&amp;gt;
          &amp;lt;p className="mt-2 text-center text-sm text-gray-600"&amp;gt;
            Or{' '}
            &amp;lt;a
              href="/register"
              className="font-medium text-blue-600 hover:text-blue-500"
            &amp;gt;
              create a new account
            &amp;lt;/a&amp;gt;
          &amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;

        &amp;lt;div className="mt-8 bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10"&amp;gt;
          &amp;lt;div className="mb-4 p-4 bg-blue-50 border border-blue-200 rounded-md"&amp;gt;
            &amp;lt;p className="text-sm text-blue-800"&amp;gt;
              🚀 &amp;lt;strong&amp;gt;React Server Component:&amp;lt;/strong&amp;gt; Authentication runs on the server
            &amp;lt;/p&amp;gt;
          &amp;lt;/div&amp;gt;

          &amp;lt;LoginForm error={actionData?.error} /&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Part 4: Server vs Client Components
&lt;/h2&gt;

&lt;h3&gt;
  
  
  4.1 Core Principles
&lt;/h3&gt;

&lt;p&gt;In RSC mode, all components are Server Components by default.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Server Component (default)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ServerComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Runs only on the server&lt;/span&gt;
  &lt;span class="c1"&gt;// Database access, authentication, etc.&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Server&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Client Component (explicit)&lt;/span&gt;
&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ClientComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Runs on the client&lt;/span&gt;
  &lt;span class="c1"&gt;// useState, useEffect, event handlers, etc.&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Client&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.2 Module Federation Integration
&lt;/h3&gt;

&lt;p&gt;Remote components must always be treated as Client Components.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ❌ Won't work - Loading remote modules in Server Component&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ServerComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;RemoteButton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;loadRemoteModule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./Button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;RemoteButton&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Click&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/RemoteButton&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// ✅ Correct - Loading remote modules in Client Component&lt;/span&gt;
&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ClientComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;RemoteButton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;loadRemoteModule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./Button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Suspense&lt;/span&gt; &lt;span class="nx"&gt;fallback&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Loading&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&amp;gt;}&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;RemoteButton&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Click&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/RemoteButton&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Suspense&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.3 Recommended Pattern
&lt;/h3&gt;

&lt;p&gt;Server Components should fetch data and pass it to Client Components.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// routes/dashboard.tsx (Server Component)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ServerComponent&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;loaderData&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;Route&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ComponentProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;loaderData&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Dashboard&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* Fetch data in Server Component */&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* Pass to Client Component for interactivity */&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;UserList&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// components/UserList.tsx (Client Component)&lt;/span&gt;
&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;UserList&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;selectedUser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setSelectedUser&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;RemoteUserCard&lt;/span&gt;
          &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setSelectedUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
        &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="p"&gt;))}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Part 5: Data Layer Implementation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  5.1 Database Schema (Drizzle ORM)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";

export const users = sqliteTable("users", {
  id: text("id").primaryKey(),
  username: text("username").notNull().unique(),
  email: text("email").notNull().unique(),
  passwordHash: text("password_hash").notNull(),
  createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
  updatedAt: integer("updated_at", { mode: "timestamp" }).notNull(),
});

export const sessions = sqliteTable("sessions", {
  id: text("id").primaryKey(),
  userId: text("user_id")
    .notNull()
    .references(() =&amp;gt; users.id, { onDelete: "cascade" }),
  expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
  createdAt: integer("created_at", { mode: "timestamp" }).notNull(),
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.2 Service Layer
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { userRepository } from "~/repositories/user.repository";
import { hashPassword } from "~/utils/password";

export const userService = {
  async createUser(data: { username: string; email: string; password: string }) {
    const errors: Record&amp;lt;string, string&amp;gt; = {};

    // Validation
    if (data.username.length &amp;lt; 3) {
      errors.username = "Username must be at least 3 characters";
    }
    if (!data.email.includes("@")) {
      errors.email = "Please enter a valid email address";
    }
    if (data.password.length &amp;lt; 8) {
      errors.password = "Password must be at least 8 characters";
    }

    if (Object.keys(errors).length &amp;gt; 0) {
      return { success: false, errors };
    }

    // Check existing user
    const existingUser = await userRepository.findByEmail(data.email);
    if (existingUser) {
      return {
        success: false,
        errors: { email: "This email is already registered" },
      };
    }

    // Create user
    const passwordHash = await hashPassword(data.password);
    const user = await userRepository.create({
      username: data.username,
      email: data.email,
      passwordHash,
    });

    return { success: true, user };
  },

  async getAllUsers() {
    return userRepository.findAll();
  },

  async getUserById(id: string) {
    return userRepository.findById(id);
  },

  async updateUser(id: string, data: Partial&amp;lt;{ username: string; email: string }&amp;gt;) {
    return userRepository.update(id, data);
  },

  async deleteUser(id: string) {
    return userRepository.delete(id);
  },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.3 Repository Pattern
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { db } from "~/db";
import { users } from "~/db/schema";
import { eq } from "drizzle-orm";
import { nanoid } from "nanoid";

export const userRepository = {
  async create(data: {
    username: string;
    email: string;
    passwordHash: string;
  }) {
    const user = {
      id: nanoid(),
      username: data.username,
      email: data.email,
      passwordHash: data.passwordHash,
      createdAt: new Date(),
      updatedAt: new Date(),
    };

    await db.insert(users).values(user);
    return user;
  },

  async findById(id: string) {
    const [user] = await db.select().from(users).where(eq(users.id, id));
    return user || null;
  },

  async findByEmail(email: string) {
    const [user] = await db.select().from(users).where(eq(users.email, email));
    return user || null;
  },

  async findAll() {
    return db.select().from(users);
  },

  async update(id: string, data: Partial&amp;lt;{ username: string; email: string }&amp;gt;) {
    await db
      .update(users)
      .set({ ...data, updatedAt: new Date() })
      .where(eq(users.id, id));

    return this.findById(id);
  },

  async delete(id: string) {
    await db.delete(users).where(eq(users.id, id));
  },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Part 6: Running the Application
&lt;/h2&gt;

&lt;h3&gt;
  
  
  6.1 Start the Remote Application
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;atomic-shared
npm &lt;span class="nb"&gt;install
&lt;/span&gt;npm run build
npm run preview  &lt;span class="c"&gt;# http://localhost:5001&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.2 Start the Host Application
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;react-router-rsc-app
npm &lt;span class="nb"&gt;install
&lt;/span&gt;npm run db:generate  &lt;span class="c"&gt;# Generate database schema&lt;/span&gt;
npm run db:migrate   &lt;span class="c"&gt;# Run migrations&lt;/span&gt;
npm run dev          &lt;span class="c"&gt;# http://localhost:5173&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Part 7: Troubleshooting
&lt;/h2&gt;

&lt;h3&gt;
  
  
  7.1 Remote Modules Not Loading
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Error: Remote modules can only be loaded on the client side&lt;/span&gt;

&lt;span class="c1"&gt;// Solution: Ensure you're using Client Components&lt;/span&gt;
&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;RemoteButton&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./RemoteComponents&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.2 CORS Errors
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// vite.config.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;server&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;cors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;// Enable CORS&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.3 Shared Dependency Version Mismatch
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Use&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;same&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;versions&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;package.json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"dependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"react"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"19.1.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"react-dom"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"19.1.1"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.4 TypeScript Errors
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Add type declarations for remote modules&lt;/span&gt;
&lt;span class="kr"&gt;declare&lt;/span&gt; &lt;span class="kr"&gt;module&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;atomicShared/Button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;ButtonProps&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ButtonProps&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;JSX&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Element&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Component Organization
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Atoms&lt;/strong&gt;: Basic building blocks (Button, Input, Label)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Molecules&lt;/strong&gt;: Simple combinations (FormField, Card)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Organisms&lt;/strong&gt;: Complex components (UserForm, UserList)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Server vs Client Components
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Use Server Components for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data fetching&lt;/li&gt;
&lt;li&gt;Database queries&lt;/li&gt;
&lt;li&gt;Authentication&lt;/li&gt;
&lt;li&gt;Static content&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Use Client Components for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Interactive features&lt;/li&gt;
&lt;li&gt;State management&lt;/li&gt;
&lt;li&gt;Event handlers&lt;/li&gt;
&lt;li&gt;Remote components&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Module Federation
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Keep shared dependencies aligned&lt;/li&gt;
&lt;li&gt;Use lazy loading for remote components&lt;/li&gt;
&lt;li&gt;Implement proper error boundaries&lt;/li&gt;
&lt;li&gt;Add loading states with Suspense&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Performance Optimization
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Minimize client-side JavaScript&lt;/li&gt;
&lt;li&gt;Leverage Server Components for static content&lt;/li&gt;
&lt;li&gt;Use code splitting effectively&lt;/li&gt;
&lt;li&gt;Implement proper caching strategies&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Combining React Router v7's RSC mode with Module Federation provides powerful benefits:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Optimized Server-Side Rendering&lt;/strong&gt;: Server Components efficiently handle server-side processing&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Component Reusability&lt;/strong&gt;: Share components across multiple applications via Module Federation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reduced Bundle Size&lt;/strong&gt;: Server code stays on the server&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Improved Developer Experience&lt;/strong&gt;: Atomic Design + Micro-frontends architecture&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;While RSC mode is still experimental, it offers a compelling architecture similar to Next.js App Router but within the React Router ecosystem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://reactrouter.com/" rel="noopener noreferrer"&gt;React Router v7 Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://react.dev/blog/2023/03/22/react-labs-what-we-have-been-working-on-march-2023#react-server-components" rel="noopener noreferrer"&gt;React Server Components&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://module-federation.io/" rel="noopener noreferrer"&gt;Module Federation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/originjs/vite-plugin-federation" rel="noopener noreferrer"&gt;@originjs/vite-plugin-federation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://atomicdesign.bradfrost.com/" rel="noopener noreferrer"&gt;Atomic Design Methodology&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sample Code
&lt;/h2&gt;

&lt;p&gt;The complete sample code is available on GitHub:&lt;br&gt;
&lt;a href="https://github.com/hironobugt/react-router-rsc-app" rel="noopener noreferrer"&gt;react-router-rsc-app&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/hironobugt/my-react-router-app" rel="noopener noreferrer"&gt;my-react-router-ssr-app&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/hironobugt/my-atomic-shared" rel="noopener noreferrer"&gt;my-atomic-shared&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;If you found this article helpful, please give it a ❤️ and share your thoughts in the comments!&lt;/p&gt;

</description>
      <category>react</category>
      <category>microservices</category>
    </item>
  </channel>
</rss>
