Skip to content

Sync โ€‹

The Host and the Remote live in separate repositories. mono-utils keeps them in step, and both the Mono Host and the Mono Remote (in the mono-lit/templates monorepo) ship with it installed.

Sync flows both ways, through GitHub. Neither side talks to the other directly โ€” each one pushes to GitHub, and the other picks the change up on its next sync:

A Remote pulls in shell updates from the Host; the Host pulls in each Remote's new modules.

Working with the repos side by side?

Put every app in one repository as sibling folders and connect them by apps[].path โ€” no sync round-trip, and the host hot-updates when a remote changes. See Mono-Lith.

Setup Sync โ€‹

Both templates use these files:

mono-vue-remote/
โ”œโ”€โ”€ .mono/
โ”‚   โ”œโ”€โ”€ apps/                # synced remotes land here
โ”‚   โ””โ”€โ”€ tsconfig.json        # generated path aliases (see Prepare)
โ”œโ”€โ”€ mono.config.ts
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ .env.dev
โ””โ”€โ”€ .env

Everything mono generates lives under one gitignored .mono/ folder. You never edit it by hand.

mono.config.ts โ€‹

Lists the apps to sync. On a Remote, list your Host here:

ts
import { defineConfig, JWTCompleteTokenTypes } from "mono-utils/runtime";

export default defineConfig({
    name: 'mono-remote',
    apps: [
      {
        name: 'mono-host',
        url: 'https://github.com/mono-lit/templates/tree/main/vue-host',
        envToken: 'MONO_TOKEN'
      }
    ]
});

The url carries the ref directly, GitHub-style:

  • โ€ฆ/mono-vue-host โ€” the main branch
  • โ€ฆ/mono-vue-host/tree/v4.0.7 โ€” a tag
  • โ€ฆ/mono-vue-host/tree/feat/layout-program โ€” a branch (slashes are fine)
  • โ€ฆ/mono-vue-host/tree/deac44a955ac63981e6bae705f5df3f2d61dcf0f โ€” a commit SHA

.env and .env.dev โ€‹

envToken names a GitHub token kept in .env or .env.dev:

MONO_TOKEN=YOUR_GITHUB_TOKEN

It is optional โ€” if everyone who syncs the app has been invited to its repo, mono sync uses your own git credentials and never needs a token.

package.json โ€‹

The sync script:

json
{
  "scripts": {
    "mono:sync": "mono sync && mono prepare",
    "mono:prepare": "mono prepare",
    "postinstall": "mono sync && mono prepare"
  }
}

Run Sync โ€‹

pnpm mono:sync

Each app in mono.config.ts is downloaded into .mono/apps/. mono prepare then regenerates .mono/tsconfig.json, so the new app's @<name> alias is available to TypeScript right away.