Build a website on the Brain CMS
Read published pages, entries and menus from your website's server and refresh on publish.
Set up access
- In Nucleo, go to CMS > your site > Settings > For developers.
- Copy the base URL of the site.
- Select Create token and store the
cmsdt_…value as a secret on your server — it is shown once.
The token reads only that site's published content. Call the API from your server or at build time: it does not accept browser calls, so the token never reaches visitors.
Fetch a page
Resolve the URL the visitor asked for into a page:
// Next.js (App Router): app/[...slug]/page.js
const BASE = "https://api-brain.nucleoplatform.com/api/delivery/v1/acme/sites/12";
async function nucleo(path) {
const res = await fetch(`${BASE}${path}`, {
headers: { Authorization: `Bearer ${process.env.NUCLEO_CMS_TOKEN}` },
next: { tags: ["nucleo"] },
});
if (res.status === 404) return null;
if (!res.ok) throw new Error(`Nucleo CMS: ${res.status}`);
return res.json();
}
export default async function Page({ params }) {
const { slug = [] } = await params;
const page = await nucleo(`/page?path=/${slug.join("/")}&locale=en`);
if (!page) return notFound();
// render page.data …
}<?php
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api-brain.nucleoplatform.com/api/delivery/v1/acme/sites/12/',
'headers' => ['Authorization' => 'Bearer ' . getenv('NUCLEO_CMS_TOKEN')],
'http_errors' => false,
]);
$res = $client->get('page', ['query' => ['path' => '/about', 'locale' => 'en']]);
$page = $res->getStatusCode() === 200 ? json_decode($res->getBody(), true) : null;Use /collections/{collection}/entries for blog posts and news, /menus for navigation, /redirects to apply the redirects your editors set and /sitemap to build sitemap.xml. All of it is in the Content Delivery reference.
Refresh when editors publish
Cache everything you fetch and let Nucleo tell you when to refresh: set a Revalidate URL and secret in the site settings and handle the call as shown in Webhooks.