How React Router Became a Framework

Rate this content
Bookmark

When Remix was first released in 2020, its goal was to provide framework-level features on top of React Router, simplifying server-side rendering, data fetching, state management and build tooling. Now, with the release of React Router v7, the entirety of Remix is getting merged back upstream into React Router. This is a huge step up for the React community since React Router powers roughly half of all React downloads. In this talk we'll take a look into how this happened and what this means for the future of React frameworks.

This talk has been presented at React Advanced 2024, check out the latest edition of this React Conference.

FAQ

Yes, ReactRouter plans to support React Server Components, though it is dependent on the stabilization of certain APIs.

The development is guided by a focus on simplicity, removing unnecessary layers of abstraction, and providing clear, concise solutions for common development challenges.

The transition allows Remix to decouple from ReactRouter and explore new directions, potentially evolving into a different framework while maintaining backward compatibility.

Remix is heavily built on ReactRouter, using many of its APIs and features. ReactRouter serves as the core DNA of Remix, which is considered ReactRouter as a framework.

It was announced that Remix would merge into ReactRouter, bringing framework-level features of Remix into ReactRouter v7, making ReactRouter a more complete solution.

Mark Dalglish's talk focuses on how ReactRouter evolved into a framework and the distinction between libraries and frameworks in the context of React development.

Using ReactRouter with the Vite plugin provides features like nested routing, code splitting, and a simple state management model, enhancing the overall development experience.

Mark Dalglish has been working in the React space for about 10 years.

ReactRouter is traditionally a library, but with its integration of framework-like features, especially through its Vite plugin, it can also function as a framework, providing a more complete solution for React applications.

Mark Dalgleish
Mark Dalgleish
31 min
25 Oct, 2024

Comments

Sign in or register to post your comment.
Video Summary and Transcription
My name is Mark Dalglish and I'm here to discuss how ReactRouter became a framework. Remix is built on ReactRouter and heavily relies on it. Remix feels like a framework because it has a CLI, manages the dev and build lifecycle, and has strong opinions about the file system structure. Remix embraced Vite as a plugin, allowing developers to integrate it seamlessly into their existing Vite setup. The shift to Vite led to a change in the philosophy of Remix Vite, enabling frameworks to orchestrate all the environment builds and make the framework as a plugin pattern first class. React Router is merging with Remix to make all the build time framework features available to React Router consumers. React Router is now officially a framework as well as a library. The move to integrate Remix into React Router is driven by the exploration of the next generation of Remix. React Router V7 simplifies by dropping the React Native layer and allows flexibility for consumers to use it as a library or as a framework with additional architectural features provided by plugins. The focus is on betting on Vite in the long term, and React Router plans to support React Server components. Thank you to Mark for answering the questions.

1. Introduction to ReactRouter

Short description:

My name is Mark Dalglish. I'm here to talk about how ReactRouter became a framework. I've been working with React for 10 years and it led me to my current position with the Remix team at Shopify. ReactRouter provided server rendering and data fetching capabilities, which I used to take React to production. ReactRouter has a huge adoption in the React community, and today I want to discuss the distinction between libraries and frameworks, with ReactRouter moving towards becoming a framework.

All right, thank you. So as you heard, my name is Mark Dalglish, all the way here from Melbourne, Australia. And as you heard, also, I'm here to talk about how ReactRouter became a framework. It's obviously a very big topic, so I'm going to touch the surface of it, but hopefully give you a good sense of where this move came from.

Now, as you heard as well, there, I've been working in the React space for a very long time. I've actually been working with it for about 10 years at this point. And that work has led me to my current position, working full-time with the Remix team at Shopify, a very privileged thing for me to be able to do at this point in my career. I'm really enjoying it.

And when I go back to the start of my career working with React, for me it really started with ReactRouter, because what got me interested in React was the fact that I could do server rendering, progressive enhancement, and do that with shared code between the client and server. And the first time I saw this done for real, in a way I could take to production, was in this ReactRouter mega demo that Ryan Florence put together about 10 years ago. And what was really great about this demo is it showed how you could get server rendering and data fetching working together. And the way it was done by convention in this boilerplate was that each route component could have this static fetch data method on it that would describe how do I get the data for this route. And you could figure out after doing route matching on the server, you could figure out which of your route components had these functions on them. You could call them in parallel, take the data and pass it down, and also run this on the client as you navigate it around. So this is exactly what I used to take React to production. To take React to production way back in the early days of React. So it was a really great project.

Now I know by far I was not the only person to be building on top of ReactRouter, because even to this day, roughly half of all React DOM downloads are paired with ReactRouter. So there's huge adoption still in the React community today. Now today what I want to do is drill into this distinction between libraries versus frameworks. Because if we're talking about ReactRouter becoming a framework, it's important to describe what is the difference between where it is today and where it's heading. Because ReactRouter is a library, that's not a controversial thing to say. Of course, it has always been a library since its first release. As it says right here in its readme, ReactRouter is a lightweight, fully featured routing library. But if you go to the React documentation for how to start a new React project, they tackle this question head on about whether you can use React without a framework. And they say that, of course, while you can use React without a framework, we're at the point now where there are so many big challenging problems to solve if you try to go it alone that you're much better off, the average developer is much better off using a framework. And they go further and draw a distinction with what they call production-grade React frameworks. And luckily, in terms of my work, luckily, Remix is on that list. So, Remix is featured as a production-grade framework.

2. Remix's Relationship with ReactRouter

Short description:

Remix is built on ReactRouter and heavily relies on it. The core DNA of Remix is ReactRouter, and making Remix better often means making ReactRouter better. Features of Remix are now arriving for ReactRouter consumers, including attaching loaders and actions to routes and lazy loading of routes. ReactRouter coupled with tools like Vite starts to feel like a framework.

So, Remix is featured as a production-grade framework. Here, it describes itself as a full stack web framework. But what's important for today's topic is that Remix is built on ReactRouter and quite heavily so. To the extent that if you go look at one of the packages that you use quite heavily throughout your Remix project, Remix run slash React, you go look at the source code for that package, and what you're going to see right up top is a giant wall of reexports from ReactRouter DOM. If you're familiar with ReactRouter and you come over to Remix, you're going to find yourself right at home. A lot of those APIs are completely identical. And of course, Remix adds a bunch of stuff on top. But it means that the core DNA of Remix is really ReactRouter. So, you can think of ReactRouter sorry, Remix as ReactRouter, the framework. What's interesting about this relationship is it meant that making Remix better often meant making ReactRouter better. Because if we needed to add a big new feature to Remix, it would usually require changes to ReactRouter. If we wanted to clean up the code in Remix, it would often require us to remove it from Remix and move it over to a lower level within ReactRouter. So, there was this relationship ongoing as we worked further on Remix and improved Remix itself. This was especially notable with this post from Ryan Florence a couple years ago in 2022 about remixing ReactRouter. And this was announcing the fact that a lot of the best features of Remix were actually going to be starting to arrive for ReactRouter consumers. In practice, what that looked like is something like this where you could describe your route tree as you might have done previously. But now you could also attach things like loaders and actions to your route to your actions to your routes. So, now you're starting to get a lot of the benefits that you get from a Remix application inside of your regular ReactRouter app. This was extended even further with lazy loading of routes. So, no longer did you need to load the entire route tree up front when you were describing it this way. You could instead make it so that you would only load the code for that route if and when you needed it as you navigated around. So, in this case, this is your standard implementation where the lazy route is a dynamic import here of our dashboard route. And if you go look at the source code for that, what you can imagine is that it's going to have to return the API for what a route would typically be described as in line. So, that dashboard component might look like this here where it's exporting a loader, it's exporting an action, it's exporting its component. And if you squint, if you've looked at Remix before, this basically looks like the same thing. So, you're using ReactRouter but you're getting a lot of those benefits and API decisions that you get out of Remix right here in ReactRouter. So, as a ReactRouter consumer, what you're getting now with this setup is nested routing. You're getting code splitting along with that and the simple state management model that makes Remix such a joy to work with while still being in the world of a library. This was notably picked up by a lot of people. Ken C Dodds gave a great talk at VConf last year highlighting that to him, ReactRouter, once it's gone down this road, ReactRouter tied with something like Vite really starts to feel like a framework and I completely agree with that position.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Building Better Websites with Remix
React Summit Remote Edition 2021React Summit Remote Edition 2021
33 min
Building Better Websites with Remix
Top Content
Remix is a web framework built on React Router that focuses on web fundamentals, accessibility, performance, and flexibility. It delivers real HTML and SEO benefits, and allows for automatic updating of meta tags and styles. It provides features like login functionality, session management, and error handling. Remix is a server-rendered framework that can enhance sites with JavaScript but doesn't require it for basic functionality. It aims to create quality HTML-driven documents and is flexible for use with different web technologies and stacks.
Don't Solve Problems, Eliminate Them
React Advanced 2021React Advanced 2021
39 min
Don't Solve Problems, Eliminate Them
Top Content
Kent C. Dodds discusses the concept of problem elimination rather than just problem-solving. He introduces the idea of a problem tree and the importance of avoiding creating solutions prematurely. Kent uses examples like Tesla's electric engine and Remix framework to illustrate the benefits of problem elimination. He emphasizes the value of trade-offs and taking the easier path, as well as the need to constantly re-evaluate and change approaches to eliminate problems.
Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
This talk discusses the usage of Microfrontends in Remix and introduces the Tiny Frontend library. Kazoo, a used car buying platform, follows a domain-driven design approach and encountered issues with granular slicing. Tiny Frontend aims to solve the slicing problem and promotes type safety and compatibility of shared dependencies. The speaker demonstrates how Tiny Frontend works with server-side rendering and how Remix can consume and update components without redeploying the app. The talk also explores the usage of micro frontends and the future support for Webpack Module Federation in Remix.
Speeding Up Your React App With Less JavaScript
React Summit 2023React Summit 2023
32 min
Speeding Up Your React App With Less JavaScript
Top Content
Watch video: Speeding Up Your React App With Less JavaScript
Mishko, the creator of Angular and AngularJS, discusses the challenges of website performance and JavaScript hydration. He explains the differences between client-side and server-side rendering and introduces Quik as a solution for efficient component hydration. Mishko demonstrates examples of state management and intercommunication using Quik. He highlights the performance benefits of using Quik with React and emphasizes the importance of reducing JavaScript size for better performance. Finally, he mentions the use of QUIC in both MPA and SPA applications for improved startup performance.
Full Stack Documentation
JSNation 2022JSNation 2022
28 min
Full Stack Documentation
Top Content
The Talk discusses the shift to full-stack frameworks and the challenges of full-stack documentation. It highlights the power of interactive tutorials and the importance of user testing in software development. The Talk also introduces learn.svelte.dev, a platform for learning full-stack tools, and discusses the roadmap for SvelteKit and its documentation.
SolidJS: Why All the Suspense?
JSNation 2023JSNation 2023
28 min
SolidJS: Why All the Suspense?
Top Content
Suspense is a mechanism for orchestrating asynchronous state changes in JavaScript frameworks. It ensures async consistency in UIs and helps avoid trust erosion and inconsistencies. Suspense boundaries are used to hoist data fetching and create consistency zones based on the user interface. They can handle loading states of multiple resources and control state loading in applications. Suspense can be used for transitions, providing a smoother user experience and allowing prioritization of important content.

Workshops on related topic

Remix Fundamentals
React Summit 2022React Summit 2022
136 min
Remix Fundamentals
Top Content
Featured WorkshopFree
Kent C. Dodds
Kent C. Dodds
Building modern web applications is riddled with complexity And that's only if you bother to deal with the problems
Tired of wiring up onSubmit to backend APIs and making sure your client-side cache stays up-to-date? Wouldn't it be cool to be able to use the global nature of CSS to your benefit, rather than find tools or conventions to avoid or work around it? And how would you like nested layouts with intelligent and performance optimized data management that just works™?
Remix solves some of these problems, and completely eliminates the rest. You don't even have to think about server cache management or global CSS namespace clashes. It's not that Remix has APIs to avoid these problems, they simply don't exist when you're using Remix. Oh, and you don't need that huge complex graphql client when you're using Remix. They've got you covered. Ready to build faster apps faster?
At the end of this workshop, you'll know how to:- Create Remix Routes- Style Remix applications- Load data in Remix loaders- Mutate data with forms and actions
Building WebApps That Light Up the Internet with QwikCity
JSNation 2023JSNation 2023
170 min
Building WebApps That Light Up the Internet with QwikCity
Featured WorkshopFree
Miško Hevery
Miško Hevery
Building instant-on web applications at scale have been elusive. Real-world sites need tracking, analytics, and complex user interfaces and interactions. We always start with the best intentions but end up with a less-than-ideal site.
QwikCity is a new meta-framework that allows you to build large-scale applications with constant startup-up performance. We will look at how to build a QwikCity application and what makes it unique. The workshop will show you how to set up a QwikCitp project. How routing works with layout. The demo application will fetch data and present it to the user in an editable form. And finally, how one can use authentication. All of the basic parts for any large-scale applications.
Along the way, we will also look at what makes Qwik unique, and how resumability enables constant startup performance no matter the application complexity.
Back to the Roots With Remix
React Summit 2023React Summit 2023
106 min
Back to the Roots With Remix
Featured Workshop
Alex Korzhikov
Pavlik Kiselev
2 authors
The modern web would be different without rich client-side applications supported by powerful frameworks: React, Angular, Vue, Lit, and many others. These frameworks rely on client-side JavaScript, which is their core. However, there are other approaches to rendering. One of them (quite old, by the way) is server-side rendering entirely without JavaScript. Let's find out if this is a good idea and how Remix can help us with it?
Prerequisites- Good understanding of JavaScript or TypeScript- It would help to have experience with React, Redux, Node.js and writing FrontEnd and BackEnd applications- Preinstall Node.js, npm- We prefer to use VSCode, but also cloud IDEs such as codesandbox (other IDEs are also ok)
How to Solve Real-World Problems with Remix
Remix Conf Europe 2022Remix Conf Europe 2022
195 min
How to Solve Real-World Problems with Remix
Featured Workshop
Michael Carter
Michael Carter
- Errors? How to render and log your server and client errorsa - When to return errors vs throwb - Setup logging service like Sentry, LogRocket, and Bugsnag- Forms? How to validate and handle multi-page formsa - Use zod to validate form data in your actionb - Step through multi-page forms without losing data- Stuck? How to patch bugs or missing features in Remix so you can move ona - Use patch-package to quickly fix your Remix installb - Show tool for managing multiple patches and cherry-pick open PRs- Users? How to handle multi-tenant apps with Prismaa - Determine tenant by host or by userb - Multiple database or single database/multiple schemasc - Ensures tenant data always separate from others
Build and Launch a personal blog using Remix and Vercel
Remix Conf Europe 2022Remix Conf Europe 2022
156 min
Build and Launch a personal blog using Remix and Vercel
Featured Workshop
Robert Pop
Robert Pop
In this workshop we will learn how to build a personal blog from scratch using Remix, TailwindCSS. The blog will be hosted on Vercel and all the content will be dynamically served from a separate GitHub repository. We will be using HTTP Caching for the blog posts.
What we want to achieve at the end of the workshop is to have a list of our blog posts displayed on the deployed version of the website, the ability to filter them and to read them individually.
Table of contents: - Setup a Remix Project with a predefined stack- Install additional dependencies- Read content from GiHub- Display Content from GitHub- Parse the content and load it within our app using mdx-bundler- Create separate blog post page to have them displayed standalone- Add filters on the initial list of blog posts
Building High-Performance Online Stores with Shopify Hydrogen and Remix
React Advanced 2023React Advanced 2023
104 min
Building High-Performance Online Stores with Shopify Hydrogen and Remix
WorkshopFree
Alexandra Spalato
Alexandra Spalato
I. Introduction- Overview of Shopify Hydrogen and Remix- Importance of headless e-commerce and its impact on the industry
II. Setting up Shopify Hydrogen- Installing and setting up Hydrogen with Remix- Setting up the project structure and components
III. Creating Collections and Products- Creating collections and products using Hydrogen’s React components- Implementing a Shopping Cart- Building a shopping cart using Hydrogen’s built-in components
VI. Building the home page with Storyblok- Cloning the space and explaining how it works- Implementing Storyblok in the repo- Creating the Blok components- Creating the Shopify components- Implementing personalisation