<?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 Miloš Dželetović on Medium]]></title>
        <description><![CDATA[Stories by Miloš Dželetović on Medium]]></description>
        <link>https://medium.com/@miloshinjo?source=rss-451e3a7dfa10------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qvgmeM9uUloLUk3KF7iPkg.png</url>
            <title>Stories by Miloš Dželetović on Medium</title>
            <link>https://medium.com/@miloshinjo?source=rss-451e3a7dfa10------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 11:12:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@miloshinjo/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[Bridging the gap: How Remix and Next.js are redefining full-stack web development]]></title>
            <link>https://medium.com/symphonyis/bridging-the-gap-how-remix-and-next-js-are-redefining-full-stack-web-development-11cbaa3d40e3?source=rss-451e3a7dfa10------2</link>
            <guid isPermaLink="false">https://medium.com/p/11cbaa3d40e3</guid>
            <category><![CDATA[remix]]></category>
            <category><![CDATA[full-stack]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-server-component]]></category>
            <dc:creator><![CDATA[Miloš Dželetović]]></dc:creator>
            <pubDate>Thu, 14 Nov 2024 15:17:36 GMT</pubDate>
            <atom:updated>2024-11-14T15:17:36.645Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SMfZAA81QkiKySp4j43Llw.png" /></figure><p>React has come a long way since its inception, and recent developments are opening up new possibilities for web development. Modern frameworks are now exploring ways to seamlessly integrate frontend and backend capabilities, offering developers new tools to create more cohesive web applications.</p><p>These frameworks are introducing innovative approaches that extend React’s component model to the server while also incorporating robust backend functionalities. As a result, developers are discovering more streamlined and powerful ways to build web applications.</p><p>Key areas of change include:</p><ol><li>Writing React: The way we compose React applications is evolving. Server components, streaming SSR, and other new patterns are changing how we structure our code and think about data flow.</li><li>Server-to-Server Interactions: These frameworks are reimagining how the frontend communicates with backend services, often simplifying and optimizing these interactions.</li><li>Unified Backend and Frontend: Perhaps most importantly, these frameworks are positioning themselves as comprehensive solutions that can serve as both the backend and frontend of web applications.</li></ol><p>At the core of any web application are two fundamental processes which we will explore in this post, and those are:</p><ol><li><strong>Data querying (how we get the data to the user’s browser and make sure it’s fresh)</strong></li><li><strong>Data mutation (How we change it over time)</strong></li></ol><p>Traditionally, both data querying and data mutation has been implemented through communication with the JSON APIs written in server side languages like PHP, Go, Python, Ruby and many others, with the browser making calls to the server.</p><p>This post aims to explore an alternative approach: the use of frameworks that integrate Node.js and React capabilities into one. These frameworks offer a different paradigm for handling data flow and mutations. Drawing from my experience primarily as a frontend developer, with some exposure to backend development, I’ll discuss the potential advantages and drawbacks of this approach.</p><h3>Data Querying</h3><p>Data querying is a fundamental aspect of web application development, determining how information is retrieved and presented to users. In modern React-based frameworks, the approach to data querying has evolved significantly, moving beyond traditional client-side fetching to more efficient server-side methods. This section explores how two popular frameworks, Remix and Next.js, handle data querying, highlighting their unique approaches and the benefits they offer to developers.</p><h3>Remix Loaders</h3><p>Remix represents an innovative approach to web development, seamlessly blending Node.js capabilities with React’s component model. At its core, Remix introduces two powerful concepts: <em>loaders</em> and <em>actions</em>. These features exemplify how Remix bridges the gap between backend and frontend, offering developers a unified way to handle data querying and mutations.</p><p>Loaders in Remix are <em>server-side functions</em> that fetch and prepare data for your React components and here’s why they’re significant:</p><ol><li>Improved Performance: By moving data fetching to the server, Remix reduces client-side network requests and payload sizes.</li><li>Simplified Data Flow: Loaders provide a clear, predictable pattern for getting data into your components.</li><li>Access to Backend Resources: Loaders can directly interact with databases, file systems, and other server-side resources.</li><li>Data Shaping: You can shape your data on the server before sending it to the client, reducing the need for client-side data manipulation.</li></ol><p>Here’s an example of a loader function that checks for user’s authentication and fetches a list of projects:</p><pre>// routes/_index/route.tsx<br>import { type LoaderFunction, redirect } from &#39;@remix-run/node&#39;;<br>import { useLoaderData } from &#39;@remix-run/react&#39;;<br>import { eq } from &#39;drizzle-orm&#39;;<br><br>import { authenticator } from &#39;~/.server/auth/auth&#39;;<br>import { db } from &#39;~/.server/db/client&#39;;<br>import { type Project, projects } from &#39;~/.server/db/schema&#39;;<br><br>import { ProjectsList } from &#39;~/components/pages/dashboard/index/ProjectsList&#39;;<br><br>// Loader data type for the dashboard index route - /dashboard<br>type LoaderData = {<br>  projects: Project[];<br>};<br><br>// Dashboard index route loader - /dashboard<br>export const loader: LoaderFunction = async ({ request }) =&gt; {<br>  // Check for user&#39;s auth, redirect to login if it fails<br>  // (this part would usually be abstracted somewhere else)<br>  const user = await authenticator.isAuthenticated(request, {<br>    failureRedirect: &#39;/login&#39;,<br>  });<br><br>  // User is not activated, redirect to account activation page<br>  if (user.activatedAt === null) {<br>    return redirect(&#39;/account-activation&#39;);<br>  }<br><br>  // Select projects from the database for the user<br>  const selection = await db.query.projects.findMany({<br>    where: (projects, { eq }) =&gt; eq(projects.userId, user.id),<br>  });<br><br>  // Don&#39;t send archived projects to the client<br>  const filteredSelection = selection.filter(<br>    (project) =&gt; project.archivedAt === null<br>  );<br><br>  // If there are no projects, redirect to the new project page<br>  if (filteredSelection.length === 0) {<br>    return redirect(&#39;/dashboard/new-project&#39;);<br>  }<br> <br>  // Prepare loader data for the client<br>  const loaderData: LoaderData = {<br>    projects: filteredSelection,<br>  };<br><br>  // Return the data to the client<br>  // Only this part of the loader gets exposed to the client side<br>  return loaderData;<br>};</pre><p>In our example loader, we’re leveraging several key Remix features. The request object, passed as part of the loader’s arguments, encapsulates all the information about the incoming HTTP request. We use this to authenticate the user via the <em>authenticator.isAuthenticated()</em> method. If authentication fails, we redirect the user to the login page using a server side redirect built into Remix.</p><p>Once authenticated, we perform a series of checks and data fetching operations. We verify if the user’s account is activated, redirecting them to an activation page if necessary. Then, we query our database for the user’s projects using Drizzle ORM’s query builder. This showcases how Remix allows us to seamlessly integrate with various database libraries and ORMs.</p><p>After fetching the projects, we apply some business logic, filtering out archived projects and checking if the user has any active projects. If not, we redirect them to create a new project. This demonstrates how loaders can not only fetch data but also control application flow based on that data.</p><p>Finally, we prepare and return the data that will be sent to the client. By defining a <em>LoaderData</em> type, we ensure type safety between our server-side data fetching and client-side rendering. This typed approach helps prevent runtime errors and improves developer experience.</p><p>Remix’s loader system exemplifies the framework’s commitment to progressive enhancement and separation of concerns. By associating loaders with specific routes, we can define precise data requirements for each page or section of our app. This route-based approach to data loading ensures that only necessary data is fetched, contributing to faster page loads and a more efficient application overall.</p><p>In essence, Remix loaders provide a robust foundation for building secure, performant, and maintainable web applications. They enable us to craft experiences that work well across a wide range of devices and network conditions, all while keeping our codebase clean and our data handling secure.</p><p>This is the example of how we can consume the data that is returned from our loader, using a hook that comes with Remix, <em>useLoaderData</em>:</p><pre>// Index route component /<br>export default function DashboardIndexRoute() {<br>  // Get the projects from the loader data<br>  const { projects } = useLoaderData&lt;typeof loader&gt;() as LoaderData;<br><br>  return (<br>    &lt;main className=&quot;flex flex-1 flex-col pb-6&quot;&gt;<br>      &lt;div className=&quot;flex flex-1 flex-col gap-4&quot;&gt;<br>        &lt;PageHeading<br>          subtitle=&quot;Browse all your current projects&quot;<br>          title=&quot;Dashboard&quot;<br>        &gt;<br>          &lt;LinkButton to=&quot;/dashboard/new-project&quot;&gt;<br>            &lt;Plus /&gt; New Project<br>          &lt;/LinkButton&gt;<br>        &lt;/PageHeading&gt;<br><br>        &lt;ProjectsList projects={projects} /&gt;<br>      &lt;/div&gt;<br>    &lt;/main&gt;<br>  );<br>}</pre><p>This approach works well, but as mentioned earlier, loaders are tightly tied to routes. This means we must load all necessary data in one function, and components can only consume data — they can’t make requests to fetch it. React Server Components (RSC), a new feature of React, aims to change this approach. Currently, Next.js is the only popular framework implementing RSC, so we’ll examine its approach to data querying.</p><h3>Next.js and React Server Components</h3><p>React Server Components allow developers to write React components that are executed and rendered entirely on the server. This is different from traditional server-side rendering, where the entire app is rendered on the server and then hydrated on the client.</p><p>With Server Components:</p><ol><li>The component’s logic runs on the server, not in the user’s browser.</li><li>Only the rendered HTML is sent to the client, not the component’s JavaScript code.</li><li>They can seamlessly integrate with client-side components in the same application.</li></ol><p>Key difference between the Remix model and the newer React Server Components (RSC) model is that RSC can be placed anywhere in the app and be rendered on the server. For example, a deeply nested component in your React tree can be a Server Component, allowing for more granular control over server-side rendering.</p><p>In Remix, server-side operations are typically confined to route-level loaders and actions. RSC, on the other hand, allows you to:</p><ol><li>Sprinkle server-rendered components throughout your app, even within client components.</li><li>Fetch data at the component level rather than just at the route level.</li><li>Keep sensitive operations or large dependencies server-side, even for non-route components.</li></ol><p>This flexibility can lead to more optimized applications, as developers can make fine-grained decisions about what runs on the server versus the client, potentially improving both performance and security.</p><p>Let’s look at our previous example implemented as a React Server Component in Next.js:</p><pre>// components/ProjectList.tsx<br>import { redirect } from &#39;next/navigation&#39;;<br>import { eq } from &#39;drizzle-orm&#39;;<br>import { getServerSession } from &#39;next-auth/next&#39;;<br>import { authOptions } from &#39;@/app/api/auth/[...nextauth]/route&#39;;<br>import { db } from &#39;@/db/client&#39;;<br>import { projects } from &#39;@/db/schema&#39;;<br><br>// Helper function to fetch and filter projects for a user<br>async function getProjects(userId: string) {<br>  // Query the database for projects belonging to the user<br>  const selection = await db.query.projects.findMany({<br>    where: eq(projects.userId, userId),<br>  });<br><br>  // Filter out archived projects<br>  return selection.filter((project) =&gt; project.archivedAt === null);<br>}<br><br>// This is a reusable Server Component for displaying a list of projects<br>export async function ProjectList() {<br>  // Get the user&#39;s session<br>  const session = await getServerSession(authOptions);<br><br>  // If there&#39;s no session or user, redirect to the login page<br>  if (!session || !session.user) {<br>    redirect(&#39;/login&#39;);<br>  }<br><br>  // If the user&#39;s account is not activated, redirect to the activation page<br>  if (!session.user.activatedAt) {<br>    redirect(&#39;/account-activation&#39;);<br>  }<br><br>  // Fetch the user&#39;s projects<br>  const projects = await getProjects(session.user.id);<br><br>  // If the user has no projects and redirectOnEmpty is true, redirect to the new project page<br>  if (projects.length === 0) {<br>    redirect(&#39;/dashboard/new-project&#39;);<br>  }<br><br>  // Render the list of projects<br>  return (<br>    &lt;ul&gt;<br>      {projects.map((project) =&gt; (<br>        &lt;li key={project.id}&gt;{project.name}&lt;/li&gt;<br>      ))}<br>    &lt;/ul&gt;<br>  );<br>}</pre><p>This <em>ProjectList</em> component showcases the power and flexibility of React Server Components. Unlike the Remix loader we saw earlier, this component <em>encapsulates both the data fetching logic and the rendering in a reusable unit</em>. It can be easily integrated into different parts of your application, demonstrating the granular nature of RSC.</p><p>The component handles authentication checks and data fetching, all on the server. This approach keeps sensitive operations (like database queries) on the server while sending only the rendered HTML to the client, enhancing both security and performance.</p><p>You can use this component in various parts of your application like this:</p><pre>// In a dashboard page<br>import { ProjectList } from &#39;@/components/ProjectList&#39;;<br><br>export default function DashboardPage() {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Dashboard&lt;/h1&gt;<br>      &lt;ProjectList /&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>This level of reusability is a key advantage of React Server Components. They allow you to create efficient, secure, and modular components that can be used throughout your application, blending seamlessly with client-side React components when needed.</p><p>By leveraging React Server Components, Next.js applications can achieve a fine balance between server-side and client-side rendering, optimizing for both performance and developer experience. The ability to perform data fetching and authentication at the component level, rather than just at the route level, offers developers more control over their application’s behavior and performance characteristics.</p><h3>Data Mutation</h3><p>Data mutation is a critical aspect of web application development, determining how information is created, updated, and deleted within a system. In modern React-based frameworks, the approach to data mutation has evolved significantly, moving beyond traditional client-side updates to more efficient and reliable server-side methods. This section examines how Remix and Next.js handle data mutation, highlighting their unique approaches and the benefits they offer to developers in managing state changes and ensuring data consistency.</p><h3>Remix Actions</h3><p>In addition to loaders, each route in Remix can also have an action. Actions are server-side functions designed to handle data mutations, typically triggered by form submissions or other POST, PUT, PATCH, or DELETE requests. They allow you to perform server-side data modifications, such as updating a database or interacting with external APIs, before sending a response back to the client.</p><p>Remix leverages HTML forms as a core part of its data mutation strategy. This approach not only aligns with web standards but also provides a robust, JavaScript-independent way to handle user inputs and data submissions. By using native HTML forms, Remix ensures that your application remains functional even if JavaScript fails to load or execute, enhancing the overall reliability and accessibility of your web app.</p><p>An example of a typical action that any web app might have, that is dealing with sending an email for account activation:</p><pre>import jwt from &#39;jsonwebtoken&#39;;<br>import nodemailer from &#39;nodemailer&#39;;<br>import { type ActionFunction } from &#39;@remix-run/node&#39;;<br>import { db } from &#39;~/.server/db/client&#39;;<br>import { users } from &#39;~/.server/db/schema&#39;;<br>import { eq } from &#39;drizzle-orm&#39;;<br>import { emailOptions, transportOptions } from &#39;~/.server/email/sender&#39;;<br>import { render } from &#39;@react-email/render&#39;;<br>import { AccountActivationEmail } from &#39;~/.server/email/EmailTemplates&#39;;<br><br>// Action for the /account-activation route<br>export const action: ActionFunction = async ({ request }) =&gt; {<br>  // Every request object contains from data that we can parse<br>  const formData = await request.formData();<br><br>  // Get email from the form data<br>  const email = formData.get(&#39;email&#39;) as string;<br><br>  // Generate activation token that expires in 15 minutes<br>  const activationToken = jwt.sign({}, &#39;secret&#39;, { expiresIn: &#39;15m&#39; });<br><br>  // Save the token in the database<br>  await db<br>    .update(users)<br>    .set({ activationToken })<br>    .where(eq(users.email, email));<br><br>  // Create a nodemailer transporter<br>  const transporter = nodemailer.createTransport(transportOptions);<br><br>  // Send account confirmation email<br>  await transporter.sendMail({<br>    from: emailOptions.from,<br>    to: email,<br>    subject: &#39;Welcome to My App&#39;,<br>    html: render(<br>      AccountActivationEmail({ url: `${request.headers.get(&#39;Origin&#39;)}` })<br>    ),<br>  });<br><br>  // Action must return something; we return null as we don&#39;t need the result<br>  return null;<br>};</pre><p>In this example, we’re utilizing a Remix action to handle account activation, demonstrating how server-side operations can be efficiently managed in a web application.</p><p>The action function receives a request object, which contains all the information about the incoming HTTP request. We use this to extract the form data submitted by the user, specifically their email address.</p><p>Once we have the email, we generate a JSON Web Token (JWT) with a 15-minute expiration time. and we interact with our database using the Drizzle ORM. We update the user’s record, setting the newly generated activation token. This showcases how Remix actions can seamlessly integrate with database operations, allowing us to modify server-side state in response to user actions.</p><p>Finally, the action returns null. In Remix, actions must return something, but in this case, we don’t need to use anything from the return value. If we wanted, we could return some piece of data about the operation to the client so that the client can display visual feedback to the user about the success of the mutation or something else.</p><h3>Security and Validation</h3><p>By handling these operations on the server, we ensure:</p><ul><li>Sensitive operations like token generation are kept secure.</li><li>We can perform server-side validation before making any database changes.</li><li>Email sending is handled reliably without exposing sensitive SMTP credentials to the client.</li></ul><h3>The Client-Side Perspective</h3><p>You might wonder, “<em>How does the client know the operation was successful</em>?” This is where Remix shines. After the action completes, Remix automatically revalidates the data on the page. This means the UI will update to reflect the new state without requiring a full page reload. The user gets immediate feedback, and the application remains responsive. This seamless integration between server-side actions and client-side updates is a key feature of Remix, enabling developers to create highly interactive and responsive web applications with minimal effort. Beside automatic revalidation, we can also take over control for some more complicated scenarios if the need arises.</p><h3>Why This Approach is Effective</h3><ol><li><strong>Security</strong>: Sensitive operations are performed server-side, away from potential client-side vulnerabilities.</li><li><strong>Simplicity</strong>: The action encapsulates all the logic for account activation in one place.</li><li><strong>Performance</strong>: By handling everything server-side and using Remix’s automatic revalidation, we avoid unnecessary API calls and keep the UI snappy.</li><li><strong>Scalability</strong>: This pattern can easily be extended to handle more complex workflows or additional account management features.</li></ol><p>In conclusion, Remix actions provide a powerful, secure, and efficient way to handle server-side operations. They allow us to keep sensitive logic on the server while still providing a responsive and up-to-date user experience.</p><p>Since this action was triggered by a HTML form and executed on the server, the browser’s network tab won’t show anything, but the UI will be fresh with new data.</p><p>While Remix’s approach to data mutations and revalidation is powerful and elegant, it’s worth noting one of its limitations: <em>each route can only have a single loader function</em>. This constraint, while promoting simplicity in many cases, can become a bottleneck in more complex scenarios.</p><p>The single loader per route design means that all data fetching for a given route must be channeled through one function. For routes with multiple, independent data requirements, this can lead to less modular and potentially less efficient code. Developers might find themselves cramming disparate data fetching logic into a single action, which can impact code organization and maintainability.</p><p>Interesting recent development: OpenAI has migrated ChatGPT’s frontend code from Next.js to Remix. However, they’ve opted not to utilize Remix’s action functionality in their codebase.</p><h3>Next.js Server Actions</h3><p>While Remix actions are tied to routes and limited to one action per route, Next.js offers more flexibility with <strong>server actions</strong>. These can be triggered from various places where we typically initiate actions, such as button event listeners or forms.</p><p><strong>Server actions</strong> provide a more granular approach to data mutations compared to Remix. They can be defined at a component level, promoting modularity and reusability in your codebase. This flexibility allows developers to structure their mutation logic more intuitively, often aligning closely with the UI components that trigger these actions.</p><p>Let’s look at an example of how a <strong>server action</strong> would handle the previous case with user account activation:</p><pre>&#39;use server&#39;;<br><br>import jwt from &#39;jsonwebtoken&#39;;<br>import nodemailer from &#39;nodemailer&#39;;<br>import { db } from &#39;@/db/client&#39;;<br>import { users } from &#39;@/db/schema&#39;;<br>import { eq } from &#39;drizzle-orm&#39;;<br>import { emailOptions, transportOptions } from &#39;@/email/sender&#39;;<br>import { render } from &#39;@react-email/render&#39;;<br>import { AccountActivationEmail } from &#39;@/email/EmailTemplates&#39;;<br>import { revalidatePath } from &#39;next/cache&#39;;<br><br>export async function activateAccountAction(formData: FormData) {<br>// Form Data is available to server actions used with HTML forms<br>  const email = formData.get(&#39;email&#39;) as string;<br><br>// Save the token in the database<br>  await db<br>    .update(users)<br>    .set({ activationToken })<br>    .where(eq(users.email, email));<br><br>// Create a nodemailer transporter<br>  const transporter = nodemailer.createTransport(transportOptions);<br><br>// Send account confirmation email<br>  await transporter.sendMail({<br>    from: emailOptions.from,<br>    to: email,<br>    subject: &#39;Welcome to My App&#39;,<br>    html: render(<br>      AccountActivationEmail({ url: `${process.env.NEXT_PUBLIC_URL}` })<br>    ),<br>  });<br><br>// Revalidate the path to update UI<br>  revalidatePath(&#39;/account-activation&#39;);<br>}</pre><p>The core functionality of this Server Action mirrors our Remix action, demonstrating the similarities in server-side processing between the two frameworks. However, there are some key differences in how Next.js approaches these operations:</p><ol><li><strong>Flexibility in Definition</strong>: Unlike Remix actions which are tied to routes, Next.js Server Actions <em>can be defined at the component level or in separate files</em>, allowing for more granular control over where and how server-side logic is implemented.</li><li><strong>Explicit Revalidation</strong>: Notice the revalidatePath function at the end of our action. Unlike Remix’s automatic revalidation, Next.js requires explicit calls to update the UI after a mutation. This gives developers more fine-grained control but also requires more careful management of data freshness.</li><li><strong>Progressive Enhancement</strong>: Like Remix, Next.js Server Actions support progressive enhancement, ensuring functionality even when JavaScript fails to load or execute.</li><li><strong>TypeScript Integration</strong>: When used with TypeScript, server actions provide end-to-end type safety from the server to the client, potentially reducing runtime errors.</li></ol><h3>Using Server Actions in Components</h3><p>Server Actions can be used in other components like this:</p><pre>import { activateAccountAction } from &#39;@/actions/activateAccount&#39;;<br>import { useState } from &#39;react&#39;;<br><br>export function ActivateAccountForm() {<br>  return (<br>    &lt;form action={activateAccountAction}&gt;<br>      &lt;input<br>        type=&quot;email<br>        name=&quot;email&quot;<br>        required<br>        placeholder=&quot;Enter your email&quot;<br>      /&gt;<br>      &lt;button type=&quot;submit&quot;&gt;Activate Account&lt;/button&gt;<br>    &lt;/form&gt;<br>  );<br>}</pre><p>As you can see, we’re calling the Server Action from a client component. This seamless integration between server and client code is a powerful feature of Next.js.</p><h3>Conclusion</h3><h3>Comparing Traditional BE+FE vs Full-Stack Approach</h3><p>Full-stack frameworks like Remix and Next.js offer several advantages over traditional backend-frontend separation. They provide a unified codebase, shared typings, and seamless data flow between server and client, reducing development time and inconsistencies. Here’s a list of some pros and cons of full-stack framework approach:</p><p><strong>Pros of Full-Stack Frameworks</strong>:</p><ol><li>Unified development experience</li><li>End-to-end type safety</li><li>Built-in performance optimizations</li><li>Simplified deployment</li><li>Rapid prototyping capabilities</li></ol><p><strong>Cons of Full-Stack Frameworks</strong>:</p><ol><li>Framework-specific learning curve</li><li>Potential vendor lock-in</li><li>Limited flexibility in technology choices</li><li>Scalability challenges for monolithic apps</li><li>Opinionated structure may not suit all teams</li></ol><p>Traditional BE+FE setups, while offering more technological freedom and clear separation of concerns, can lead to increased complexity and potential inconsistencies between layers.</p><p>The choice between these approaches depends on various factors that need to be carefully considered. Project requirements play a significant role, as do the expertise and experience of the development team. Scalability needs must be taken into account, especially for applications expected to grow significantly over time. Development speed priorities can also influence the decision, particularly in fast-paced environments with tight deadlines.</p><p>Long-term maintenance considerations are equally important, as the chosen approach will impact the ease of updates and bug fixes in the future. Both approaches have their merits, and the best choice ultimately aligns with the specific project goals and team dynamics.</p><p>As the landscape of web development continues to evolve, it remains crucial for developers and teams to stay adaptable while critically evaluating new paradigms to ensure ongoing success in their projects.</p><h3>Note about React Server Components and Server Actions</h3><p>It’s important to note that <strong>server actions</strong> and <strong>React Server Components</strong> are not exclusive Next.js features, but rather core React innovations. These concepts were initially proposed by the React team to enhance server-client integration in React applications. Next.js, being at the forefront of React framework development, was among the first to implement and offer these features in a production-ready environment. However, as the React ecosystem evolves, we can expect to see these powerful capabilities adopted by other frameworks and toolchains, further blurring the lines between server and client in React applications across the board.</p><h3>Comparing Remix and Next.js</h3><p>While Next.js may seem more attractive on paper with its flexible Server Components and Server Actions, after working with both frameworks, I felt better working with Remix, and I opted to migrate my production app from Next.js to Remix. I’ll try to give a few personal reasons why and why I would prefer to work in Remix more:</p><ul><li>React Server Components enable a lot of cool things and I get their goal and aim, but I found myself more comfortable with using Remix loaders because I knew exactly when I was on the server and when I was on the client. By using RSC and regular components, sometimes we may get lost in what is what, and nesting Server components with Client components is not really that straightforward, but it requires a few special tricks.</li><li>While Remix builds on time-tested server-centric patterns reminiscent of PHP and Ruby on Rails days, React Server Components represent an innovative approach that’s still gaining traction in the global development ecosystem and is yet to prove itself as a better option.</li><li>With Remix, I could utilize all the good things React Router library offers, with how they handle redirects, route state, and not worrying to refresh my loaders after an action has been fired. I also had all the power of a web browser in every component, and all the power of Node.js in every loader/action. That felt like a clear separation of concerns and easy to reason about. <strong>next/navigation</strong> is also a great library for routing, but still not as good as React Router.</li><li>Biggest flaw for Remix in my book was having one action per route, which needed to have special code to manage, and I didn’t like that, but one can learn to live with it, and it may go away in the future.</li><li>This is based just on a feeling, I never did any benchmarks or anything, but Remix app felt a bit faster in the end, with much less code.</li><li>Remix uses Vite for build and Next.js still uses Webpack, or now super fast Turbopack, still Vite is the clear winner in the JS ecosystem and I would use it on any project.</li><li>Remix is a plain Node.js server and it can be deployed anywhere as such, for example I have used<a href="http://fly.io/"> fly.io</a> to deploy my app very easily. Next.js is by default a serverless app that best works with Vercel, and deploying it as a Node.js server requires some extra work.</li></ul><p>I would still use any of these techs for a new project in a heartbeat and both are a safe bet for any project in the long run.</p><p>Quick comparison table between two frameworks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D7OsEIEXK0q3FdPnUjYLrQ.png" /></figure><h3>Useful links for things mentioned in the post</h3><p>Remix Official Website <a href="https://remix.run/">— https://remix.run</a></p><p>Next.js Official Website <a href="https://nextjs.org/">— https://nextjs.org</a></p><p>React Server Components <a href="https://react.dev/reference/rsc/server-components">— https://react.dev/reference/rsc/server-components</a></p><p>Next.js Server Actions <a href="https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations">— https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations</a></p><p>Remix Loader <a href="https://remix.run/docs/en/main/route/loader">— https://remix.run/docs/en/main/route/loader</a></p><p>Remix Action <a href="https://remix.run/docs/en/main/route/action">— https://remix.run/docs/en/main/route/action</a></p><p>Request Web API <a href="https://developer.mozilla.org/en-US/docs/Web/API/Request">— https://developer.mozilla.org/en-US/docs/Web/API/Request</a></p><p>DrizzleORM (TypeScript database ORM used in the examples) <a href="https://orm.drizzle.team/">— https://orm.drizzle.team</a></p><p>nodemailer (lib for sending emails using Node.js) <a href="https://nodemailer.com/">— https://nodemailer.com</a></p><p>React Email (lib for creating beautiful email messages using React) <a href="https://react.email/">— https://react.email</a></p><h3>About the author</h3><p>Milos Dzeletovic, a Software Engineer from Symphony’s Belgrade branch, excels in frontend development and has strong expertise in HTML, CSS, JavaScript, React.js and React Native. His strengths lie in his adaptability, self-driven learning, and proactive communication, which enable him to quickly adopt new technologies, effectively mentor peers, and contribute to building efficient, high-quality web applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11cbaa3d40e3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/symphonyis/bridging-the-gap-how-remix-and-next-js-are-redefining-full-stack-web-development-11cbaa3d40e3">Bridging the gap: How Remix and Next.js are redefining full-stack web development</a> was originally published in <a href="https://medium.com/symphonyis">symphonyis</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>