@fairgarden/monolith

Compose several Next.js apps into one deployable app.

Next only supports basePath for a monorepo, which is the right shape when each app is built and deployed on its own. A self-hosted core or starter distribution wants the opposite: one server, one build, one thing to run. This library mounts each app's routes under a path prefix and merges their configs so that works.

// apps/monolith/next.config.ts
import { withMonolith } from '@fairgarden/monolith'

export default withMonolith(
  {},
  {
    id: '@fairgarden/id',
    membership: '@fairgarden/membership',
  }
)

id's routes are then served from /id, its assets from public/id, and its Pages Router API from /api/id.

Start here

Install

pnpm add @fairgarden/monolith

The package has three entry points:

| Import | For | | --- | --- | | @fairgarden/monolith | the monolith's next.config.ts, and an app's portability check | | @fairgarden/monolith/link | an app's own components | | @fairgarden/monolith/eslint | an app's eslint.config.mjs |

It also installs a fg-monolith command for the things that have to happen before a build.