React SSR not working in Production Build.
See original GitHub issueDescribe the bug
I managed to get SSR with React and Vite working with the command “vite” but when i try to build with “vite build” and serve it with “vite preview” SSR got not working. The code is Public and i want to Maintain it as a good template: https://github.com/Trackhe/Vite-React-SSR-HMR
Reproduction
Reproduction clone my code, then npm i
-> npm run dev
try all works. shutdown and try npm run preview
, look in the loaded document now no SSR
System Info
System:
OS: macOS 12.4
CPU: (20) arm64 Apple M1 Ultra
Memory: 19.76 GB / 64.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.0.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.10.0 - /opt/homebrew/bin/npm
Browsers:
Chrome: 102.0.5005.61
Safari: 15.5
npmPackages:
@vitejs/plugin-react: * => 1.3.2
vite: * => 2.9.9
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Server side rendering not work on production build Next.js
I'm new on Next.js and my previous apps on react can't do server side rendering, so i a bit confuse about it. Any...
Read more >Server Side Rendering Not Work On Production ... - ADocLib
Server Side Rendering Not Work On Production Build Next.Js. Server-side rendering (SSR) is a popular technique for rendering a client-side in this tutorial ......
Read more >How to Enable Server-Side Rendering for a React App
In this tutorial, you will initialize a React app using Create React App and then modify the project to enable server-side rendering.
Read more >Improve app performance with React server-side rendering
In this article, we'll investigate different types of rendering for web applications.
Read more >Build Your Own SSR/SSG From Scratch with Vite and React
It means server actually doing the heavy lifting before responding to the upcoming requests. If you are doing SSR with React you will...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll close this as it doesn’t seem to be a bug in Vite, but more of a usage issue. Re
configurePreviewServer
, the feature has been backported to thev2
branch and will make it’s way in 2.9.10 when it’s released.When i try that i got errors like no loader for .svg is configured and when i comment that out TypeError: server.transformIndexHtml is not a function and there is where i dont know to continue.