# Nextly for developers: Collections you define in code are files in your repository.

Nextly is an open-source content platform for Next.js.

MIT licensed, self-hosted. Runs inside your own Next.js app, on your own PostgreSQL or MySQL database, or SQLite for local work.

Model content in TypeScript or in the Visual Schema Builder. Both feed the same Nextly runtime, admin and APIs.

[Start building](https://nextlyhq.com/docs/getting-started/quick-start.md) · [Read the docs](https://nextlyhq.com/docs/getting-started.md)

```bash
npx create-nextly-app@alpha my-app
```

## What it does

### Define content in code

Typed, code-defined schemas and APIs: `nextly generate:types` writes types for the collections, singles and field groups in your config.

Limit: A collection made in the Visual Schema Builder is stored in your database, with no TypeScript file written for it, and gets no generated types.

`nextly.config.ts`

```ts
import { defineCollection, defineConfig, richText, text } from "nextly/config";

const Posts = defineCollection({
  slug: "posts",
  admin: { useAsTitle: "title" },
  fields: [
    text({ name: "title", required: true }),
    text({ name: "slug", required: true, unique: true }),
    richText({ name: "content" }),
  ],
  status: true,
});

export default defineConfig({ collections: [Posts] });
```

Compiled against nextly 0.0.2-alpha.82

[Collections](https://nextlyhq.com/docs/configuration/collections.md)

### Read it in your page code

Read content straight from your database in your page code (the Direct API), or over REST.

The Direct API runs as trusted server code and skips access rules unless you pass `overrideAccess: false`.

`app/blog/page.tsx`

```tsx
import { getNextly } from "nextly";
import config from "@/nextly.config";

export default async function BlogPage() {
  const nextly = await getNextly({ config });
  const { items: posts } = await nextly.find({
    collection: "posts",
    where: { status: { equals: "published" } },
    sort: "-createdAt",
    limit: 10,
  });
  return <ul>{posts.map((p) => <li key={p.id}>{p.title}</li>)}</ul>;
}
```

Compiled against nextly 0.0.2-alpha.82

`With access rules`

```ts
const visiblePosts = await nextly.find({
  collection: "posts",
  overrideAccess: false,
  user: { id: "user-123", role: "editor" },
});
```

[From docs/api-reference/direct-api.mdx · v0.0.2-alpha.82](https://github.com/nextlyhq/nextly/blob/v0.0.2-alpha.82/docs/api-reference/direct-api.mdx)

[The Direct API](https://nextlyhq.com/docs/api-reference/direct-api.md)

### Read it over REST

Access rules you write in code apply over REST and in the admin, including read rules on a collection’s or single’s own fields.

Sign-in for your team: email and password, sessions and API keys, stored in your own database.

`REST`

```http
GET /admin/api/collections/posts/entries?limit=10&sort=-createdAt
Authorization: Bearer <api key>

{
  "items": [{ "id": "…", "title": "Release notes: November" }],
  "meta": { "total": 1, "page": 1, "limit": 10, "totalPages": 1 }
}
```

Written for nextly 0.0.2-alpha.82

[The REST API](https://nextlyhq.com/docs/api-reference/rest-api.md)

### Write access rules

Role-based permissions for each collection and action, plus field-level read and write rules in code, on a collection’s or single’s fields, fields inside field groups included.

`collections/posts.ts`

```ts
import { defineCollection, relationship, text } from "nextly/config";

export const Posts = defineCollection({
  slug: "posts",
  fields: [
    text({ name: "title" }),
    relationship({ name: "author", relationTo: "users" }),
  ],
  access: {
    read: true,
    // Narrowed: the role's update-posts, and not while a content freeze is on.
    update: () => process.env.CONTENT_FREEZE !== "on",
  },
});
```

[From docs/permissions/index.mdx · v0.0.2-alpha.82](https://github.com/nextlyhq/nextly/blob/v0.0.2-alpha.82/docs/permissions/index.mdx)

[Roles and permissions](https://nextlyhq.com/docs/permissions.md)

### Run code when content changes

Hooks in code run before and after a change, a read or a delete.

`collections/posts.ts`

```ts
hooks: {
  beforeChange: [
    async ({ data, operation, collection, user, context, req }) => {
      if (operation === "create" && !data.slug) {
        return { ...data, slug: slugify(data.title) };
      }
      return data;
    },
  ],
  afterChange: [
    async ({ data, req }) => {
      // Use req.nextly for the Direct API inside hooks
      await req?.nextly?.create({
        collection: "activity-logs",
        data: { action: "post_updated", postId: data.id },
      });
    },
  ],
}
```

[From docs/configuration/collections.mdx · v0.0.2-alpha.82](https://github.com/nextlyhq/nextly/blob/v0.0.2-alpha.82/docs/configuration/collections.mdx)

[Hooks](https://nextlyhq.com/docs/configuration/collections.md#hooks)

### Webhooks and background jobs

Signed webhooks for content, media, user and form events, with retries, a delivery log, redelivery and secret rotation.

Background jobs, run by calling one endpoint from your scheduler.

`jobs/send-digest.ts`

```ts
import { defineJob } from "nextly";

export const sendDigest = defineJob({
  slug: "send-digest",
  handler: async (input, context) => {
    // `input` is the payload the job was enqueued with. `context` is what the
    // runner tells the handler about the run it is in.
  },
});
```

[From docs/jobs/index.mdx · v0.0.2-alpha.82](https://github.com/nextlyhq/nextly/blob/v0.0.2-alpha.82/docs/jobs/index.mdx)

`nextly.config.ts`

```ts
import { defineConfig } from "nextly";

import { sendDigest } from "./jobs/send-digest";

export default defineConfig({
  jobs: [sendDigest],
});
```

[From docs/jobs/index.mdx · v0.0.2-alpha.82](https://github.com/nextlyhq/nextly/blob/v0.0.2-alpha.82/docs/jobs/index.mdx)

`Your scheduler`

```http
POST /admin/api/jobs/run
Authorization: Bearer $NEXTLY_DRAIN_SECRET
```

[From docs/jobs/index.mdx · v0.0.2-alpha.82](https://github.com/nextlyhq/nextly/blob/v0.0.2-alpha.82/docs/jobs/index.mdx)

`Webhook signature`

```text
key           = base64_decode(secret without its "whsec_" prefix)
signedContent = "<id>.<timestamp>.<rawBody>"
signature     = base64(HMAC_SHA256(key, signedContent))
```

[From docs/webhooks/index.mdx · v0.0.2-alpha.82](https://github.com/nextlyhq/nextly/blob/v0.0.2-alpha.82/docs/webhooks/index.mdx)

[Webhooks](https://nextlyhq.com/docs/webhooks.md) · [Background jobs](https://nextlyhq.com/docs/jobs.md)

### Extend it with plugins

An alpha plugin SDK for schema, services, routes, admin UI and permissions. Parts are marked experimental; pin exact versions.

Dashboard widgets in the admin; plugins can add their own, an experimental part of the plugin SDK. The SEO plugin adds an SEO issues widget.

`plugins/example.ts`

```ts
import { definePlugin } from "@nextlyhq/plugin-sdk";

export const myPlugin = definePlugin({
  name: "@acme/nextly-plugin-example",
  version: "1.0.0",
  nextly: ">=0.0.2-alpha.67",
  contributes: {
    collections: [MyCollection], // merged automatically by the pipeline
  },
  setup(config) {
    return { ...config }; // escape hatch for advanced config transforms
  },
});
```

[From docs/plugins/index.mdx · v0.0.2-alpha.82](https://github.com/nextlyhq/nextly/blob/v0.0.2-alpha.82/docs/plugins/index.mdx)

[Plugins](https://nextlyhq.com/docs/plugins.md) · [API stability](https://nextlyhq.com/docs/plugins/stability.md)

## What ships today: in 0.0.2-alpha.82

- **Package:** `nextly`
- **Release:** `0.0.2-alpha.82` · 28 Nov 2026
- **Licence:** MIT
- **Runs in:** Your own Next.js app, self-hosted
- **Databases:** PostgreSQL 15+, MySQL 8+, SQLite 3.38+ for local work
- **Requires:** Node.js 22.12+ or 24+; Next.js 16 with the App Router; React 19
- **APIs:** The Direct API and REST
- **Plugin SDK:** [`@nextlyhq/plugin-sdk`, alpha](https://nextlyhq.com/stability)

## Where it stops

- **Visual Schema Builder collections:** A collection made in the Visual Schema Builder is stored in your database, with no TypeScript file written for it, and gets no generated types. [Docs](https://nextlyhq.com/docs/schema-builder.md)
- **Access rules and the Direct API:** The Direct API runs as trusted server code and skips access rules unless you pass `overrideAccess: false`. Called that way with no `user`, it is judged as a signed-out visitor: it can read where no rule names the read, and a create, update or delete needs a rule that allows it. [Docs](https://nextlyhq.com/docs/permissions.md)
- **Sign-in:** Sign-in for your team: email and password, sessions and API keys, stored in your own database. [Docs](https://nextlyhq.com/docs/guides/authentication.md)
- **The plugin SDK:** Alpha plugin SDK. The `@public` surface becomes semver-protected at 1.0; until then, pin exact versions. [Docs](https://nextlyhq.com/docs/plugins/stability.md)
- **Database versions:** PostgreSQL 15 or later, MySQL 8 or later, SQLite 3.38 or later for local work. [Docs](https://nextlyhq.com/docs/database.md)

Nextly is in alpha. APIs may change before 1.0. Pin exact versions in production.

## Questions

### Does Nextly run inside my Next.js app?

MIT licensed, self-hosted. Runs inside your own Next.js app, on your own PostgreSQL or MySQL database, or SQLite for local work.

### Are my collections files in my repository?

Collections you define in code are files in your repository. A collection made in the Visual Schema Builder is stored in your database, with no TypeScript file written for it, and gets no generated types.

### Does Nextly write TypeScript types?

Typed, code-defined schemas and APIs: `nextly generate:types` writes types for the collections, singles and field groups in your config.

### Does Nextly have a GraphQL API?

No. Nextly offers REST and the Direct API.

### Can my app’s customers sign in with Nextly?

No. Sign-in is for your team. It is not sign-in for site visitors or customers.

### Is Nextly free?

Nextly is MIT licensed and self-hosted. MIT today, and no decision yet about paid offerings.

### Can a coding agent set it up?

Every new Nextly project ships with an AGENTS.md and CLAUDE.md written for coding agents.

## More of Nextly

- [CMS for Next.js](https://nextlyhq.com/nextjs-cms): Runs inside your own Next.js app, on your own PostgreSQL or MySQL database.
- [Plugins](https://nextlyhq.com/plugins): The established official plugins: Visual Page Builder, SEO and Form Builder.
- [For your team](https://nextlyhq.com/for-teams): After a developer sets up and deploys Nextly, editors manage content and pages in the admin.
