This is an example app created for the blog post 'What is a good directory structure for a monorepo with a Node.js back end and React front end?'.
- Node.js >= v12
client/
directory - React front end code.server/
directory - Node.js back end code.static/
directory - Compiled front end assets. Created by webpack when you run the commandnpm run build
. The Node.js back end serves serves these assets using theexpress.static
middleware.
# Install dependencies for front end and back end
npm install
# Build front end assets with webpack
npm run build
# Run Node.js back end server
npm start
Load up http://localhost:3000 in your browser to view the example website.
-
Express - "Fast, unopinionated, minimalist web framework for Node.js".
-
React - "A JavaScript library for building user interfaces".
-
Webpack - A popular tool for building front end assets e.g. CSS and JavaScript.
-
Sucrase - A simpler and faster alternative to Babel which brings support for JSX, TypeScript, ES modules, and more to your client side and server side JavaScript.