---
title: "Layout regions"
description: "Declare your layout regions in cmssy.config.ts with defineCmssyLayout. The editor lists exactly those, and the slots are typed to them."
url: https://www.cmssy.com/docs/rendering/layout-regions
---

# Layout regions

Your site declares which regions a layout block can live in. The editor lists exactly those.

Header and footer are not the only places a layout block can live. Since cmssy-sdk 13 the **site declares its regions** in `cmssy.config.ts`, and the editor lists exactly those under Layouts. A sidebar, a top bar, a cookie strip - whatever your app actually mounts.

If you declare nothing, you get `header` and `footer`, the same as before.

## Declaring regions

```ts
// cmssy.config.ts
import { defineCmssyConfig, defineCmssyLayout } from "@cmssy/next";

export const layout = defineCmssyLayout({
  regions: [
    { id: "header", label: "Header" },
    { id: "sidebar", label: "Sidebar" },
    { id: "footer", label: "Footer" },
  ],
});

export const cmssy = defineCmssyConfig({
  org: process.env.CMSSY_ORG_SLUG,
  workspaceSlug: process.env.CMSSY_WORKSPACE_SLUG,
  draftSecret: process.env.CMSSY_DRAFT_SECRET,
  apiUrl: process.env.CMSSY_API_URL, // optional - SDK reads CMSSY_API_URL itself; falls back to https://api.cmssy.io/graphql
  layout, // optional - omit for header and footer only
});
```

An `id` starts with a letter or digit and continues with letters, digits, `_` or `-` (up to 50 characters). Ids are unique, labels are what the editor shows, and a layout holds at most 20 regions. `defineCmssyLayout` throws at startup on anything else - a typo does not reach the editor.

Keep the `regions` array inline in the call. Hoisted into a variable first, TypeScript widens the ids to `string` and you lose the typing below.

## Typed slots

`CmssyRegion<typeof layout>` is the union of your declared ids. Type the slot helper with it and a slot for a region you never declared does not compile:

```tsx
import type { CmssyRegion } from "@cmssy/next";
import { cmssy, type layout } from "@/cmssy.config";

const slot = (position: CmssyRegion<typeof layout>) => (
  <CmssyLayoutSlot config={cmssy} blocks={blocks} position={position} path={path} />
);

{slot("header")}
<aside>{slot("sidebar")}</aside>
<main><CmssyPage {...props} /></main>
{slot("footer")}
```

Import `layout` as a type only. The config module reads server env, and a value import from a client component would pull it into the browser bundle.

The slot fetches the layouts of the routed page - `path` decides, and a page inherits its parent's regions as usual. Pass `page` only to pin a slot to one page regardless of the route (with the `locale` form, which has no path, you have to).

With `cache` set, the slot reads layouts by key (cmssy-sdk 19.35): it first asks for a small key naming the page the layout comes from, then reads the layouts by that key. Every page that inherits the same layout sends the same request, so the data cache answers it once, and a static build pays for each distinct layout once instead of once per page. Without `cache`, in preview and in the editor, the slot reads the page's layouts directly.

## Which blocks a region accepts

A block opts into regions with `layoutRegions`. The editor offers it only in those regions:

```ts
export const sidebarNavBlock = defineBlock({
  type: "sidebarNav",
  label: "Sidebar navigation",
  layoutRegions: ["sidebar"],
  component: SidebarNav,
  props: sidebarNavProps,
});
```

A block without `layoutRegions` is a page block and never appears in a layout.

Before cmssy-sdk 15 the option was called `layoutPositions`. `npx @cmssy/codemod v15` renames it across your code.

## Region settings

A region can carry its own settings, declared with the same `fields.*` builders a block uses for its props. cmssy invents none of them - a header has no width, a sidebar has whatever you say it has:

```ts
import { fields } from "@cmssy/react";

export const layout = defineCmssyLayout({
  regions: [
    { id: "header", label: "Header" },
    {
      id: "sidebar",
      label: "Sidebar",
      settings: {
        width: fields.number({ label: "Width (rem)" }),
        sticky: fields.boolean({ label: "Sticky" }),
      },
    },
    { id: "footer", label: "Footer" },
  ],
});
```

The Layouts page renders a form under the region from that schema - a region without `settings` shows no form. Values are saved per page and inherited down the tree like the blocks themselves, and are validated against your schema on write: an unknown key is refused.

Delivery returns them as `settings` on the layout group, typed with `CmssyRegionSettings`:

```tsx
import type { CmssyRegionSettings } from "@cmssy/next";

type SidebarSettings = CmssyRegionSettings<typeof layout, "sidebar">;
// { width?: number; sticky?: boolean }

const sidebar = groups.find((g) => g.position === "sidebar")?.settings as SidebarSettings | null;

<aside className={sidebar?.sticky ? "sticky" : undefined} style={sidebar?.width ? { width: `${sidebar.width}rem` } : undefined}>
  {slot("sidebar")}
</aside>
```

Requires cmssy-sdk 14. On 13 the delivery query still asks for the old fixed settings shape and fails against the current API - upgrade before deploying.

## How the editor learns about them

On Next, `createCmssyPage` and `createCmssyEditPage` forward the regions to the editor on their own. On Astro and React Router, `loadCmssyPage` / `createCmssyLoader` return `layoutRegions` - pass it to `CmssyEditor` as `edit={{ editorOrigin, layoutRegions }}`. Delivery returns the layout groups keyed by your ids, so `groups.find(g => g.position === "sidebar")` works as you would expect.

## Removing a region

Take a region out of `regions` and its blocks are not deleted. The editor keeps the card, marks it as not mounted by the site, and lets you move or remove the blocks yourself. Nothing disappears from a page because a deploy changed a config file.

Requires TypeScript 5.0 or newer (the typing relies on `const` type parameters). See [Layouts](https://www.cmssy.com/docs/rendering/layouts.md) for inheritance and the public/edit split, and the sdk migration guide [`v12-to-v13`](https://github.com/cmssy-io/cmssy-sdk/blob/main/docs/migrations/v12-to-v13.md) for the rename from `LayoutPosition`.
