Server-side rendering
Introducció
Section titled “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
Section titled “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-ssrbun run dev
After that, open your browser and visit the URL http://localhost:5173.
How to build SSR pages
Section titled “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:
El contingut d'aquest lloc web té llicència CC BY-NC-ND 4.0.
©2022-2025 xtec.dev