# Configuration

Configure your Nextly application with collections, singles, field groups, fields, storage, security, and more.

Nextly is configured through a single `nextly.config.ts` file at the root of your project. That file is the source of truth for your content model, database output paths, storage backends, security settings, email, and admin panel branding.

## The config file

Every Nextly project has a `nextly.config.ts` that exports a config built with `defineConfig()`:

```typescript title="nextly.config.ts"
import { defineConfig } from "nextly";
import Posts from "./src/collections/posts";
import Media from "./src/collections/media";
import SiteSettings from "./src/singles/site-settings";

export default defineConfig({
  collections: [Posts, Media],
  singles: [SiteSettings],
  db: {
    schemasDir: "./src/db/schemas/collections",
    migrationsDir: "./src/db/migrations",
  },
  typescript: {
    outputFile: "./src/types/generated/nextly-types.ts",
  },
});
```

## What you can configure

| Area                                                                            | Description                                                       |
| ------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| [Nextly config](https://nextlyhq.com/docs/configuration/nextly-config.md)       | Every option in `defineConfig()` with types and defaults          |
| [Collections](https://nextlyhq.com/docs/configuration/collections.md)           | Content types with multiple entries (blog posts, products, media) |
| [Singles](https://nextlyhq.com/docs/configuration/singles.md)                   | One-off documents (site settings, header, footer)                 |
| [Field Groups](https://nextlyhq.com/docs/configuration/field-groups.md)         | Reusable field groups embedded in collections and singles         |
| [Fields](https://nextlyhq.com/docs/configuration/fields.md)                     | Field types, options, validation, and helpers                     |
| [Environment variables](https://nextlyhq.com/docs/configuration/environment.md) | Every environment variable Nextly reads                           |

## Visual Schema Builder vs code-first

Collections, singles, and field groups can also be created visually in the Visual Schema Builder (the "Schema Builder" link inside the admin panel). The Schema Builder writes the same `CollectionConfig`, `SingleConfig`, and `FieldGroupConfig` shapes documented in this section, so anything you build visually maps 1:1 to a `defineCollection`, `defineSingle`, or `defineFieldGroup` call.

## Next steps

* [Nextly config reference](https://nextlyhq.com/docs/configuration/nextly-config.md) — every top-level option in `defineConfig()`
* [Collections](https://nextlyhq.com/docs/configuration/collections.md) — content types with multiple entries
* [Singles](https://nextlyhq.com/docs/configuration/singles.md) — single-document content like site settings
* [Field Groups](https://nextlyhq.com/docs/configuration/field-groups.md) — reusable field groups for collections and singles
* [Fields](https://nextlyhq.com/docs/configuration/fields.md) — every available field type
* [Environment variables](https://nextlyhq.com/docs/configuration/environment.md) — what to set in `.env`
