You may need to install express inside server directory. Go inside server directory by cd server and type express myapp. This will generate a complete separate express app using different package.json file.

note: Expressjs generator must be installed before express myapp command. You can install expressjs generator by npm install -g express-generator

Since this is not a good idea for going full-stack in react. You can consider a couple of starter kits for this task.

  1. mern.io This stands for: mongo, express, react and nodejs. This comes with pre-configured React Router, Redux and Server side rendering.
  2. React Starter Kit

React Starter Kit — isomorphic web app boilerplate (Node.js, Express, GraphQL, React.js, Babel, PostCSS, Webpack, Browsersync)

Answer from Ejaz Karim on Stack Overflow
🌐
GitHub
github.com › JedWatson › generator-react-express
GitHub - JedWatson/generator-react-express: React / Express Project Generator
Builds a simple project to help you get started with React on the client, express for the server and browserify to pull it all together.
Starred by 34 users
Forked by 6 users
Languages   JavaScript 92.4% | HTML 4.1% | CSS 3.5%
🌐
Medium
medium.com › @ABiasedHypocrite › simplest-and-fastest-react-express-app-setup-8497ed8db0d1
Simplest and Fastest React Express App Setup | by Jorge Fuentes | Medium
December 11, 2021 - React and Express setup doesn’t have to be complicated. They both come with a project generator you can run from the command line that creates all the basic file structure you need. Since an npm…
People also ask

What is reactjs-express-generator?
React-Express generator is a generator designed to set up an ExpressJs back end with a ReactJs front end. Visit Snyk Advisor to see a · full health score report · for reactjs-express-generator, including popularity, security, maintenance · & community analysis.
🌐
snyk.io
snyk.io › advisor › javascript packages › reactjs-express-generator
reactjs-express-generator - npm package | Snyk
Is reactjs-express-generator popular?
The npm package reactjs-express-generator receives a total · of 3 weekly downloads. As · such, reactjs-express-generator popularity was classified as · · limited. Visit the · popularity section · on Snyk Advisor to see the full health analysis.
🌐
snyk.io
snyk.io › advisor › javascript packages › reactjs-express-generator
reactjs-express-generator - npm package | Snyk
Is reactjs-express-generator safe to use?
While scanning the latest version of reactjs-express-generator, we found · that a security review is needed. A total of · 0 vulnerabilities or license issues were · detected. See the full · security scan results.
🌐
snyk.io
snyk.io › advisor › javascript packages › reactjs-express-generator
reactjs-express-generator - npm package | Snyk
🌐
Express.js
expressjs.com › en › starter › generator.html
Express application generator
Use the application generator tool, express-generator, to quickly create an application skeleton.
🌐
freeCodeCamp
freecodecamp.org › news › create-a-react-frontend-a-node-express-backend-and-connect-them-together-c5798926047c
How to create a React frontend and a Node/Express backend and connect them
September 7, 2018 - Used express-generator to create an express app and named it api. ... Installed all dependencies. Started the app. In your browser, navigate to http://localhost:3000/. If all is ok, you will see the express welcome page. Congratulations! That means you now have a basic Express application running on your local machine. Easy right? To stop your react app, just press **Ctrl + c** in your terminal.
🌐
Reddit
reddit.com › r/reactjs › how do i use react with an express application?
r/reactjs on Reddit: how do I use react with an express application?
September 6, 2023 -

hi so basically I have been using express generator to make new express apps. I can make servers and then endpoint routes and then I then render html files for each of the routes visited and i use PUG as the view engine.

app.set("views", path.join(__dirname, "../views"));app.set("view engine", "pug");

Pug is nice but I am trying to figure out how to use react instead of making views for every route. Also as far as styling, using express generator I seem to only be able to edit styles.css to write vanilla css and then I have to serve the static path.

app.use(express.static(path.join(__dirname, "../public")));

In a nutshell, I am just trying to figure out how to use react with nodejs and express. I read a couple of guides so I think I have the directory structure correct (client and server, each with their own node modules), but not sure on how to proceed. any advice? I've attached my repo. thanks.

https://github.com/ForkEyeee/blog-api

Top answer
1 of 6
43
The above comments didn't mention the core of this post. OP is coming from the templating world (PUG, etc). This is essentially, technically, traditionally server-side rendering. The server handles the request, determines what to render, then sends out a bunch of HTML to the browser. Since 2010s, client side frameworks (like AngluarJS, React, Vue) emerged. In simple words they use pure Javascript to generate the DOM (more or less equivalent to HTML in JS world). The HTML (index.html) is just a blank shell pointing to a script to render UI. This is called Client Side Rendering (CSR). JS can also handle client side routing by mimicking URL changes but under the hood it's just showing and hiding stuff with JS. This is Single Page App (SPA). These files can be served statically with any server/service (like nginx, caddy, S3), and probably not ExpressJS most of the time. So, the first answer to this post is: No you don't need to use Express if you just want a simple SPA, follow the Vite Tutorial till "Deploying" ( https://vitejs.dev/guide/static-deploy.html ). Then, your app probably needs data. The browser has a function called fetch() to fetch data from URL. If you fetch https://www.google.com you will get some HTML strings because it is serving a website directly. If you fetch https://reqres.in/api/users you will get a JSON containing some JSON data. When you build an SPA, all dynamic data will be coming from some API. Express usually works with any SPA as a REST api server, rather than serving the HTML directly. But, SPA is not Search engine friendly because the index.html does not contain any data at all (IDK, thats what people said 5 years ago :/). People started to want SSR again, but still wanted to use React. We then have https://react.dev/reference/react-dom/server . It is used by frameworks like Next.js to render complete HTML with the react rendering, on the server, send it to browser, then "hydrating" the website to be a complete react app. OK, I have gone too far. Anyway, it's still react and your data can still come from a separate Express server no matter what framework you're using. Someone said "Fetching from server A to server B then render HTML to browser is too slow". Then Next.JS and the react team now advocates "React Server Components" (RSC), (not to be confused as SSR) (not to be discussed here). They encourage putting backend logic directly in your Next.js app without an extra API server. So the Express server is not necessary too. As long as you chose react, the express server will never be a templating engine anymore. It's a REST API server that provides data for your react app.
2 of 6
6
Your express is an API, it’s sole purpose would be to serve and ingest content Your client (react app) should make calls to the API then render the data appropriately
🌐
Snyk
snyk.io › advisor › javascript packages › reactjs-express-generator
reactjs-express-generator - npm package | Snyk
An important project maintenance signal to consider for reactjs-express-generator is that it hasn't seen any new versions released to npm in the past 12 months, and could be considered as a discontinued project, or that which receives low attention from its maintainers.
Find elsewhere
🌐
GitHub
github.com › AmanMinhas › create-react-app-with-express-generator
GitHub - AmanMinhas/create-react-app-with-express-generator: Combine create-react-app and express-generator to bootstrap your project
Thank you Facebook. create-react-app makes bootstraping a project plain and simple without you having to work on a bunch of configurations. Express-generator is another popular application generator tool to scaffold your application.
Author   AmanMinhas
🌐
Dave Ceddia
daveceddia.com › create-react-app-express-backend
Create React App with an Express Backend
$ npm install -g express-generator # or: yarn global add express-generator ... It’ll create a react-backend folder.
🌐
npm
npmjs.com › package › generator-express-react
generator-express-react - npm
To install generator-express-react from npm, run: $ npm install -g generator-express-react · Finally, initiate the generator: $ yo express-react · Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced.
      » npm install generator-express-react
    
Published   Dec 04, 2015
Version   0.1.0
Author   Aparna
🌐
npm
npmjs.com › package › generator-react-express-jest
generator-react-express-jest - npm
Yeoman Generator for a React app on Express using webpack and Jest for testing. Latest version: 0.4.1, last published: 3 years ago. Start using generator-react-express-jest in your project by running `npm i generator-react-express-jest`. There are no other projects in the npm registry using ...
      » npm install generator-react-express-jest
    
Published   Feb 05, 2021
Version   0.4.1
Author   Paul van Woensel
🌐
npm
npmjs.com › package › create-react-express-app
create-react-express-app - npm
a boilerplate react frontend with an express backend full-stack app generator. Latest version: 0.9.5, last published: 7 years ago. Start using create-react-express-app in your project by running `npm i create-react-express-app`. There are no ...
      » npm install create-react-express-app
    
Published   Feb 17, 2019
Version   0.9.5
Author   Mateo Navarrete 🤓
🌐
DEV Community
dev.to › techcheck › creating-a-react-node-and-express-app-1ieg
Creating a React, Node, and Express App - DEV Community
February 14, 2024 - In this article, I'll show you how to create a project with React, Node, and Express. We'll get the...
🌐
Neo's Blog
neotan.github.io › express-react-generator-typescript
express-react-generator-typescript
express-react-generator-typescript Express application generator, with TypeScript, Jest, ESLint and optionally React support, which’s inspired by Sean Maxwell’s express-generator-typescript.
🌐
3D Bay
clouddevs.com › home › hire express developers › express and react: building single-page applications
Express and React: Building Single-Page Applications
October 16, 2023 - Similarly, you can use Create React App to set up a React application with all the necessary configurations in place. bash # Installing Express Generator globally npm install -g express-generator # Creating an Express application express my-express-app # Installing Create React App globally npm install -g create-react-app # Creating a React application create-react-app my-react-app
🌐
Flatlogic
flatlogic.com › home › using react with express
Using React with Express - Flatlogic Blog
March 4, 2022 - Express Setup – To create a blog using React start by installing the express generator with this command:
🌐
Medium
medium.com › @dceddia › create-react-app-with-an-express-backend-9fbf7a2e0b59
Create React App with an Express Backend | by Dave Ceddia | Medium
October 10, 2017 - $ npm install -g express-generator # or: yarn global add express-generator ... It’ll create a react-backend folder.
🌐
React Express
react.express
React Express
React is a library for building user interfaces for the web and other platforms. This guide covers the fundamental aspects of React needed to build great web apps. If you're more interested in building mobile apps, consider checking out React Native Express instead.
🌐
GitHub
github.com › tahnik › react-expressjs
GitHub - tahnik/react-expressjs: Simple and compact boilerplate for ReactJS project with expressJS
Simple and compact boilerplate for ReactJS project with expressJS - tahnik/react-expressjs
Starred by 215 users
Forked by 72 users
Languages   JavaScript 79.1% | CSS 10.7% | HTML 10.2%
🌐
YouTube
youtube.com › watch
Build AI Video Generator with React.js, Express.js, Node, GPTScript and Tailwdincss - YouTube
Unique and outstanding fullstack javascript project? Here you go!In this tutorial we are going to build something really amazing - a video generator that tak...
Published   August 8, 2024