apps/web + apps/admin + apps/api

Three apps, one monorepo.

8 mineasy

Tour all three apps. We already covered apps/api in the Go API course; this lesson focuses on apps/web and apps/admin โ€” what's the same, what's different.

apps/web โ€” the public Next.js site

apps/web/
apps/web/
โ”œโ”€โ”€ app/
โ”‚ โ”œโ”€โ”€ (marketing)/ public pages โ€” landing, pricing, blog
โ”‚ โ”‚ โ”œโ”€โ”€ page.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ pricing/page.tsx
โ”‚ โ”‚ โ””โ”€โ”€ layout.tsx header + footer
โ”‚ โ”œโ”€โ”€ (auth)/ login, signup, forgot-password
โ”‚ โ”œโ”€โ”€ (app)/ logged-in pages โ€” dashboard, settings
โ”‚ โ”‚ โ”œโ”€โ”€ dashboard/page.tsx
โ”‚ โ”‚ โ””โ”€โ”€ layout.tsx sidebar + topbar
โ”‚ โ”œโ”€โ”€ api/ Next.js route handlers (mostly empty)
โ”‚ โ””โ”€โ”€ layout.tsx root layout โ€” theme, providers
โ”œโ”€โ”€ components/ reusable React components
โ”œโ”€โ”€ hooks/ useUsers, useCurrentUser, โ€ฆ
โ”œโ”€โ”€ lib/ api client, auth helpers, utils
โ””โ”€โ”€ public/ static assets

Three route groups: (marketing), (auth), (app). Each has its own layout. The parens don't appear in URLs.

apps/admin โ€” the staff panel

apps/admin/
apps/admin/
โ”œโ”€โ”€ app/
โ”‚ โ”œโ”€โ”€ (auth)/login/page.tsx
โ”‚ โ”œโ”€โ”€ dashboard/page.tsx
โ”‚ โ”œโ”€โ”€ resources/
โ”‚ โ”‚ โ”œโ”€โ”€ users/page.tsx defineResource() โ€” generates CRUD
โ”‚ โ”‚ โ””โ”€โ”€ products/page.tsx
โ”‚ โ””โ”€โ”€ layout.tsx admin shell โ€” sidebar, top nav
โ”œโ”€โ”€ components/
โ”‚ โ”œโ”€โ”€ admin/ DataTable, FormBuilder, etc.
โ”‚ โ””โ”€โ”€ ui/ shadcn primitives
โ”œโ”€โ”€ hooks/
โ””โ”€โ”€ lib/

The killer file is app/resources/x/page.tsx โ€” we cover defineResource() in chapter 4. Almost every admin page is one of these.

What's the same across both apps

  • Both use Next.js 14 App Router (no Pages Router)
  • Both import types from @workspace/shared
  • Both use React Query for data
  • Both use shadcn/ui + Tailwind CSS

What differs

  • Auth scope โ€” web cookies are scoped to customer-token; admin to staff-token. One can't accidentally log into the other.
  • Layout โ€” web is marketing-shaped (header / hero / footer); admin is dashboard-shaped (sidebar / topbar).
  • Robots โ€” admin has noindex,nofollow on every page.
The shared API client trick: both apps import the same lib/api.ts shape but configure it with different cookie names. We'll see this in chapter 3.

Quick check

A teammate suggests deleting apps/admin and gating admin URLs inside apps/web by role. Trade-off check โ€” what's the biggest downside?

Try it

In your scaffolded project, open both apps/web/app/layout.tsx and apps/admin/app/layout.tsx. In notes.md, write:

  • What providers does each app wrap children in?
  • What's in each app's root metadata (title, OG, etc.)?
  • What one component or import is DIFFERENT between them?

What's next

Last lesson of the chapter โ€” packages/shared, the glue between the three apps.

Spot a typo? Have an idea?

Help us improve this lesson. One click opens a GitHub issue with the lesson URL pre-filled, suggest clearer wording, report a bug, or request more depth. The course keeps improving thanks to learners like you.

Suggest an improvement on GitHub