Developers

Overlay & login

Wire the in-page editor: load @macrocontent/overlay, open the sign-in modal, and activate inline editing after session.

No /login page
Editors sign in through an in-page modal via ⌘⇧M / Ctrl+Shift+M (Mod+Shift+M). Configure the chord in macro.config.js.

Packages

bash
pnpm add @macrocontent/sdk @macrocontent/overlay

With the Vite plugin (or loader), Macro dynamically imports DefaultMacroOverlay when overlay is enabled. If the overlay package fails to load, the SDK continues in read/hydrate mode and logs a warning.

Config

macro.config.js
export const macroConfig = {
  apiBaseUrl: 'https://api.macrocontent.dev',
  websiteId: 'your-website-uuid',
  publicKey: 'pk_...',
  editorLogin: {
    enabled: true,
    shortcut: 'Mod+Shift+M',
    triggers: true,
  },
  overlay: {
    enabled: true,
    theme: 'dark',
    position: 'bottom-right',
    mode: 'full',
    showCloseButton: true,
  },
  openOverlayOnSession: true,
  enableInlineEditing: true,
}
NameTypeDescription
editorLogin.shortcutstringDefault 'Mod+Shift+M'.
editorLogin.triggersbooleanWire [data-macro-editor-login-trigger] clicks.
overlay.enabledbooleanLoad @macrocontent/overlay adapter.
openOverlayOnSessionbooleanOpen shell when a session already exists.
enableInlineEditingbooleanEnable inline surfaces after login.

Login triggers

Besides the keyboard shortcut, any element with data-macro-editor-login-trigger opens the modal when editorLogin.triggers is true (default).

header.html
<button type="button" data-macro-editor-login-trigger>
  Edit with macrocontent
</button>

Session flow

  1. Visitor / anonymous

    SDK hydrates live content with the frontend key. Overlay editing stays closed.

  2. Editor signs in

    Modal authenticates a website editor (site_users) for this websiteId. Session cookies / tokens are website-scoped.

  3. Overlay activates

    Inline editing, sidebar, drafts, and SEO tab become available. Autosave writes to the active draft. See the Editors handbook.

Programmatic init

For custom boots (without the loader), the contract looks like:

boot.ts
import { initMacroSdk } from '@macrocontent/sdk'

await initMacroSdk({
  websiteId: 'website-uuid',
  apiBaseUrl: 'https://api.macrocontent.dev',
  publicKey: 'pk_...',
  editorLogin: { enabled: true, shortcut: 'Mod+Shift+M' },
  autoSaveDebounceMs: 800,
  overlay: true,
})

Theme & chrome

  • theme: 'dark' | 'light' selects overlay theme tokens.
  • Position corners: bottom/top × left/right.
  • Editor chrome selectors (data-macro-editor-*) are excluded from “click outside = deselect content” logic.

Do

  • Keep overlay enabled in staging so content teams can verify UX.
  • Document the shortcut for editors (same chord on every site).

Don’t

  • Don’t ship a parallel CMS login URL — the modal is the supported path.
  • Don’t put management tokens in the overlay config.