This repo contains an example of a full-stack application with an express backend and a React frontend.
It uses vite as the module bundler and dotenv for configuration. It's organized as a mono-repo using npm workspaces which allows us to have our client and server in one repo.
Note: When you run
npm install
at the root, it will install all dependencies listed inpackage.json
,server/package.json
, andclient/package.json
.
- Create new repo using this one as a template.
- Pull that repo down.
- Update
./server/migration.sql
to the schema for your application.
- Install dependencies:
npm install
- Create your database:
createdb YOUR_DB
- Run your migrations:
psql -f server/migration.sql YOUR_DB
- Create your
.env
file:cp .env.template .env
- Add your info in
.env
- Run the app:
npm run dev
Root
npm run dev
- Runs the API server and hosts your frontend assets.npm run dev:server
- Runs the API server in watch mode.npm run dev:client
- Hosts your frontend assets.
/client
npm run dev
- Hosts your assets.npm run build
- Builds your assets (mainly used in CI/CD).
/server
npm run dev
- Runs the server in watch mode.npm run start
- Starts the server (mainly used when deploying).