You're reading docs for Nextly Alpha. APIs may change between releases.

Configuration

Nextly Config Reference

Complete reference for every option accepted by defineConfig() in nextly.config.ts.

The nextly.config.ts file is the central configuration for your Nextly application. The defineConfig() function validates your config, applies defaults, and returns a sanitized SanitizedNextlyConfig consumed by the rest of the runtime.

Source of truth: the NextlyConfig interface in packages/nextly/src/shared/types/config.ts defines the shape this page documents. The defineConfig() helper in packages/nextly/src/collections/config/define-config.ts wires it up.

Full example

nextly.config.ts
import { defineConfig } from "nextly";
import { s3Storage } from "@nextlyhq/storage-s3";
import Posts from "./src/collections/posts";
import Media from "./src/collections/media";
import SiteSettings from "./src/singles/site-settings";
import Header from "./src/singles/header";
import Footer from "./src/singles/footer";
import { Seo, Hero } from "./src/field-groups";

export default defineConfig({
  // Content model
  collections: [Posts, Media],
  singles: [SiteSettings, Header, Footer],
  fieldGroups: [Seo, Hero],

  // Built-in user model extensions
  users: {
    fields: [
      // imported from "nextly"
      // text({ name: "company", label: "Company" }),
    ],
  },

  // Output paths
  typescript: {
    outputFile: "./src/types/generated/nextly-types.ts",
    declare: true,
  },
  db: {
    schemasDir: "./src/db/schemas/collections",
    migrationsDir: "./src/db/migrations",
  },

  // Cloud storage (optional — defaults to local disk under ./.nextly/uploads/)
  storage: [
    s3Storage({
      bucket: process.env.S3_BUCKET!,
      region: process.env.AWS_REGION!,
      accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
      secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
      collections: {
        media: true,
      },
    }),
  ],

  // Security
  security: {
    cors: {
      origin: ["https://example.com"],
      credentials: true,
    },
    sanitization: { enabled: true },
  },

  // Rate limiting (enabled by default — opt out with enabled: false)
  rateLimit: {
    enabled: true,
    readLimit: 100,
    writeLimit: 30,
    windowMs: 60_000,
  },

  // Per-API-key rate limit
  apiKeys: {
    rateLimit: { requestsPerHour: 1000, windowMs: 3_600_000 },
  },

  // Auth opt-in flags
  auth: {
    revealRegistrationConflict: false,
  },

  // Email
  email: {
    providerConfig: {
      provider: "resend",
      apiKey: process.env.RESEND_API_KEY!,
    },
    from: "My App <noreply@example.com>",
    baseUrl: "https://example.com",
  },

  // Admin panel branding & plugin overrides
  admin: {
    branding: {
      logoUrl: "/logo.svg",
      logoText: "My App",
      favicon: "/favicon.ico",
      colors: {
        primary: "#6366f1",
        accent: "#f59e0b",
      },
    },
  },
});

Top-level options

OptionTypeDefaultDescription
collectionsCollectionConfig[][]Content types with multiple entries. See Collections.
singlesSingleConfig[][]Single-document content (site settings, header, etc.). See Singles.
fieldGroupsFieldGroupConfig[][]Reusable field groups. See Field Groups.
usersUserConfigundefinedExtend the built-in user model with custom fields.
typescriptTypeScriptConfigSee belowGenerated types path and module augmentation.
dbDatabaseConfigSee belowWhere Drizzle schema and migration files are written.
rateLimitRateLimitingConfigEnabled (100 read / 30 write per minute)Global API rate limiting.
apiKeysApiKeysConfig1000 req/hour, 1-hour windowPer-API-key rate limit (applies when Authorization: Bearer nx_live_... is used).
authAuthConfig{ revealRegistrationConflict: false, allowRegistration: false }Auth-related opt-in flags.
storageStoragePlugin[][] (local disk used)Cloud storage plugins. Default storage is local disk under ./.nextly/uploads/.
pluginsPluginDefinition[][]Plugins extending Nextly with collections, hooks, sidebar items, etc.
emailEmailConfigundefinedEmail provider for password resets and notifications.
securitySecurityConfigSecure defaultsCORS, security headers, upload restrictions, sanitization, auth-rate-limit, body-size limits.
adminAdminConfigundefinedAdmin panel branding and plugin sidebar overrides.
ai"off"undefined@experimental "off" turns AI off for the site: nothing runs it, nothing in the admin turns it back on, and AI's settings are kept. NEXTLY_AI=off in the environment turns it off whatever this says.

The next sections walk through each option.


collections

collections?: CollectionConfig[];

Array of collection configurations created with defineCollection(). Each collection becomes a database table, an admin panel section, and a set of REST endpoints under /admin/api/collections/[slug]/entries.

import Posts from "./src/collections/posts";
import Media from "./src/collections/media";

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

See Collections for the full CollectionConfig shape.


singles

singles?: SingleConfig[];

Array of single-document configurations created with defineSingle(). A single is an auto-created, non-deletable document (site settings, header, footer, homepage). Slugs must be unique across collections, singles, and field groups.

import SiteSettings from "./src/singles/site-settings";

export default defineConfig({
  singles: [SiteSettings],
});

See Singles for the full SingleConfig shape.


fieldGroups

fieldGroups?: FieldGroupConfig[];

Array of reusable field structures created with defineFieldGroup(). Field groups are embedded inside collections, singles, or other field groups via the component field type. Slugs must be unique across collections, singles, and field groups.

import { Seo, Hero } from "./src/field-groups";

export default defineConfig({
  fieldGroups: [Seo, Hero],
});

See Field Groups.


users

users?: UserConfig;

Extend the built-in user model with custom fields. Custom fields are stored in a separate user_ext table with proper typed columns. Only scalar field types are accepted: text, textarea, number, email, select, radio, checkbox, date.

import { text, select, option } from "nextly";

export default defineConfig({
  users: {
    fields: [
      text({ name: "company", label: "Company" }),
      select({
        name: "department",
        options: [option("Engineering"), option("Sales"), option("Marketing")],
      }),
    ],
    admin: {
      // Show these custom columns in the user list
      listFields: ["company", "department"],
      // Override the form-section group label (default: "Additional Information")
      group: "Profile",
    },
  },
});

typescript

typescript?: { outputFile?: string; declare?: boolean; zod?: boolean };

Controls TypeScript type generation, for nextly generate:types and nextly build alike.

PropertyTypeDefaultDescription
outputFilestring"./src/types/generated/nextly-types.ts"Path the generator writes types to.
declarebooleantrueWhether to add the declare module "nextly" block, which narrows Direct API slugs and return types to your schema.
zodbooleanfalseWhether to also write a Zod schema for each collection, in zod/ under db.schemasDir.

Both commands follow declare and zod on every run. For one run, --declare / --no-declare and --zod / --no-zod win over them.

The generated types cover every collection, Single and field group the site serves: those in your config, those plugins add, and those made in the Visual Schema Builder, read from db.uiSchemaFile. A code-first entity wins over a Schema Builder one of the same kind and slug.

Earlier versions wrote the default file as payload-types.ts. If your config doesn't set outputFile and that file is still there, the generator writes nextly-types.ts and leaves payload-types.ts as it is, telling you what to do with it:

  • A one-line re-export of nextly-types, which 0.0.2-alpha.67 and alpha.68 wrote: it still compiles. Change imports of payload-types to nextly-types, then delete it.
  • Types an earlier version generated: it's no longer updated. Unless it was generated with --no-declare, it declares module "nextly" as nextly-types.ts does, so the two clash and TypeScript may use the old types. Delete it and change imports of payload-types to nextly-types.

A payload-types.ts that Nextly didn't generate is never changed. To keep the old name, set outputFile to it.


db

db?: { schemasDir?: string; migrationsDir?: string };

Where Drizzle schema files and migration files are written.

PropertyTypeDefaultDescription
schemasDirstring"./src/db/schemas/collections"Per-collection Drizzle schema files.
migrationsDirstring"./src/db/migrations"Generated migration files.

See Environment variables for the runtime database connection settings.


rateLimit

rateLimit?: RateLimitingConfig;

Global API rate limiting. Enabled by default with 100 read / 30 write requests per minute. Opt out with rateLimit: { enabled: false }.

PropertyTypeDefaultDescription
enabledbooleantrueToggle rate limiting.
readLimitnumber100Max GET requests per window.
writeLimitnumber30Max POST/PATCH/PUT/DELETE per window.
windowMsnumber60_000Window in milliseconds.
store"memory" | "database" | LimitStore | RateLimitStore"memory"Where every limit counts, core's own included. "database" shares the counts between instances. See Limit store.
singleInstancebooleanfalseSays the site runs one instance, which silences the production warning about limits counted in memory.
keyGenerator(request: Request) => stringClient IPCustom rate-limit key.
skip(request: Request) => boolean | Promise<boolean>NoneSkip rate limiting for matching requests.
sessions{ readLimit?: number; writeLimit?: number }5 × readLimit / writeLimitA signed-in session's own budget, per user.
unresolvedCeiling{ readLimit?: number; writeLimit?: number }10 × readLimit / writeLimitThe ceiling shared by requests with no session or key from no resolvable address.
collectionsRecord<string, { readLimit?: number; writeLimit?: number }>NonePer-collection overrides.
rateLimit: {
  enabled: true,
  readLimit: 100,
  writeLimit: 30,
  collections: {
    media: { readLimit: 50, writeLimit: 10 },
    logs: { readLimit: 200 },
  },
}

Every REST request is limited, the admin's included, and each is counted by who is asking:

  • A signed-in session spends its own budget, per user and whatever address it comes from: by default five times readLimit and writeLimit, so the admin's parallel page loads never meet it. A session that does not verify, an expired or revoked one included, counts as carrying none.
  • An API key that resolves spends its own apiKeys.rateLimit budget, once per request. Invalid keys spend their address's budget. With no address, a key's failed lookups are bounded by the id it carries, which the server verifies without a lookup, with an address's budget; an invalid key cannot carry a valid id, so a flood of them never refuses a key that does. A key made before keys carried ids shares a ceiling with every key that has none, so a flood can still refuse it until it is replaced with a new key.
  • A plugin's signed-in person, on a route that asks for one, spends a budget of the session's size, whatever staff session or key the request also carries. A person who does not resolve costs the plugin's resolver a lookup, so failed resolutions are bounded as invalid keys are, per plugin: by a budget for that address the size of its own and apart from it, or with no address by a ceiling of their own the size of unresolvedCeiling. A flood of them can refuse a valid person of that plugin sent under the same bound, and nothing else.
  • Anything else spends its client address's readLimit or writeLimit. Without security.trustProxy no address resolves, and such requests share unresolvedCeiling instead. It never refuses a session, a key or a sign-in, which the auth limits judge.

The deprecated defaultSkipAdminApi, once the default skip, is still exported for an app that passes it to exempt /admin/api/*; a later release removes it.


apiKeys

apiKeys?: { rateLimit?: { requestsPerHour?: number; windowMs?: number } };

Per-key rate limit applied when a request authenticates with an API key (Authorization: Bearer nx_live_...). The global rateLimit counts a request whose key resolves against this budget, once, rather than against its address. Session-cookie requests spend the global limit's session budget instead. Omitting this block falls back to built-in defaults. A key whose budget is spent is still looked up on each request before it is refused with 429, so a client holding one costs a key lookup per request until its window resets.

PropertyTypeDefaultDescription
rateLimit.requestsPerHournumber1000Maximum requests per sliding window. Must be a positive integer.
rateLimit.windowMsnumber3_600_000Sliding window duration in milliseconds.

defineConfig() throws at startup if either value is non-positive.


auth

auth?: { revealRegistrationConflict?: boolean; allowRegistration?: boolean };

Auth-related opt-in flags.

PropertyTypeDefaultDescription
allowRegistrationbooleanfalseWhether anyone may create an account through /auth/register. While false, registration answers 403 "Registration is not open." and creates no account. A registered account gets no role and never becomes the first administrator. Needs the release after 0.0.2-alpha.68.
revealRegistrationConflictbooleanfalseWhen false (default), /auth/register returns the same "we've sent a confirmation link" response whether or not the email exists, to prevent account enumeration. Set to true only if your threat model genuinely doesn't care about email enumeration (e.g. closed admin tool with controlled signup). Has effect only when allowRegistration is true.

Authentication is custom: email + password, JWT access/refresh tokens, sessions, API keys, RBAC. There is no OAuth.


storage

storage?: StoragePlugin[];

Cloud storage plugins. The default is local disk — Nextly writes uploads to ./.nextly/uploads/ if storage is empty or omitted.

Available adapters:

  • @nextlyhq/storage-s3 — AWS S3, Cloudflare R2, MinIO, DigitalOcean Spaces
  • @nextlyhq/storage-vercel-blob — Vercel Blob Storage
  • @nextlyhq/storage-uploadthing — UploadThing

Install whichever adapter you need:

pnpm add @nextlyhq/storage-s3
npm install @nextlyhq/storage-s3
yarn add @nextlyhq/storage-s3
bun add @nextlyhq/storage-s3
import { s3Storage } from "@nextlyhq/storage-s3";

export default defineConfig({
  storage: [
    s3Storage({
      bucket: process.env.S3_BUCKET!,
      region: process.env.AWS_REGION!,
      accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
      secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
      collections: {
        media: true,
        "private-docs": {
          prefix: "private/",
          signedDownloads: true,
          clientUploads: true,
        },
      },
    }),
  ],
});

See Environment variables — Storage for adapter-specific env vars.


plugins

plugins?: PluginDefinition[];

Plugins extend Nextly with extra collections, hooks, sidebar items, and admin views.

import { formBuilder } from "@nextlyhq/plugin-form-builder";

const formBuilderPlugin = formBuilder();

export default defineConfig({
  plugins: [formBuilderPlugin.plugin],
  collections: [Posts],
});

email

email?: EmailConfig;

Email provider for password resets, email verification, and other transactional emails. The provider configured here is the code-first fallback; database-managed providers configured via the admin Settings UI take precedence at runtime.

PropertyTypeRequiredDescription
providerConfigSmtpConfig | ResendConfig | SendLayerConfigYesProvider details.
fromstringYesDefault From address (e.g., "App <noreply@example.com>").
baseUrlstringNoUsed for password reset and verify links; falls back to NEXT_PUBLIC_APP_URL.
resetPasswordPathstringNo (default "/admin/reset-password")Reset-password page path appended to baseUrl.
verifyEmailPathstringNo (default "/admin/verify-email")Email verification page path appended to baseUrl.
templates{ welcome?, passwordReset?, emailVerification? }NoOverride the default HTML templates.
email: {
  providerConfig: {
    provider: "resend",
    apiKey: process.env.RESEND_API_KEY!,
  },
  from: "My App <noreply@example.com>",
  baseUrl: "https://example.com",
}

security

security?: SecurityConfig;

Security configuration. All sub-sections are optional — secure defaults are applied by middleware.

PropertyTypeDescription
headersSecurityHeadersConfigCSP, X-Content-Type-Options, X-Frame-Options, HSTS, Referrer-Policy, Permissions-Policy.
corsCorsConfigCross-Origin Resource Sharing. Default: same-origin only.
uploadsUploadSecurityConfigInputMIME-type allowlist and SVG serving behavior.
sanitizationSanitizationConfigInputHTML stripping for plain-text fields, CSS validation in rich text, URL protocol validation.
limits{ json?, multipart?, fileSize?, fileCount?, fieldCount?, fieldSize? }Body and multipart size caps. Defaults: json 1mb / multipart 50mb / fileSize 10mb / fileCount 10 / fieldCount 50 / fieldSize 100kb. Numeric values accept "1mb"-style suffixes.
authRateLimit{ requestsPerHour?: number; windowMs?: number }Rate limit on the auth routes (sign-in, registration, password reset, email verification, invites, second-factor answers). Default: 30 req/hour. A request whose client address can be read counts per address; one whose address cannot counts against the account it names, under a shared ceiling of 100× the budget. See Auth rate limit. Set requestsPerHour: 0 to disable (test/dev only).
trustProxybooleanTrust X-Forwarded-For (filtered through the TRUSTED_PROXY_IPS env-var CIDR list) for client-IP resolution. Default: false. While unset, no client address is read, so the auth rate limit counts per named account rather than per client; on Vercel this is logged at startup. Set true on Vercel or behind a proxy every request passes through: see Client addresses and the auth rate limit.
breachedPasswords{ source: "pwned-passwords" | { url: string } | { range(prefix) }; timeoutMs?: number }@experimental Where a plugin's password check asks whether a password appeared in a breach, when the plugin asks for that check. Only a 20-bit prefix of the password's SHA-1 leaves the process. A url must be https: any other address is sent nothing, the check answers "unchecked", and boot warns. Default source: "pwned-passwords"; timeoutMs is 1 to 60000 ms, default 2000 (another value is named at boot and replaced by the default). See Security helpers.
security: {
  cors: {
    origin: ["https://example.com", "https://app.example.com"],
    credentials: true,
  },
  headers: {
    contentSecurityPolicy: "default-src 'self'",
  },
  uploads: {
    additionalMimeTypes: ["application/xml"],
  },
  sanitization: {
    enabled: true,
    stripHtmlFromText: true,
  },
  limits: {
    multipart: "20mb",
    fileSize: "5mb",
  },
  authRateLimit: {
    requestsPerHour: 30,
  },
  trustProxy: true,
}

admin

admin?: AdminConfig;

Admin panel branding and per-plugin sidebar overrides.

admin.branding

PropertyTypeDefaultDescription
logoUrlstringNoneLogo image URL (replaces text logo when set).
logoUrlLightstringNoneLight-mode logo URL (used when logoUrl is not set).
logoUrlDarkstringNoneDark-mode logo URL (used when logoUrl is not set).
logoTextstring"Nextly"Sidebar text label and alt text when logoUrl is set.
faviconstringNoneCustom favicon URL.
colors.primarystring (6-digit hex)NonePrimary brand color (e.g. "#6366f1"). Foreground colors auto-calculated for WCAG AA contrast.
colors.accentstring (6-digit hex)NoneAccent brand color (e.g. "#f59e0b").
showBuilderbooleanon outside productionfalse turns the Visual Schema Builder off in development and test: its navigation is hidden and its schema writes are refused. The builder is always off in production, whatever this says; a production start that finds true logs that it has no effect there.

admin.pluginOverrides

Override any plugin's sidebar placement and appearance without modifying the plugin's source.

import { defineConfig, AdminPlacement } from "nextly";

export default defineConfig({
  admin: {
    pluginOverrides: {
      "form-builder": {
        placement: AdminPlacement.SETTINGS, // "collections" | "singles" | "users" | "settings" | "plugins" | "standalone"
        order: 80,
        after: "settings",
        appearance: { icon: "FileText" },
      },
    },
  },
});
PropertyTypeDescription
placementAdminPlacementSidebar section the plugin appears in. Values: "collections", "singles", "users", "settings", "plugins", "standalone".
ordernumberSort order within the section.
after"dashboard" | "collections" | "singles" | "media" | "plugins" | "users" | "settings"Position anchor for STANDALONE plugins (which built-in section to appear after).
appearancePartial<PluginAdminAppearance>Shallow-merged onto the plugin's own appearance (icon, label, etc.).

Validation

defineConfig() performs these checks at startup:

  • Duplicate slugs. Collection, single, and field group slugs must be unique across all three.
  • Cross-type conflicts. A single cannot share a slug with a collection or field group.
  • Field group nesting. A field group placed inside itself, directly or through other field groups, is rejected; nesting has no depth limit.
  • User config. Only the allowed scalar field types are accepted.
  • API-key bounds. apiKeys.rateLimit.requestsPerHour and apiKeys.rateLimit.windowMs must be positive.

Validation failures throw a descriptive error at startup so misconfigurations surface immediately.

Next steps