A First Look at Remix
Published:
Remix is a React metaframework created by Ryan Florence and Michael Jackson. It primarily uses standard web APIs and is built on React Router.
Outline
All of this project’s code can be found in the First Look monorepo on my GitHub.
Introduction
Remix is a React metaframework from Ryan Florence and Michael Jackson that builds on standard web APIs. At the time of the framework’s release, they were already well known as the maintainers of React Router and educators behind React Training. But in the beginning of 2020, widespread quarantine measures were enacted across the country.
Quarantine effectively brought an end to all in-person technical training. Once the impeding demise of their livelihood became apparent, the two founders helped their remaining employees find new remote roles before they inevitable were forced to lay them off. About a month later in April 2020, they announced Remix.
Originally requiring a paid license, it launched as a “supporter preview” in October 2020. A little over a year later, in November 2021, it was fully open-sourced. This was accompanied by the founders starting a company, raising a $3 million seed round, and hiring notable React developer and teacher, Kent C. Dodds.
Kent had become infatuated with Remix and rebuilt his entire platform around the framework. During the rebuild he also attempted to individually tell every single person on the internet why using anything except Remix to build literally anything was a terrible choice. He was soon hired as a Developer Advocate and early co-founder of the newly formed company. In this example we will use the Vercel starter to make Fetch requests containing GraphQL queries.
Initialize Starter Project
The create-remix
command can be used to generate various Remix templates with varying deployment providers. We’ll specify the vercel
template and select JavaScript when prompted.
Make sure to select No for npm install
or it will fail due to an unresolvable peer dependency.
Start Development Server
cd
into your project, install the Vercel CLI, and start the development server.
Open localhost:3000 to see the project.
Index Routes
index
routes are routes that renders when the layout’s path is matched exactly. If you have an index.jsx
file in the routes
directory it will be used as the home page. I’ve made a few edits to the boilerplate code.
json
provides a shortcut for creating application/json
responses and meta
sets meta tags for the HTML document.
CSS Styling
Include Water CSS for some styling presets.
Loader Functions
Loaders provide data to components and are only ever called on the server. Since the function only runs on the server, it’s an ideal candidate for requests that include API secrets that cannot be exposed on the client. At the beginning of the tutorial, we created a new route for a GraphQL query called graphql.jsx
.
Each route can define a “loader” function that will be called on the server before rendering to provide data to the route. You can connect to a database or run any server side code next to the component that renders it.
Deploy to Vercel
The starter already includes Vercel specific configuration in remix.config.js
and the @remix-run/vercel
package in server.js
. You can deploy your app by importing a Git repository into Vercel. If you’d like to avoid using a Git repository, you can directly deploy the project with the Vercel CLI:
If this is your first time using the Vercel CLI, it will first ask you to login. You will then be asked a series of questions to configure your Vercel deployment.
Open your website URL (ajcwebdev-remix.vercel.app
in my case) to see the deployed project.