Skip to content

@conloca/cms-spa

Overview

@conloca/cms-spa is the React-based admin interface for Conloca CMS. It provides the full CMS experience: visual page editing with Puck, block management with MDX, a media library, data schema editing, git operations, and multi-locale content management.

This package is consumed by @conloca/astro-cms — developers do not install it directly. The Astro integration bundles and serves the SPA automatically at the configured CMS route (default: /__cms).

Architecture

The SPA is built as a pre-bundled React application served via Astro middleware:

  1. Build time: The SPA is compiled into hashed static assets (dist/spa/)
  2. Runtime: The CMS handler injects the Puck config and UI config into the HTML
  3. Client: React Router handles navigation within the CMS

Key UI Areas

AreaDescription
DashboardOverview of content, recent changes, needs-review items
PagesSite-scoped page list with locale management
BlocksShared and site-specific block collections
DataData schema editor for structured content
Media LibraryAsset management with folders, tags, and usage tracking
Page EditorPuck visual editor with drag-and-drop components
Block EditorMDX editor for block content
GitStatus panel, commit, push, pull operations

Entry Points

ImportPurpose
@conloca/cms-spaMain CMS application exports (UIConfig type)
@conloca/cms-spa/data-schemasData schema editor component
@conloca/cms-spa/page-schemasPage schema editor component
@conloca/cms-spa/puck-configPuck configuration wrapper and utilities
@conloca/cms-spa/mainApplication bootstrap entry point
@conloca/cms-spa/dist/spa/*Pre-built static SPA assets (HTML, JS, CSS)

Customization

The CMS UI is configured through the Astro integration options, not by importing this package directly.

Puck Components

Custom Puck components are provided via the puckConfigPath option in conlocaCMS(). The config file exports a Puck configuration object:

// src/puck.config.tsx
import type { Config } from '@puckeditor/core'

const config: Config = {
  components: {
    Hero: {
      fields: { title: { type: 'text' } },
      render: ({ title }) => <h1>{title}</h1>,
    },
  },
}

export default config

The CMS loads this config via a Vite virtual module, enabling Hot Module Replacement during development.

Data Schemas

Data schemas define structured content types beyond pages and blocks:

// src/schemas.ts
import { z } from 'zod';

export const dataSchemas = {
  'blog-posts': z.object({
    title: z.string(),
    author: z.string(),
    publishDate: z.coerce.date(),
  }),
};

UI Configuration

The UIConfig type controls SPA behavior:

FieldTypePurpose
basenamestringBase path for CMS routes
apiBaseUrlstringBase URL for API requests
siteBaseUrlstringBase URL for the live site
enableDevtoolsbooleanShow React Query devtools (default: false)
queryClientOptionsQueryClientConfigTanStack Query client configuration
projectRootstringProject root path for file operations
schemasPathstringPath to schemas directory
templatesRecord<string, TemplateConfig>Page creation templates

Technology Stack

LibraryPurpose
React 19UI framework
React RouterClient-side routing
TanStack React QueryData fetching and caching
PuckVisual page editor
MDX EditorBlock content editing
Tailwind CSSStyling
Radix UIAccessible dialog, select, dropdown components
Lucide ReactIcons