A modern Yarn 4 monorepo starter with:
- client: Vite + React 19 + MUI
- server: Node/Express utilities (ESM)
- shared: isomorphic utilities used by both client and server
This README covers cloning, installing Node & Yarn, installing dependencies, running in dev, building, environment configuration, linting, quick testing, and adding a Git repository/remote.
- Node.js 20+ recommended (LTS works). Verify with:
node -v
- Yarn 4 via Corepack (pinned to yarn@4.10.2 in package.json). Enable Corepack once:
corepack enable- Optionally verify:
yarn -v
If you don't have Node, install from https://nodejs.org or via a version manager (nvm, fnm, volta).
- Using HTTPS:
git clone https://github.com/<your-org-or-user>/react-boilerplate.git
- Or with SSH:
git clone git@github.com:<your-org-or-user>/react-boilerplate.git
Then change into the project directory:
cd react-boilerplate
If you created a new, empty repo locally:
git init -b maingit remote add origin https://github.com/<your-org-or-user>/<your-repo>.git- Add your first commit:
git add -Agit commit -m "chore: initial commit from react boilerplate"git push -u origin main
Run at the repository root only (workspaces are wired automatically):
yarn install
This uses the pinned Yarn 4 via Corepack and installs for all workspaces.
- client: Vite app, React 19, MUI; dev via
vite, build viavite build. - server: Node service; dev via
nodemonwatchingsrc, start vianode src/lockpickersUnitedServer.js. - shared: Common ESM modules used by both client and server.
- client-dist: Build artifact copied from
client/distby the root build script (do not edit directly).
From the repo root:
- Full dev (client + server concurrently):
yarn dev- Client: Vite on http://localhost:5173
- Server: nodemon on the API (see server section)
Client-only:
yarn workspace @starter/client dev
Server-only:
yarn workspace @starter/server dev
Convenience aliases at root:
yarn client→ client dev serveryarn server→ API dev server
- Build client and copy artifact to
client-dist/:yarn build
- Build all workspaces that define a build script:
yarn build-all
- Preview the built client (serve static):
yarn workspace @starter/client preview --port 3000
Notes:
- Root build currently builds only the client. If the server needs a build step later, wire it via its workspace
buildscript and rely onbuild-all.
Server reads .env via dotenv in server/src/lockpickersUnitedServer.js. Create server/.env with:
# Optional: comma-separated CORS origins. In dev, defaults to permissive true.
CORS_ORIGIN=http://localhost:3000,https://example.com
# Required for /api/discord: full Discord webhook URL.
# If missing, server returns { error: 'server_misconfigured' } for that route.
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/…
Client environment variables (if you add any) should follow Vite’s convention and be prefixed with VITE_ (e.g., VITE_API_BASE). Access via import.meta.env.VITE_API_BASE.
Readiness and health endpoints (server):
GET /api/ready→{ ready: true }GET /api/health→{ ok: true }
- Run linter at root:
yarn lint
- Config:
eslint.config.cjs(flat config). Highlights:- React rules enabled;
react/prop-typesdisabled. no-unused-vars: warn withignoreRestSiblings: true.react-hooks/exhaustive-deps: warn.- Quotes: single preferred; Semicolons: omitted (warn on deviations).
import/extensions: enforce bare imports for js/jsx; json requires explicit.json.
- React rules enabled;
A formal test framework isn’t configured. For quick checks, use Node’s built-in assert in a temporary file and run it directly with Node. Example:
Create shared/src/example.test.js:
import assert from 'node:assert/strict'
import { API_PREFIX, sleep } from '@starter/shared'
assert.equal(API_PREFIX, '/api', 'API prefix should be /api')
const t0 = Date.now()
await sleep(50)
assert.ok(Date.now() - t0 >= 45, 'sleep should wait ~50ms')
console.log('ok: shared utilities basic tests passed')Run it:
node shared/src/example.test.jsThen remove the temporary test file to keep the repo tidy.
Guidance for future tests:
- Consider Vitest for the client and a light-weight runner (Vitest or node:test) for shared/server.
- Keep tests workspace-local and ESM-friendly.
Initialize a new repo locally (if starting fresh):
git init -b maingit add -Agit commit -m "chore: initial commit"
Add a remote and push:
- HTTPS:
git remote add origin https://github.com/<your-org>/<your-repo>.git - SSH:
git remote add origin git@github.com:<your-org>/<your-repo>.git git push -u origin main
If you cloned first and just need to set your own remote:
git remote set-url origin https://github.com/<your-org>/<your-repo>.git
- Client (Vite): Fast Refresh enabled; use browser devtools. If you see import resolution warnings for bare imports or JSON extensions, check ESLint rules and Vite aliasing.
- Server:
yarn workspace @starter/server devgives nodemon reloads. For inspector:NODE_OPTIONS=--inspect yarn workspace @starter/server start
- Shared: Keep modules ESM-friendly; avoid CommonJS-only patterns unless gated.
client/ # Vite + React 19 app
server/ # Node/Express utilities (ESM), routes, .env support
shared/ # Common isomorphic utilities
client-dist/ # Build artifact copied from client/dist (do not edit)
scripts/ # Build and convenience scripts
- Ensure Corepack is enabled; Yarn should be v4.x per the repo pin:
corepack enable && yarn -v
- Delete node_modules and reinstall if packages look out-of-sync:
rm -rf node_modules && yarn install
- Port conflicts: Vite defaults to 5173; preview example uses 3000.
- Discord webhook errors will surface as
discord_webhook_failed; ensureDISCORD_WEBHOOK_URLis set and valid.
See LICENSE.