This guide walks you through adding Alinea to a Next.js project from scratch. By the end you will have a working content schema, a running local dashboard, and a server component that queries typed content. All steps assume you have an existing Next.js 14+ project with the App Router.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/alineacms/alinea/llms.txt
Use this file to discover all available pages before exploring further.
cms.ts is the single source of truth for your entire content schema. It
must be committed to your repository — Alinea derives all TypeScript types,
dashboard forms, and database structure from it at build time.Install Alinea
Add the Alinea requires
alinea package to your project. Alinea is ESM-only, so make sure
your package.json contains "type": "module".react and react-dom as peer dependencies. Both are
already present in any Next.js project, so no additional installation is
needed.Initialize the config file
Run the This creates
init command to scaffold a starter cms.ts in your project root:cms.ts with a minimal workspace and root configuration. Open
the file and customize it in the next step.Configure Next.js with withAlinea
Wrap your Next.js config with
withAlinea so the framework can set up
routing for the dashboard, configure image domains, and mark Alinea’s
generated packages as server-external.next.config.ts
withAlinea reads the generated @alinea/generated/settings.json to
determine the dashboard path and automatically adds the necessary redirects
and rewrites.Create your cms.ts schema
Replace the scaffolded
cms.ts (or write it from scratch) with a schema
that matches your content model. Below is a complete example with a
BlogPost document type containing a title and a body:cms.ts
createCMS (from alinea/next) returns a NextCMS instance that wires
together the content database, preview support, and Next.js draft mode.Create the API route handler
Alinea needs a single API route to handle dashboard requests, authentication,
mutations, and preview tokens. Create the following file:The route must match the
app/api/cms/route.ts
handlerUrl you set in cms.ts
(/api/cms in the example above). createHandler returns a standard
Request → Response function compatible with the Next.js App Router route
handler convention.Start the dashboard
Start the Alinea development dashboard alongside your Next.js dev server:You can also pass Before deploying, run
--port to change the dashboard port, or --dir to
point at a project in a subdirectory:alinea build to generate types and the content
cache used at build time:Query content in a server component
Import your Content is bundled with your application during the build, so both calls
resolve from an in-memory database with zero network overhead during static
generation.
cms instance and call cms.find(), cms.first(), or
cms.get() directly inside any async Server Component or
generateStaticParams function. Results are fully typed based on your
schema. Remember to export any types you define in cms.ts so they can
be imported in your components.app/blog/page.tsx
app/blog/[slug]/page.tsx
What’s next?
With the basics in place you can explore the full field library (Field.select, Field.image, Field.date, Field.list, and more), add i18n locales to a root, configure roles and permissions, or set up a cloud backend for team collaboration. See the Configuration reference for all available options.