Remix Fundamentals

Rate this content
Bookmark

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

FAQ

Remix is a web development framework that focuses on improving the bridge between the client and server, effectively handling the hardest part of web development which is the network chasm. It leverages web standards for routing, data loading, and actions, allowing developers to build more with less while ensuring an optimized user experience.

While Remix is primarily designed for web applications, there is potential for compatibility with React Native, particularly in sharing components and possibly utilizing loaders. However, this integration is not officially supported yet and would require custom solutions or further development from the community or the Remix team.

Remix allows developers to associate individual CSS files with specific routes, enabling styles to be independent and not affect other parts of the application. This approach leverages the capabilities of the web platform, avoiding the cascade issues common in traditional CSS management. Remix supports traditional CSS, Tailwind CSS, and plans to improve support for CSS modules and Vanilla Extract.

Remix provides robust error handling mechanisms through error boundaries and catch boundaries, which can be used to render fallback UI components when data fetching or other operations fail. These boundaries ensure that errors are managed gracefully, providing a better user experience and maintaining application stability.

Remix automatically re-fetches all page data upon successful mutations, eliminating the need for manual state management related to data synchronization. This model simplifies development by reducing the complexity associated with keeping the UI and server state consistent. Developers can focus more on features rather than state management intricacies.

Integrating Remix with existing applications like those built with Next.js involves setting up a proxy, such as Express or Nginx, to route specific paths to Remix or the existing system. This approach allows for gradual migration and coexistence of both frameworks during the transition period.

The Remix team is exploring various monetization strategies including offering services around Remix similar to what Laravel does, building products akin to what Rails has with Basecamp, or potentially partnering with larger companies through acquisitions or collaborations.

Kent C. Dodds
Kent C. Dodds
136 min
04 Jul, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Remix simplifies state management and data loading in web applications, combining modern web development with the simplicity of managing state in the backend. It supports nested routing and provides a convenient way to associate parent and child components based on URL segments. Remix handles data fetching, mutations, and error states automatically. It offers flexibility in accessing loader data and allows for multiple instances of loader data in a component. Remix also provides seamless handling of form updates, error handling, and redirects.

Available in Español: Fundamentos de Remix

1. Introduction to Remix and Exercise 1

Short description:

Welcome everyone. We're going to talk about Remix and cover topics like nested routing, data loading, dynamic parameters, mutations, and progressive enhancement. In Exercise 1, we'll add a link to the post route in the Indy Stack. We'll go through the README and stop at loading data. Then, we'll create a post index route in our routes directory. TypeScript is recommended for building web applications with Remix, but it's not mandatory. Let's get started!

Welcome everyone. I am super excited to talk with you all about Remix. I think it's amazing and I think that we're all gonna have a great time learning about Remix. Let me get my screen prepared. And so this is the the workshop repo, and this is the workshop running locally. Let me bump that up just one here a little bit, scoot that over.

So here is our outline. We're gonna, we're not going to get through all of this stuff. We only have three hours, so we're going to work through some of this. I do want to give you some time with your hands on the keyboard, but because we're so limited on time I have a feeling that you're more interested in me or in getting through more content than spending as much time with your hands on the keyboard. That's my guess. That's the assumption I'm going to be operating under. So, because of that, I will give you a little bit of time on some of these as exercises, but most of the time you're gonna just be watching and asking questions and stuff in the Discord. And I think that will be the best use of the limited time that we have.

So we're going to talk today about nested routing, data loading, dynamic parameters, nested routing, mutations, progressive enhancement, and then there's homework, all sorts of things that we can do for the homework. Some of these things will just kind of breeze over and stuff. So I want to kind of give you an introduction to what Remix Even is and kind of the unique value proposition and everything. But I'd like to get things rolling quicker. And so I think we're going to do the first exercise and then we'll loop around and do a little is Remix Even. This is actually part of my strategy for learning. It's just kind of throwing you into the deep end. So we're going to start with Exercise 1 and you're not actually going to CD into this directory. So the way that this works is we have a special script called route runner. So this is called dev, that you can run, NodeDev and then you give it the path to the exercise that you want and it will run that exercise and what's cool about this is it will run it on a port that is associated to the exercise. So you could run all of the exercises and all of the finished versions of the exercises all at the exact and they will all work, which is kind of fun and fancy. So if you run NodeDev exercise zero one routing, and actually a quick tip, you can actually do just zero one and that will also work so you don't have to type the whole thing out, but then you pop open Locos 4001 and you're presented with this page that is the Indy stack. So Remix has this feature for project generation where you generate new projects and we call these stacks. It has a bunch of tools and stuff that come pre-installed and pre-configured for you. And the tutorial that we're going through is based on the Indy Stack. So that is where we're going to start is in exercise one with basically a pre-generated Indy Stack and your job for this exercise is simply to add a link right here, just below the big image here, to take you to the post route. We're going to add a blog to this site. So that's what we're going to do. That's your first exercise. You're going to go into exercise 01 routing, go to the README, and this will give you a starting place and a stopping place in the blog tutorial. So you'll start with your first route, and you will stop right when you get to loading data. So you won't continue through loading data, you'll just stop right here for this exercise. And so we're going to stick that in our routes index j.s. So this is our home page. That's where we want it to go. And we're just going to put it right there. It doesn't really matter where it is because we're not learning j.s.x. and proper structure or whatever. That doesn't really matter. So we're coming over here. We've got a link to blog post. And when I click on that link, we're going to get a four or four because even though we are actually going to that URL, we don't actually have anything there. And fun fact, because Remix is server rendered, you actually get a 404 from the server when going to that page, all the stuff that we've been doing on the client for the last six to eight years. When you have a route that is not not supported, you get the index HTML. So you get a 200. And the client just says, Oh, we can't find it. But Remix because of server rendered, can actually give a proper status code, which is really good for for SEO for the browser behaving the proper way all that stuff. So that's nice. But we want to have something there. And so in the next step here, we make a new route, and that is controlled by having a new route. And that is controlled by having a file at posts. And we want to have the index for our posts. So we'll create a post index route on in our routes directory. So let's make posts, and then index dot TSX. And Oh, by the way, I, I just assumed that we're all doing TypeScript. TypeScript is the way that you build web applications these days. And if you're not familiar with TypeScript, you'll be pleased to know that there's actually not a ton of TypeScript weirdness that you have to do with Remix. There's a little bit. But yeah, it is so so nice. So if you're not used to TypeScript, you can feel free to just leave the types off it will still work. You'll just get little red squiggles in some places. It's not a big deal. Okay, so we're just going to copy this because again, I don't think that you care to spend time writing jsx but the important thing here is that our module exports default, a function component. I guess it could be a class component. I don't know why I distinguished with function but you export a function or a component. And, and that is what's going to be rendered when the user lands on the post page.

2. Remix and React Router Integration

Short description:

So there it is posts. We have this link to the posts route and then the posts is a file under routes called, with a default export for what should be rendered when we're on that route. This would be with the convention that we currently have for Remix for the file structure, you can just have a posts.TSX. Remix uses React router remix came from the creators of React router. Remix is just using React router here. Remix is focused on web standards and modern web app UX. Remix takes the things that worked really well in the web 10 years ago, and then Remixes the things that work really well in the modern web. The thing that bothers people who have been involved in the web for a long time about the modern web is how hard it is to build a website these days. What Remix manages to do is, the thing that we liked about the older way of building websites is you didn't have to worry about managing state in the browser.

So there it is posts. And that that's everything that was the whole exercise was you literally just add a link using this link component that's coming from remix. And this is actually just being being re exported essentially from react router. There's a couple additional features but for the most part it's just being re exported. And in fact the additional features are being moved into React router proper.

So anyway, we have this link to the posts route and then the posts is a file under routes called, with a default export for what should be rendered when we're on that route. Could that posts folder just be a file post.TSX or does it have to be an index file? Great question. Yeah yeah. So we'll go ahead and do this now. This would be with the convention that we currently have for Remix for the file structure, you can just have a posts.TSX so we could put all this stuff in here instead and we'll get the same result and like, of course I could delete this or whatever but in the next couple of exercises, we're also going to have post slash slug with whatever the post name is and so we're going to need to have the post directory eventually. And so this is effectively the homepage for the post so the index page for the post and so that's what we just started with the index page. But it's not necessarily wrong to have this file because there could be like some sort of special nav or footer that you want for all your posts and that's what you would put in this. We'll talk about that a little bit more when we get into nested routing, doing the admin UI but just to give you a quick sample of what this is, this it would be the parent route of this index route and all the routes inside of this post directory and so parents need to say what where the children should be rendered and so the way that we do that is via the outlet component from remix run react. And so now I can say render my outlet and I'll wrap it in a div and say here's my footer stuff and my header stuff and then we come over here and I have my header stuff, the posts, this is the index route that's coming from our index right here, this right there and then our footer stuff. And so now every route inside of the post directory is gonna have the header stuff and wrapping whatever the child route is. And so that that absolutely is helpful and now this is controlling some of the layout for us. And then just saying where the the children should be rendered. But we don't really want to wrap anything. So we'll just do this and now what we're looking at is actually the default parent route. So if you don't have a parent route, this is the default basically is nothing. It's routing a structure that is something like React router six, which has outlet and it can some, put some routing inside them and have parents. Is it something like that?

Yes, that's exactly what it is. This remix uses React router remix came from the creators of React router. And so that's and React router is getting a lot of cool remix features very soon. Okay. Thank you. Yeah, in fact, fun fact, a couple months ago, is it months now maybe a couple weeks on our blog, we wrote this post called remixing React router, where we're taking a bunch of the really cool features from React router, and bringing them into, I'll just drop a link to that in the discord, bringing them into. or a bunch of the features from remix into React router. And actually, we could title this post differently, and instead say unreacting React router because we're basically taking all as we're taking all these features of remix and putting them into React router. We're just getting, we are kind of separating the core features of remix and React. And so what that's going to allow us to do is now React router is an adapter for remix router, and then we can make adapters for Vue and for Svelte and for angular and for preact and all of these things. So, the whole web is actually going to be able to take advantage of remix, regardless of what UI library you decide to use, which is pretty significant. So, the future version, and we have this on pre-release right now, we're thinking we may release this either this week or next week, where we'll have the remix router, and then just adapters for that router, which is cool. And community members are already building adapters for remix router, for Vue, Angular, Svelte and Preact. And, I think there may be another one, I can't remember which, but, so yeah, exciting times, and yes. So absolutely, remix is just using React router here.

I have a very basic question, maybe, like remix is running on the back end, not on the front end, like, if you would have a normal React application, it would run on the front end as a single page application, but remix is running on Node server or something, right?

Yes, yeah, but it is a SPA, a single page application when it hydrates, and so if you come over to your homepage, that was a, like, this is all server rendered, you look at the view source and you're seeing, like, all the HTML and everything in there, but when you navigate to blog posts, you're not getting a full page reload or anything, we're just loading in the JavaScript necessary for that page, and we'll do the same for the CSS and data and everything else as well. So, it is a client-side transition that's happening here, so you get like page transitions, focus management, all that stuff.

Now that we've done the first exercise, what I want to do is take a moment to talk about what is Remix, and this thing that you just toyed around with for a second, so Remix is focused on web standards and modern web app UX. You could say that we're remixing the old with the new, and so I'm going to, in Discord, I'm going to say raise your hand, raise your hand, here, I'll move this over so y'all can see what I'm doing. If you have been, or actually let's do how many years have you been in web dev. And so if you've been in for nine years, nine, there we go. If you've been in nine or more, oh whoops, that was supposed to be here. No stop chatting. We're just going to do emoji reactions. You're too fast. If you've been in nine or more, then do nine, otherwise do eight or seven or yeah, the number, you get it. So for me, I started web dev in officially 2014. So that gives me eight. So there we go, cool. So actually we've got quite a few of you who've been in for nine or more. Let's see. So for those of you who've been in for nine or more years, then you'll actually find this. Oh, there's a 10, oh man, I didn't know there was a 10. Whoops, yeah. You could do the 10 if you want to. So yeah, for those of you who have been in for a while, you'll find this to be very familiar and very comfortable because Remix takes the things that worked really well in the web 10 years ago, and then Remixes the things that work really well in the modern web in things these days. So the thing that bothers people who have been involved in the web for a long time about the modern web is how hard it is to build a website these days. There are so many things you have to do. You have your build tools, you have your linters and your formatters, and you've got your JSX, and you've got your JavaScript stuff. And now you've got to manage state in the UI and so many things that you have to do these days that you didn't have to do back then. And I would always convince myself and say, well, yeah, but our apps are way better than they used to be. We can do way more than we used to be able to do back then. And yes, that's true. The browser's way more capable. Good luck building Figma back in the late 90s or early thousands. Yeah, that's silly. So that's what I always convinced myself of. But what Remix manages to do is, the thing that we liked about the older way of building websites is you didn't have to worry about managing state in the browser. All state was basically just lived in the database and maybe you'd put a cache in somewhere in place to make things faster.

QnA

Watch more workshops on topic

React, TypeScript, and TDD
React Advanced Conference 2021React Advanced Conference 2021
174 min
React, TypeScript, and TDD
Top Content
Featured WorkshopFree
Paul Everitt
Paul Everitt
ReactJS is wildly popular and thus wildly supported. TypeScript is increasingly popular, and thus increasingly supported.

The two together? Not as much. Given that they both change quickly, it's hard to find accurate learning materials.

React+TypeScript, with JetBrains IDEs? That three-part combination is the topic of this series. We'll show a little about a lot. Meaning, the key steps to getting productive, in the IDE, for React projects using TypeScript. Along the way we'll show test-driven development and emphasize tips-and-tricks in the IDE.
Web3 Workshop - Building Your First Dapp
React Advanced Conference 2021React Advanced Conference 2021
145 min
Web3 Workshop - Building Your First Dapp
Top Content
Featured WorkshopFree
Nader Dabit
Nader Dabit
In this workshop, you'll learn how to build your first full stack dapp on the Ethereum blockchain, reading and writing data to the network, and connecting a front end application to the contract you've deployed. By the end of the workshop, you'll understand how to set up a full stack development environment, run a local node, and interact with any smart contract using React, HardHat, and Ethers.js.
Vue3: Modern Frontend App Development
Vue.js London Live 2021Vue.js London Live 2021
169 min
Vue3: Modern Frontend App Development
Top Content
Featured WorkshopFree
Mikhail Kuznetcov
Mikhail Kuznetcov
The Vue3 has been released in mid-2020. Besides many improvements and optimizations, the main feature of Vue3 brings is the Composition API – a new way to write and reuse reactive code. Let's learn more about how to use Composition API efficiently.

Besides core Vue3 features we'll explain examples of how to use popular libraries with Vue3.

Table of contents:
- Introduction to Vue3
- Composition API
- Core libraries
- Vue3 ecosystem

Prerequisites:
IDE of choice (Inellij or VSC) installed
Nodejs + NPM
Developing Dynamic Blogs with SvelteKit & Storyblok: A Hands-on Workshop
JSNation 2023JSNation 2023
174 min
Developing Dynamic Blogs with SvelteKit & Storyblok: A Hands-on Workshop
Top Content
Featured WorkshopFree
Alba Silvente Fuentes
Roberto Butti
2 authors
This SvelteKit workshop explores the integration of 3rd party services, such as Storyblok, in a SvelteKit project. Participants will learn how to create a SvelteKit project, leverage Svelte components, and connect to external APIs. The workshop covers important concepts including SSR, CSR, static site generation, and deploying the application using adapters. By the end of the workshop, attendees will have a solid understanding of building SvelteKit applications with API integrations and be prepared for deployment.
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

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 new web framework from the creators of React Router that helps you build better, faster websites through a solid understanding of web fundamentals. Remix takes care of the heavy lifting like server rendering, code splitting, prefetching, and navigation and leaves you with the fun part: building something awesome!
Don't Solve Problems, Eliminate Them
React Advanced Conference 2021React Advanced Conference 2021
39 min
Don't Solve Problems, Eliminate Them
Top Content
Humans are natural problem solvers and we're good enough at it that we've survived over the centuries and become the dominant species of the planet. Because we're so good at it, we sometimes become problem seekers too–looking for problems we can solve. Those who most successfully accomplish their goals are the problem eliminators. Let's talk about the distinction between solving and eliminating problems with examples from inside and outside the coding world.
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
Do you have a large product built by many teams? Are you struggling to release often? Did your frontend turn into a massive unmaintainable monolith? If, like me, you’ve answered yes to any of those questions, this talk is for you! I’ll show you exactly how you can build a micro frontend architecture with Remix to solve those challenges.
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
Remix is a web framework that gives you the simple mental model of a Multi-Page App (MPA) but the power and capabilities of a Single-Page App (SPA). One of the big challenges of SPAs is network management resulting in a great deal of indirection and buggy code. This is especially noticeable in application state which Remix completely eliminates, but it's also an issue in individual components that communicate with a single-purpose backend endpoint (like a combobox search for example).
In this talk, Kent will demonstrate how Remix enables you to build complex UI components that are connected to a backend in the simplest and most powerful way you've ever seen. Leaving you time to chill with your family or whatever else you do for fun.
Jotai Atoms Are Just Functions
React Day Berlin 2022React Day Berlin 2022
22 min
Jotai Atoms Are Just Functions
Top Content
Jotai is a state management library. We have been developing it primarily for React, but it's conceptually not tied to React. It this talk, we will see how Jotai atoms work and learn about the mental model we should have. Atoms are framework-agnostic abstraction to represent states, and they are basically just functions. Understanding the atom abstraction will help designing and implementing states in your applications with Jotai
Debugging JS
React Summit 2023React Summit 2023
24 min
Debugging JS
Top Content
As developers, we spend much of our time debugging apps - often code we didn't even write. Sadly, few developers have ever been taught how to approach debugging - it's something most of us learn through painful experience.  The good news is you _can_ learn how to debug effectively, and there's several key techniques and tools you can use for debugging JS and React apps.