Skip to content

Developing a react-monorepo

Generation copied each apps/*/.env.example to .env, ran yarn install, formatted the code and made the first commit.

  1. Run the API (a nest-api on port 5000). Its trusted origins and CORS must include every app you run.

  2. Start every app:

    Terminal window
    yarn dev # turbo runs each app's dev server

    landing on 3000, auth on 3001, client on 3002, admin on 3003 (those you generated).

  3. 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.

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.

@scope/types needs packages/types/.env (not created for you):

API_DOC_URL=http://localhost:5000/openapi-json
API_DOC_USER=admin # the API's BASIC_AUTH_USER
API_DOC_PASSWORD=… # the API's BASIC_AUTH_PASS

Then 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.

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.

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.