Publish a site to AWS

A Mosaic site is a Next.Js app.

To publish a Next.Js App to AWS, deploy your app as a SSR application by following the AWS docs.

Once the basic app has been configured, add the Mosaic specifics.

The site is deployed with a snapshot of your content in snapshot-file mode, so generate a snapshot with yarn gen:snapshot and commit it with the site.

Add the environment vars to the hosted app via the Amplify console

MOSAIC_MODE="snapshot-file"
MOSAIC_SNAPSHOT_DIR="snapshots/latest"
NEXT_PUBLIC_SITE_URL="https://your-site.example.com"

NEXT_PUBLIC_SITE_URL

Set this to the canonical public origin of the deployed site (no trailing slash). It powers Next's metadataBase in app/layout.tsx, the absolute <loc> entries in /sitemap.xml, and the Sitemap: line in /robots.txt. Without it, social-card unfurlers (Slack, X, LinkedIn, etc.) can't resolve relative og:image URLs and crawlers can't discover the sitemap.

Falls back to http://localhost:3000 in local dev. A production build without it still works but logs a loud warning at boot and produces broken social cards / SEO. If it is set but isn't an absolute http(s) URL, the site refuses to start.

Add the following build settings

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - yarn install
        - env | grep -e MOSAIC >> .env.production
    build:
      commands:
        - yarn run build
  artifacts:
    baseDirectory: .next
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

Ensure the Node is set to 16

Mosaic BETA

Coming soon