# Nextly Documentation > Open-source CMS and visual page builder for Next.js. Nextly is an open-source CMS and visual page builder for Next.js. Model content, build pages, localize, version and release from your own stack. Define your schema in TypeScript or build it visually in the Schema Builder; both produce the same APIs and the same database schema. Supports PostgreSQL, MySQL and SQLite. MIT licensed. This file contains the complete Nextly documentation for use by AI coding assistants. For a lightweight index, see https://nextlyhq.com/llms.txt --- title: Nextly Documentation description: Nextly is an open-source CMS and visual page builder for Next.js. Model content, build pages, localize, version and release from your own stack. url: https://nextlyhq.com/docs --- Nextly is an open-source content platform for Next.js. Developers define the content model in TypeScript, or build it in the admin with the Visual Schema Builder; either way it is the same data model, the same type-safe API and the same admin interface. Your team then composes pages in the Visual Page Builder, translates them, keeps a version history, and schedules what goes live. It all runs inside your own Next.js app, on your own database. ## Why Nextly? - **Next.js Native** -- Runs as part of your Next.js app. No separate server, no external API to manage. - **Code-First + Visual** -- Define collections in TypeScript for version control, or build them visually in the admin panel. Mix both approaches freely. - **Type-Safe** -- Full TypeScript support with auto-generated types for your content schema. - **Direct API** -- Query content directly in Server Components with `nextly.find()` and `nextly.findByID()`. No HTTP overhead. - **Flexible Database** -- PostgreSQL, MySQL, or SQLite via swappable Drizzle adapters. - **Admin Panel** -- A full-featured admin UI at `/admin` with RBAC, media library, and rich text editing out of the box. ## Quick Links - [Getting Started](https://nextlyhq.com/docs/getting-started) -- What Nextly is and core concepts - [Installation](https://nextlyhq.com/docs/getting-started/installation) -- Install Nextly in a new or existing Next.js project - [Quick Start](https://nextlyhq.com/docs/getting-started/quick-start) -- Build a blog in 5 minutes - [Configuration](https://nextlyhq.com/docs/configuration) -- Configure collections, singles, fields, and plugins - [REST API](https://nextlyhq.com/docs/api-reference/rest-api) -- HTTP endpoints, auth, response shapes - [Direct API](https://nextlyhq.com/docs/api-reference/direct-api) -- Server-side query layer for Server Components ## Get Started The fastest way to start is with the scaffolding CLI: **pnpm:** ```bash pnpm create nextly-app@alpha my-app ``` **npm:** ```bash npx create-nextly-app@alpha my-app ``` **yarn:** ```bash yarn create nextly-app@alpha my-app ``` **bun:** ```bash bun create nextly-app@alpha my-app ``` Or follow the [Quick Start guide](https://nextlyhq.com/docs/getting-started/quick-start) to add Nextly to an existing Next.js project and build a blog in 5 minutes. ## Next Steps - [Getting Started](https://nextlyhq.com/docs/getting-started) -- Core concepts and prerequisites - [Installation](https://nextlyhq.com/docs/getting-started/installation) -- Install Nextly in your project - [Configuration](https://nextlyhq.com/docs/configuration) -- Configure collections, singles, fields, and plugins - [Database](https://nextlyhq.com/docs/database) -- Choose and configure PostgreSQL, MySQL, or SQLite - [Deployment](https://nextlyhq.com/docs/guides/deployment) -- Deploy to Vercel or self-host on Node.js --- title: Getting Started description: Learn what Nextly is, understand its core concepts, and get up and running quickly. url: https://nextlyhq.com/docs/getting-started --- Nextly is an open-source content platform that embeds directly into your Next.js application. Instead of running a separate server, Nextly lives alongside your frontend code -- same repo, same deployment, same database. ## Two Ways to Build Nextly supports two approaches to defining your content model. You can use either one, or mix them in the same project. ### Code-First Define collections and singles in TypeScript. Your content schema lives in `nextly.config.ts`, is version-controlled, and generates types automatically. ```typescript title="nextly.config.ts" import { defineConfig, defineCollection, text, richText } from "nextly/config"; const posts = defineCollection({ slug: "posts", labels: { singular: "Post", plural: "Posts" }, fields: [ text({ name: "title", required: true }), richText({ name: "content" }), ], // Built-in Draft/Published lifecycle: injects a `status` system column // (default 'draft') and adds Save Draft / Publish buttons in the admin. status: true, }); export default defineConfig({ collections: [posts], }); ``` ### Visual Schema Builder Create and modify collections visually through the admin panel at `/admin`. The Visual Schema Builder lets you add fields with drag-and-drop, configure validation, and set up relationships -- all without writing config code. Collections created this way generate database tables dynamically and are immediately available through the same API. See [Schema Builder](https://nextlyhq.com/docs/schema-builder) for the full walkthrough. ### Same API, Either Way Regardless of how you create a collection, you query it the same way: ```typescript title="app/blog/page.tsx" import { nextly } from "nextly"; export default async function BlogPage() { const { items: posts } = await nextly.find({ collection: "posts", limit: 10, }); return ( ); } ``` ## Core Concepts ### Collections Collections are repeatable content types -- like blog posts, products, or team members. Each collection gets its own database table and admin UI for managing entries. See [Collections](https://nextlyhq.com/docs/configuration/collections) for the full reference. ### Singles Singles store one-of-a-kind content -- site settings, navigation menus, footer content. They work like collections but hold a single document instead of many. See [Singles](https://nextlyhq.com/docs/configuration/singles). ### Fields Fields define the shape of your content. Nextly ships eighteen field types organised by category: - **Basic:** [`text`](https://nextlyhq.com/docs/configuration/fields#text), [`textarea`](https://nextlyhq.com/docs/configuration/fields#textarea), [`richText`](https://nextlyhq.com/docs/configuration/fields#rich-text), [`email`](https://nextlyhq.com/docs/configuration/fields#email), [`password`](https://nextlyhq.com/docs/configuration/fields#password), [`code`](https://nextlyhq.com/docs/configuration/fields#code), [`number`](https://nextlyhq.com/docs/configuration/fields#number), [`checkbox`](https://nextlyhq.com/docs/configuration/fields#checkbox), [`date`](https://nextlyhq.com/docs/configuration/fields#date) - **Selection:** [`select`](https://nextlyhq.com/docs/configuration/fields#select), [`radio`](https://nextlyhq.com/docs/configuration/fields#radio), [`chips`](https://nextlyhq.com/docs/configuration/fields#chips) - **Media:** [`upload`](https://nextlyhq.com/docs/configuration/fields#upload) - **Relationship:** [`relationship`](https://nextlyhq.com/docs/configuration/fields#relationship) - **Layout:** [`repeater`](https://nextlyhq.com/docs/configuration/fields#repeater), [`group`](https://nextlyhq.com/docs/configuration/fields#group) - **Component:** [`component`](https://nextlyhq.com/docs/configuration/fields#component) - **Advanced:** [`json`](https://nextlyhq.com/docs/configuration/fields#json) - **Virtual:** [`join`](https://nextlyhq.com/docs/configuration/fields#join) See [Fields](https://nextlyhq.com/docs/configuration/fields) for every option per field with examples. ### Field Groups Field groups are reusable field structures that can be embedded in collections, singles, or other field groups. Define a field group once (like an SEO block or a CTA section), then use it across multiple content types. See [Field Groups](https://nextlyhq.com/docs/configuration/field-groups). ### Admin Panel Nextly includes a full admin interface at `/admin` with role-based access control, a media library, and rich text editing. The admin panel works with both code-first and Visual Schema Builder content. See [Admin Panel](https://nextlyhq.com/docs/admin) for the full overview. ## Prerequisites - **Node.js 20** or later - **Next.js 16+** (App Router required) - **React 19+** - **TypeScript 5+** - A supported database: **PostgreSQL** (recommended for production), **MySQL**, or **SQLite** (local demo only — see the [SQLite caveats](https://nextlyhq.com/docs/database/sqlite)) - Basic familiarity with Next.js and TypeScript ## Next Steps - [Installation](https://nextlyhq.com/docs/getting-started/installation) -- Install Nextly in your project - [Quick Start](https://nextlyhq.com/docs/getting-started/quick-start) -- Build a blog in 5 minutes - [Project Structure](https://nextlyhq.com/docs/getting-started/project-structure) -- Understand how a Nextly project is organised - [Configuration](https://nextlyhq.com/docs/configuration) -- Full configuration reference for collections, singles, and fields --- title: Installation description: Install Nextly in a new or existing Next.js project with step-by-step instructions. url: https://nextlyhq.com/docs/getting-started/installation --- There are two ways to install Nextly: scaffold a new project with the CLI, or add Nextly to an existing Next.js app manually. Both paths take a few minutes. ## Option A: Create a New Project (Recommended) The `create-nextly-app` CLI scaffolds a complete Nextly project with your choice of database and template. Storage defaults to local disk, so you don't need to configure cloud storage to get started. **pnpm:** ```bash pnpm create nextly-app@alpha my-app ``` **npm:** ```bash npx create-nextly-app@alpha my-app ``` **yarn:** ```bash yarn create nextly-app@alpha my-app ``` **bun:** ```bash bun create nextly-app@alpha my-app ``` The CLI will prompt you to: 1. **Project name** -- defaults to the directory name. Use `.` to scaffold into the current folder. 2. **Template** -- `Blank` (empty config) or `Blog` (a complete blog with posts, authors, categories, and frontend pages). See [Templates](https://nextlyhq.com/docs/templates) for what each one ships with. 3. **Schema approach** (only for templates that support both) -- `code-first` (default for Blog) or `visual` (Visual Schema Builder). 4. **Database** -- `SQLite` (default), `PostgreSQL`, or `MySQL`. 5. **Database connection string** -- skipped for SQLite (defaults to `file:./data/nextly.db`); required for PostgreSQL/MySQL. Once the CLI completes, change into the project and start the dev server: **pnpm:** ```bash cd my-app pnpm dev ``` **npm:** ```bash cd my-app npm run dev ``` **yarn:** ```bash cd my-app yarn dev ``` **bun:** ```bash cd my-app bun run dev ``` ### Create the super admin The first time you run the dev server, the database is empty -- there's no admin account yet. Open the setup page to create one: ``` http://localhost:3000/admin/setup ``` Enter an email, password, and name. The first user is bootstrapped with a `Super Admin` role that has every permission. After that, you'll be redirected to the login screen at `/admin`. ### Default storage is local disk Out of the box, Nextly uses your project's `./public/uploads/` directory as the media store -- no env vars, no cloud account, no credentials. Files you upload through the admin's media library land there and are served by Next.js as static assets. When you're ready to move to S3, Vercel Blob, or Uploadthing, see [Media & Storage](https://nextlyhq.com/docs/guides/media-storage). ## Option B: Add to an Existing Next.js Project ### 1. Install Packages Install the runtime, admin panel, and database adapter: **pnpm:** ```bash pnpm add nextly @nextlyhq/admin ``` **npm:** ```bash npm install nextly @nextlyhq/admin ``` **yarn:** ```bash yarn add nextly @nextlyhq/admin ``` **bun:** ```bash bun add nextly @nextlyhq/admin ``` Then install your database driver: **PostgreSQL:** ```bash pnpm add @nextlyhq/adapter-postgres pg ``` **MySQL:** ```bash pnpm add @nextlyhq/adapter-mysql mysql2 ``` **SQLite:** ```bash pnpm add @nextlyhq/adapter-sqlite better-sqlite3 ``` Cloud storage is optional -- Nextly's default is local disk under `./public/uploads/`. Install a storage adapter only if you need one: **S3 / R2 / DigitalOcean Spaces:** ```bash pnpm add @nextlyhq/storage-s3 ``` **Vercel Blob:** ```bash pnpm add @nextlyhq/storage-vercel-blob ``` **Uploadthing:** ```bash pnpm add @nextlyhq/storage-uploadthing ``` ### 2. Create `nextly.config.ts` Create a `nextly.config.ts` file in your project root: ```typescript title="nextly.config.ts" import { defineConfig } from "nextly/config"; export default defineConfig({ collections: [], singles: [], typescript: { outputFile: "./src/types/generated/nextly-types.ts", }, }); ``` ### 3. Update `next.config.ts` Add `serverExternalPackages` so Next.js doesn't try to bundle server-only dependencies: ```typescript title="next.config.ts" import type { NextConfig } from "next"; const nextConfig: NextConfig = { serverExternalPackages: [ "nextly", "@nextlyhq/adapter-drizzle", "@nextlyhq/adapter-postgres", "@nextlyhq/adapter-mysql", "@nextlyhq/adapter-sqlite", "drizzle-orm", "drizzle-kit", "pg", "mysql2", "better-sqlite3", "bcryptjs", "sharp", "esbuild", ], }; export default nextConfig; ``` Drop adapters and drivers your project doesn't actually use. ### 4. Set Up Admin Routes Create the admin panel page and layout: ```tsx title="src/app/admin/[[...params]]/page.tsx" "use client"; import "@nextlyhq/admin/style.css"; import { RootLayout, QueryProvider, ErrorBoundary } from "@nextlyhq/admin"; export default function AdminPage() { return ( { console.error("Admin error:", error, errorInfo); }} > ); } ``` ```tsx title="src/app/admin/[[...params]]/layout.tsx" import { getBrandingCss } from "nextly/config"; import config from "../../../../nextly.config"; const brandingCss = getBrandingCss(config.admin?.branding); export default function AdminLayout({ children, }: { children: React.ReactNode; }) { return ( <> {brandingCss && (