Setting Up Initial Data
Use initialData to seed pages, globals, and safe defaults so a fresh Next.js environment can render real content immediately.
Use this page when your website already has real content and you do not want Dyrected to open with blank collections, blank globals, and nothing useful to render.
To avoid a blank CMS, you can set up initialData.
By the end, you should understand what initialData does, when it runs, and how to use it to make a new Next.js environment feel ready instead of empty.
In the quick-start flow, this is the bridge between modeling content and proving the frontend can render it. Once the seed data is in place, the next page turns that content into a real Next.js route.
What initialData is for
initialData is Dyrected's first-run seed mechanism. It gives a collection or global a starting value the first time Dyrected fetches it and finds it empty.
That makes it a good fit for:
- demo content
- starter pages
- navigation defaults
- site settings a frontend depends on immediately
It is not a sync system. It is a starting point.
The most important rule
Seeding only happens while the target is still empty.
Once a collection has any documents, or a global has any saved value, initialData no longer applies. Editors own the content from that point forward.
That is why the right mental model is:
- use
initialDatato avoid a blank first load - use normal editing after the first load
Collections use an array
Collections can hold many documents, so their initialData is an array:
export const Pages = defineCollection({
slug: "pages",
labels: { singular: "Page", plural: "Pages" },
initialData: [
{
title: "Home",
slug: "home",
content: "<p>Welcome to the site.</p>",
},
{
title: "About",
slug: "about",
content: "<p>Tell your story here.</p>",
},
],
fields: [
// ...
],
});This is the right place for pages, starter posts, default FAQs, or any other first-run records a new site should already have.
Globals use one object
Globals only hold one document, so their initialData is a single object:
export const Settings = defineGlobal({
slug: "settings",
label: "Site Settings",
initialData: {
siteName: "My Site",
footerText: "Built with Dyrected",
},
fields: [
// ...
],
});This is the simplest way to keep a fresh frontend from rendering empty site chrome on day one.
What to seed first in a Next.js site
The recommended first seed set is small:
- one home page
- one shared settings global
- one navigation global
That is enough to prove all three major paths:
- the admin can edit content
- the frontend can fetch content
- a fresh environment still renders something useful before any manual data entry
What not to do
Avoid using initialData for anything that should behave like a migration or a permanent content sync.
Do not rely on it for:
- patching changed production content
- keeping two environments identical forever
- backfilling records after editors have already started using the system
If the content needs to keep changing after first run, it belongs in normal editorial workflows, not in initialData.
Recommended path
Start with seed data that helps the frontend boot cleanly:
- a page that proves routing works
- navigation that proves shared data works
- settings that prove the site chrome works
If a value is purely cosmetic or editorial and the page still works without it, you can seed it later. Prioritize anything whose absence would make the first render confusing or visibly broken.
Where to go deeper
Use this page for the quick-start mental model. For the full config references, continue to:
Success check
You are ready for the next step when:
- a fresh environment can render at least one real page from Dyrected data
- shared site chrome has safe defaults
- you are no longer depending on manual admin entry just to prove the site works
Once that is true, continue to Displaying Content in Next.js.
Defining a Schema
Turn the starter Dyrected config into a small, Next.js-friendly schema that matches the pages, shared content, and preview routes your site actually needs.
Displaying Content in Next.js
Fetch Dyrected content in Next.js, render common field types correctly, and prove one real route before moving into preview.