Router - Server-side rendering

Introducció

React Router can be used as either a routing library or a full-stack framework, incorporating the entire functionality of Remix.

Entorn de treball

Install the React Router framework by running npm create vite. “React Router v7” is available as one of the options under React Vite templates. Selecting this option will redirect you to the React Router framework CLI to complete the installation.

bunx create-react-router@latest react-router-ssr

This will create a folder with whatever you named your project. Change into that directory, then start the development server of the application:

cd react-router-ssr
bun run dev

After that, open your browser and visit the URL http://localhost:5173.

How to build SSR pages

In order to use React Router v7 for SSR, make sure ssr is set to true in the React Router configuration file. It is set to true by default. Open the react-router.config.ts file in your code editor to confirm:

TODO

Server-side rendering with React Router v7