Wire MDCMS into a real application you own. This guide covers host app responsibilities, Studio embedding, authentication, and production configuration.Documentation Index
Fetch the complete documentation index at: https://docs.mdcms.ai/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before integrating, you need:- A running MDCMS server — self-hosted via Docker Compose or a managed instance
- The CLI installed and a project initialized —
npx mdcms initcreates yourmdcms.config.tsand syncs your schema - A React application — Next.js App Router is the primary example below; any React framework with catch-all routing works
Host app responsibilities
MDCMS handles content storage, the Studio UI, authentication flows, and the API. Your host app provides the mount point and configuration.| Your app provides | MDCMS handles |
|---|---|
| A catch-all route where Studio mounts | Studio UI, runtime, and in-app navigation |
MDCMS_STUDIO_ALLOWED_ORIGINS includes your app’s origin | Authentication flow and session management |
mdcms.config.ts with project, environment, and server URL | Content storage, versioning, and media |
| Optional: custom MDX component registrations | Schema validation and API serving |
| Optional: SDK queries for rendering content | Published content delivery |
Installing packages
Install@mdcms/studio to embed the visual editor. Add @mdcms/sdk if you also query content for rendering.
Project configuration
Yourmdcms.config.ts (created by mdcms init) drives both CLI sync and Studio embedding. The fields that matter for integration:
mdcms.config.ts
Embedding Studio
Studio is a React component that owns all rendering under a catch-all route (e.g.,/admin/*). The recommended pattern splits server and client concerns so the config can be safely serialized across the boundary.
Basic setup
Use this when you do not register custom MDX components.Create the server component
The server component imports your config, strips non-serializable values via
createStudioEmbedConfig, and passes the result to the client component.app/admin/[[...path]]/page.tsx
basePath is required. Studio cannot infer its mount prefix from deep links
like /admin/content/posts/abc. Set it to the path prefix your catch-all
route uses.Other React frameworks: The pattern is the same for any framework — create a catch-all route that renders the
<Studio> component. In Remix, use a splat route (admin.$.tsx). In Vite with React Router, use a wildcard route (/admin/*). The key requirement is that Studio receives all sub-paths under its mount point.Setup with MDX components
If your app registers custom MDX components for the Studio editor (e.g.,<Chart>, <Callout>, <PricingTable>), use prepareStudioConfig on the server to extract TypeScript prop metadata at build time.
Register components in your config
Add component registrations to your
mdcms.config.ts. Each component needs a name, importPath, and a load function. Optional: propHints for widget customization, propsEditor/loadPropsEditor for fully custom prop editing UI.mdcms.config.ts
Prepare config on the server
prepareStudioConfig reads your component source files and extracts TypeScript prop types so the Studio editor can generate form controls automatically.app/admin/[[...path]]/page.tsx
Authentication and CORS
Studio communicates directly with the MDCMS server API. Authentication determines how Studio identifies the current user.- Token
Studio props reference
| Prop | Type | Description |
|---|---|---|
config | MdcmsConfig | Project, environment, server URL, and optional component registrations |
basePath | string | URL prefix where Studio is mounted (e.g., /admin) |
auth | { mode: "cookie" } | { mode: "token"; token: string } | Authentication strategy (defaults to cookie) |
hostBridge | HostBridgeV1 | Optional bridge for MDX preview rendering from the host app |
fetcher | typeof fetch | Custom fetch implementation |
Fetching content with the SDK
If your app renders MDCMS content (blog posts, pages, etc.), use@mdcms/sdk to query the API:
Production checklist
Before going live, verify each item:- HTTPS everywhere — both the MDCMS server and your host app serve over HTTPS
- Secure cookies —
MDCMS_AUTH_INSECURE_COOKIESis removed or set tofalse - CORS locked down —
MDCMS_STUDIO_ALLOWED_ORIGINSlists only your production origin, notlocalhost - Production mode —
NODE_ENV=productionon the MDCMS server - Strong credentials — database, S3, and Redis credentials are unique and not defaults
- API keys scoped — keys are scoped to the minimum required permissions and rotated periodically
- Real email provider — SMTP is configured with a production provider, not Mailhog
Next steps
Studio Guide
Dashboard overview, navigation, and all Studio features
Schema Guide
Field types, references, environment overlays, and MDX components
CLI Commands
Push, pull, login, schema sync, and all CLI flags
SDK Reference
Full typed client API for content reads