DEV Community

Cover image for How to deploy React Router Server Components on Netlify
Patryk Zdunowski
Patryk Zdunowski

Posted on

How to deploy React Router Server Components on Netlify

Recently, React Router introduced experimental support for Server Components, and I'm excited about how this will revolutionize how we build React applications with server-side rendering capabilities.

I've been exploring this feature because it brings the power of server-side rendering directly into React Router, eliminating the need for complex SSR setups. The ability to fetch data and render components on the server while maintaining React's familiar patterns is a game-changer.

However, it's actually quite straightforward to deploy on Netlify right now:

The key is configuring your netlify.toml properly:

[build]
  command = "npm run build"
  publish = "dist/client"
  functions = "dist/rsc"

[[redirects]]
  from = "/*"
  to = "/.netlify/functions/index"
  status = 200
Enter fullscreen mode Exit fullscreen mode

... and that's it!

You get server-side rendering, data fetching, and all the benefits of React Router's new architecture deployed seamlessly on Netlify's edge network.

Complete repository with setup instructions: https://github.com/zdunecki/how-to-deploy-react-router-server-components-on-netlify

Live demo: https://react-router-server-components.netlify.app

I can't wait for the stable release!

Top comments (0)