Comments (6)
Hi @mattiasewers,
Thanks for looking at react-server
! You're right, we actually don't use react-server-cli
in production, but that's mostly because it didn't exist until much later. We pulled the core of react-server
out into a stand-alone package so we could open source it, and @aickin set up the react-server-cli
to fill in some of the gaps that were left. It actually provides much more than just a CLI:
- A build that generates javascript bundles for client-side use
- Middleware that handles loading those bundles as needed
- A basic express server that ties it all together
- A CLI for configuring it all
Those are all bits that we do separately at Redfin, but actually react-server-cli
does a nicer job in some ways than we do with our internal build. The "routes" file format is much nicer, for example. Medium term we're thinking about how to make those available independent of the "CLI" part of react-server-cli
.
There are, still, some things that we use internally that we haven't pried out into packages we can share yet (but we're working on it!)
For example:
- A server cluster with:
- Fault tolerance/isolation
- Graceful restart
- Log file management
- A beacon framework for gathering stats and errors from the browser
- A statsd interface to track all those
logger.time
values (this is crucial for us)
Our goal is to make those available as soon as we can and let them integrate easily with react-server
and react-server-cli
.
In the short term, I think the answer is probably: Use react-server-cli --compile-only
and run the build it produces in a custom production server. We need some documentation on how to do that.
Thanks for calling this out. I've opened #188 for adding "running in production" documentation.
from react-server.
Yep!
Just hand the server and the (compiled) routes to the middleware
function exported by react-server
:
const express = require("express");
const rs = require("react-server");
const routes = require("./routes"); // Compiled by `react-server-cli`.
const server = express();
rs.middleware(server, routes);
from react-server.
Use react-server-cli --compile-only and run the build it produces in a custom production server. We need some documentation on how to do that.
You're going to want --production
on there as well. Also, there's a section of react-server-cli
's doc that addresses how to use it in production.
You are right that it doesn't cover server clustering, beacons, or logging, but I think it's the best answer we have right now, and for many sites it'll be a reasonable answer.
from react-server.
Thanks @aickin!
from react-server.
@gigabo Thanks, very thoughtful answer! This is arguably the easiest way to scaffold a react app with ssr, very promising!
Alright, so ssr would not work in production as of yet? Rather use the client side code splitting that react-server-cli
outputs? This I have already set up in my production but will definitely use this once sir works in production, get it up and great work! I'll be watching closely!
from react-server.
Closing this in favour of #188
Also, If you don't mind me asking, will react-server
work with an existing express server without the use of react-server-cli
, aside from compiling?
from react-server.
Related Issues (20)
- Upgrade to Webpack 4 + Babel 7 HOT 1
- compileOnStartup feature left out
- finishRoute() never fired when all elementPromises don't resolve
- Question:how does react-server achieve stream pre-rendered HTML
- Hi
- TODO IE8-9 Detection
- TODO if OSX && key is.Meta?
- ReactServerAgent only suited for use in pages?
- Build Server & Client Libraries with esnext and ES Modules HOT 4
- Page request fired twice when using bundleData
- Make react-loadable in the react-server HOT 1
- Hash fragment removed from URL in browser in version 0.8.1, how can I save it in URL for scroll to section?
- https://react-server.io/ returning 503 HOT 2
- TODO: handle compilation errors with a --reportwarnings flag
- TODO: create a READEME.md for flab
- TODO: use config for env var in repo.js
- TODO: support dash-separated options in config
- Improve Lerna + NPM Integration
- NPM Audit
- Do Lint Better
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-server.