How to deploy a React Router 7 site to Netlify

by Philippe Serhal

As strange as it may sound, the next iteration of the Remix web framework is React Router 7.

The Remix framework and the React Router library have converged in a single package that can be used either as a full framework (as with Remix) or as a simple routing library (as with previous versions of React Router).

It also adds support for pre-rendering static pages and brings along a number of significant improvements to routing type safety and flexibility.

Keep reading to find out how to upgrade your Netlify site or deploy a new app.

#How to upgrade to React Router 7

Most apps will be able to upgrade seamlessly with the provided codemod, but be sure to follow the appropriate official migration guide:

Then, replace the Netlify Remix plugin in your project’s Vite config with the Netlify React Router plugin:

Terminal window
npm uninstall @netlify/remix-adapter
npm --save-dev install @netlify/vite-plugin-react-router
vite.config.ts
import { reactRouter } from '@react-router/dev/vite'
import { defineConfig } from 'vite'
import tsconfigPaths from 'vite-tsconfig-paths'
import {netlifyPlugin} from '@netlify/remix-adapter/plugin'
import netlifyPlugin from '@netlify/vite-plugin-react-router'
export default defineConfig({
plugins: [
reactRouter(),
tsconfigPaths(),
netlifyPlugin(),
],
})

Finally, update your netlify.toml as follows. (If you don’t have one, you can create one with these contents.)

netlify.toml
[build]
command = "react-router build"
publish = "build/client"
[dev]
command = "react-router dev"

Then, deploy your site to Netlify as usual.

That’s it. Check out our other Remix guides to learn more about caching, e-commerce, image optimization, and more.

Edge SSR not yet supported

If you had opted in to edge rendering with Remix 2 by using @netlify/remix-edge-adapter, note that this is not yet supported with React Router 7. The above steps will configure rendering at the origin instead.

Psst. Is edge rendering React Router 7 important to you? Let us know.

#How to deploy a new React Router 7 site to Netlify

To deploy a new React Router 7 site to Netlify or move an existing site to Netlify, you can link your repository to automatically build and deploy your app (recommended), or you can deploy manually from the command line.

Netlify CLI

Commands starting with netlify <...> use the powerful Netlify CLI. Install it by running:

Terminal window
npm i -g netlify-cli@latest

To link your site and deploy from the command line, first link your site:

Terminal window
netlify init

As long as you’re using the latest netlify-cli (17.38.1 or later), Netlify will automatically detect that it is a React Router 7 and configure your site appropriately. (If you choose to configure this manually, see the netlify.toml changes described above.)

You can then deploy your site by running:

Terminal window
netlify deploy --build

Alternatively, you can link your repository in the Netlify UI to set up continuous deployment.

That’s it. Check out our other Remix guides to learn more about caching, e-commerce, image optimization, and more.

#Get started

Try it

To get started with React Router 7 on Netlify quickly, you can also clone and deploy a starter template for exploring and experimenting with just a few clicks. Use the button below to dive right in.

Deploy to Netlify

Check out the React Router on Netlify docs for more.