concept Express in category react

appears as: Express
Isomorphic Web Applications: Universal Development with React

This is an excerpt from Manning's book Isomorphic Web Applications: Universal Development with React.

On the server side, you’ll build a Node.js server using Express to handle routing. You’ll take advantage of React’s ability to render on the server and use it to build up a complete HTML response that can be served to the browser. Table 1.1 shows how all these pieces fit together.

Express is a framework for Node.js that makes it easy to build REST APIs and to implement view rendering. In the All Things Westies app, Express handles the incoming requests to the Node.js server—for example, when the user wants to go to the Products page, the first place the request gets handled is by the Express app routing. Part of building an isomorphic app with JavaScript is handling initial requests to your web server; the server handles routing, fetching data, and rendering the page. The fully rendered page is then sent in the response to the browser.

Figure 7.6. Routing to the test route with Express
React Quickly: Painless web apps with React, JSX, Redux, and GraphQL

This is an excerpt from Manning's book React Quickly: Painless web apps with React, JSX, Redux, and GraphQL.

In a new window, open your favorite static server (I use node-static, but you can create your own using Express), and navigate to the location in your browser. Try going to / and /#/about; the exact URL will depend on whether you’re running your static server from the same folder or a parent folder.

  • Implement and serve React browser files via Express—Eventually, you’ll need an HTTP(S) server, and Express is one of the options. Until now, you’ve used node-static or Webpack Dev Server. At this point, there’s no server-side HTML generation, just serving built/compiled static assets.
  • This is a more interesting example in which you’ll use some external plug-ins and a template engine. The idea for the app is the same: serve HTML generated from React using Express. The page will display some text that’s generated from about.jsx (see figure 17.5). No thrills, but it’s simple, and starting with simple is good.

    Figure 17.6. Rendering React markup from a Handlebars layout using Express gives you an HTML page.