Git Product home page Git Product logo

Comments (6)

gigabo avatar gigabo commented on May 4, 2024 2

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.

gigabo avatar gigabo commented on May 4, 2024 1

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.

aickin avatar aickin commented on May 4, 2024

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.

gigabo avatar gigabo commented on May 4, 2024

Thanks @aickin!

from react-server.

mtsewrs avatar mtsewrs commented on May 4, 2024

@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.

mtsewrs avatar mtsewrs commented on May 4, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.