惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
H
Help Net Security
Jina AI
Jina AI
V
V2EX
G
Google Developers Blog
B
Blog
GbyAI
GbyAI
U
Unit 42
爱范儿
爱范儿
腾讯CDC
Engineering at Meta
Engineering at Meta
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 三生石上(FineUI控件)
宝玉的分享
宝玉的分享
小众软件
小众软件
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - Franky
博客园 - 聂微东
The Cloudflare Blog
I
InfoQ
Microsoft Azure Blog
Microsoft Azure Blog
Hugging Face - Blog
Hugging Face - Blog
大猫的无限游戏
大猫的无限游戏

Netlify Developers

AI model comparison using Netlify's AI Gateway | Netlify Developers Build an AI agent to automatically process and summarize form submissions | Netlify Developers Build an AI agent to automatically generate relevant images for blog posts | Netlify Developers Prerendering SPA content pages to enable AI agent access | Netlify Developers Identify image optimization opportunities with Netlify Observability | Netlify Developers Fix top 404 page not found errors with Netlify Observability | Netlify Developers Introducing AI Gateway: built-in AI model access on Netlify | Netlify Developers Introducing Observability: your project insights on Netlify | Netlify Developers From first publish to first update with AI agents | Netlify Developers How to use Agent Runners on Netlify | Netlify Developers Add forms to your project with AI + Netlify | Netlify Developers Track Real User Metrics | Netlify Developers Lighthouse performance scores on Netlify | Netlify Developers Review your AI project before you ship | Netlify Developers Using environment variables in AI Projects on Netlify | Netlify Developers Build prototypes and MVPs fast with AI + Netlify | Netlify Developers Pause auto-publishing on Netlify | Netlify Developers Run serverless functions, storage, and more natively in Nuxt dev | Netlify Developers Netlify Office Hours: The AX Arcade challenge | Netlify Developers Netlify Office Hours: Prompting with style | Netlify Developers Netlify Office Hours: RAG Apps with OpenAI + Netlify DB | Netlify Developers How to build a RAG application with Neon, Netlify & OpenAI | Netlify Developers Netlify Office Hours: Netlify DB (powered by Neon) | Netlify Developers Netlify Office Hours: Netlify MCP Server | Netlify Developers Netlify Office Hours: Netlify Vite Plugin | Netlify Developers Building MCPs with Netlify | Netlify Developers Deploying sites from your AI tool | Netlify Developers Adding your domain using Netlify API | Netlify Developers Build a context driven chat bot with Netlify Blob and OpenAI | Netlify Developers Simplify deployments with Netlify’s branch-matching environment variables | Netlify Developers
How to deploy a React Router 7 site to Netlify | Netlify ...
2024-12-19 · via Netlify Developers

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.

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:

npm uninstall @netlify/remix-adapter

npm --save-dev install @netlify/vite-plugin-react-router

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.)

[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:

npm i -g netlify-cli@latest

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

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:

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.