Skip to main content

getRegisteredApps

The apps seen by the most recent withMonolith evaluation.

getRegisteredApps(): ResolvedApp[]

This exists so tooling can discover what a monolith composes without a second source of truth. fg-monolith loads the monolith's next.config.* with FG_MONOLITH_SKIP_LINK=1, so nothing is written to the file tree, and then reads the list back.

import { getRegisteredApps } from '@fairgarden/monolith'

process.env.FG_MONOLITH_SKIP_LINK = '1'
const config = (await import(configPath)).default
if (typeof config === 'function') await config('phase-production-build')

for (const app of getRegisteredApps()) {
  console.log(app.prefix, app.root)
}

Returns

A ResolvedApp per mounted app:

FieldMeaning
namemount name
prefixpath prefix, /<name>
rootthe app directory on disk
packageNamethe app's own package name, when it has one
appDirits App Router directory
publicDirits static assets, when it has any
pagesDirits Pages Router directory, when it has one
pagesApiDirits pages/api, when it has one
apiViaPageswhether /api/... paths are Pages Router API routes
nextConfigits loaded config

Notes

Empty until a withMonolith config has been evaluated, and replaced on each evaluation rather than accumulated. It reflects one monolith, not several.