Developing a react-monorepo
After generating
Section titled “After generating”Generation copied each apps/*/.env.example to .env, ran yarn install,
formatted the code and made the first commit.
-
Run the API (a nest-api on port 5000). Its trusted origins and CORS must include every app you run.
-
Start every app:
Terminal window yarn dev # turbo runs each app's dev serverlanding on 3000, auth on 3001, client on 3002, admin on 3003 (those you generated).
-
Sign in: open the client at
http://localhost:3002. You’re sent to the auth app’s/login, and after signing in, back to the client.
Scripts
Section titled “Scripts”Root scripts run across every workspace through Turborepo:
| Script | Does |
|---|---|
yarn dev |
Every app’s dev server |
yarn build |
Typecheck and build every app |
yarn typecheck, yarn lint |
Across apps and packages |
yarn format, yarn format:check |
Prettier |
yarn secrets [-e env] |
Each workspace’s .env from Infisical |
One app: yarn workspace client dev, yarn workspace landing build.
API types
Section titled “API types”@scope/types needs packages/types/.env (not created for you):
API_DOC_URL=http://localhost:5000/openapi-jsonAPI_DOC_USER=admin # the API's BASIC_AUTH_USERAPI_DOC_PASSWORD=… # the API's BASIC_AUTH_PASSThen yarn workspace @scope/types gen, and commit src/types/api/: every app
compiles against it. A fresh project ships empty placeholders so it typechecks
before the API exists.
Adding a page
Section titled “Adding a page”Add the route to the app’s src/app/router.tsx, and to src/app/nav.tsx if it
belongs in the sidebar (the shell builds the sidebar from that list, not from
the router). Put its data calls in src/features/<name>/api.ts with
baseApi.injectEndpoints.
Adding a package
Section titled “Adding a package”Create packages/<name> with a package.json named @scope/<name> whose
exports points at ./src/index.ts, depend on it from the apps
("@scope/<name>": "workspace:*"), and add a line for it to the Dockerfile’s
dependency stage. If it contains Tailwind classes, add it to the @source lines
in the UI kit’s globals.css.