This project contains scaffolding for a simple full stack web app.
src/client
contains the React appsrc/server
contains the Node Express.js apppackage.json
in the project root contains scripts to run in dev mode locally, and also to build and run on Heroku
All commands run from project root:
cd src/client && npm install
cd src/server && npm install
- Make sure
nodemon
&concurrently
are installed globally npm run dev
You will now see the output of both the React dev server and the Node server in your shell, running at the same time thanks to concurrently
. Enjoy!
The Node Express.js server is initialized with one router mounted at /api
. We've implemented a sample route at /api/users
. Edit the src/server/routes/api.js
file to add your own routes and server-side logic.
In the React app, you can see in src/client/src/App.jsx
where we're calling /api/users
using fetch
. App.jsx
is a functional component, so you can see how we're using useEffect
to call our API on component mount, and useState
to update component state when we receive a response from the API.