---
title: "Upgrade to the Layer Architecture"
description: "Move a project built on the Turborepo version of the kit to the new layer architecture."
canonical_url: "https://nuxtstarterkit.com/docs/getting-started/upgrade-to-layer-architecture"
---

> Index of every page on this site: [llms.txt](https://nuxtstarterkit.com/llms.txt)

This guide is for projects built on the previous version of the starter kit: Nuxt layers as workspace packages in `packages/layer-*`, run with Turborepo. The new version keeps the features and the database schema but changes the folder structure, the scripts and some environment variables.

The repository contains the same guide as `MIGRATION.md`.

**What stays the same:** page and API URLs, the database schema and its migrations, the better-auth and Polar setup, and the components and pages (only their location changed). End users of your app won't notice the update.

**What breaks:** your deployment, until you rename one environment variable, and every import or path that points into `packages/layer-*`.

## Choose a path

- **You barely changed the kit:** start from the new version and copy your few changes over.
- **You changed a lot:** still start from the new version and move your code in with the tables below. A `git merge` of the new version into your fork works in theory, but almost every file was moved, so expect conflicts in every file you touched.

Either way, do it on a branch and deploy to a staging environment first.

## 1. Environment variables

The `.env` file moves from the repository root to **apps/web/.env** (compare it with `apps/web/.env.example`).

<table>
<thead>
  <tr>
    <th>
      Before
    </th>
    
    <th>
      After
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        BETTER_AUTH_SECRET
      </code>
    </td>
    
    <td>
      <code>
        NUXT_BETTER_AUTH_SECRET
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        BETTER_AUTH_URL
      </code>
    </td>
    
    <td>
      removed: the base URL comes from <code>
        NUXT_PUBLIC_BASE_URL
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        DATABASE_NAME
      </code>
      
      , <code>
        DATABASE_USER
      </code>
      
      , <code>
        DATABASE_PASSWORD
      </code>
    </td>
    
    <td>
      removed: only <code>
        NUXT_PRIVATE_DATABASE_URL
      </code>
      
       is used
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        NODE_ENV
      </code>
      
       in <code>
        .env
      </code>
    </td>
    
    <td>
      removed: the Nuxt CLI sets it
    </td>
  </tr>
  
  <tr>
    <td>
      –
    </td>
    
    <td>
      new, optional: <code>
        NUXT_PRIVATE_EMAIL_RESEND_API_TOKEN
      </code>
      
       (when <code>
        NUXT_PRIVATE_EMAIL_PROVIDER=resend
      </code>
      
      )
    </td>
  </tr>
</tbody>
</table>

The values are now declared as Zod schemas in the `runtimeConfig` of each layer's `nuxt.config.ts`, which replaces `apps/web/validate-env.ts`. The server doesn't start when a required value is missing and lists the missing ones (error `NUXT_E8014`). See [Setup](https://nuxtstarterkit.com/docs/getting-started/setup) for the required values.

`NUXT_PRIVATE_POLAR_SERVER` now defaults to `sandbox`. Set it to `production` in production.

<warning>

**Docker and Coolify:** rename `BETTER_AUTH_SECRET` to `NUXT_BETTER_AUTH_SECRET` both as a runtime variable and as a build secret. Remove the build secrets the Dockerfile no longer reads (`BETTER_AUTH_URL`, `DATABASE_*`, `POLAR_ACCESS_TOKEN`, `POLAR_SERVER`). Without the new name the server doesn't start.

</warning>

## 2. Scripts and tooling

Turborepo and `dotenv-cli` are gone. Run the scripts from the repository root as before:

<table>
<thead>
  <tr>
    <th>
      Before
    </th>
    
    <th>
      After
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        pnpm dev:web
      </code>
    </td>
    
    <td>
      <code>
        pnpm dev
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        pnpm preview:web
      </code>
    </td>
    
    <td>
      <code>
        pnpm preview
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        pnpm dev:prepare
      </code>
    </td>
    
    <td>
      runs automatically on <code>
        pnpm install
      </code>
      
       (<code>
        nuxt prepare
      </code>
      
       in <code>
        apps/web
      </code>
      
      )
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        pnpm build
      </code>
      
      , <code>
        lint
      </code>
      
      , <code>
        typecheck
      </code>
      
      , <code>
        test:e2e
      </code>
      
      , <code>
        db:*
      </code>
    </td>
    
    <td>
      unchanged
    </td>
  </tr>
</tbody>
</table>

- Delete `turbo.json` and `.turbo/` if you still have them.
- The shared ESLint config (`packages/eslint-config`) is inlined in `apps/web/eslint.config.mjs`. The layers no longer have their own `package.json`, ESLint config, `tsconfig.json` or `.nuxtrc`.
- All npm dependencies of the app and its layers are in `apps/web/package.json`. If you added dependencies to a layer's `package.json`, move them there. Versions still go into the `catalog:` of `pnpm-workspace.yaml`.

## 3. Folder structure

Layers live in **apps/web/layers/<name>** and are registered automatically. There is no `extends` in `nuxt.config.ts` any more.

<table>
<thead>
  <tr>
    <th>
      Before
    </th>
    
    <th>
      After
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        packages/layer-<name>/…
      </code>
    </td>
    
    <td>
      <code>
        apps/web/layers/<name>/…
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        packages/layer-auth/server/db/migrations/
      </code>
    </td>
    
    <td>
      <code>
        apps/web/layers/auth/server/db/migrations/
      </code>
      
       (all migrations, unchanged)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        packages/layer-auth/server/db/drizzle.config.ts
      </code>
    </td>
    
    <td>
      <code>
        apps/web/layers/auth/server/db/drizzle.config.ts
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        packages/layer-auth/server/db/schema/<table>.ts
      </code>
    </td>
    
    <td>
      <code>
        apps/web/layers/<feature>/server/db/schema/<table>.ts
      </code>
      
       (see below)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        .env
      </code>
      
      , <code>
        .env.example
      </code>
    </td>
    
    <td>
      <code>
        apps/web/.env
      </code>
      
      , <code>
        apps/web/.env.example
      </code>
    </td>
  </tr>
</tbody>
</table>

Most files moved 1:1. These moved into the layer of their feature:

<table>
<thead>
  <tr>
    <th>
      Before
    </th>
    
    <th>
      After
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        layer-auth/server/db/schema/{banner,file,testimonial,waitlist}.ts
      </code>
    </td>
    
    <td>
      <code>
        layers/{banner,storage,testimonials,waitlist}/server/db/schema/
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        layer-dashboard/app/components/admin/{Banner,Testimonial*,Waitlist}*.vue
      </code>
    </td>
    
    <td>
      <code>
        layers/{banner,testimonials,waitlist}/app/components/admin/
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        layer-dashboard/app/pages/dashboard/admin/index/{banner,testimonials,waitlist}.vue
      </code>
    </td>
    
    <td>
      same path inside <code>
        layers/{banner,testimonials,waitlist}/app/pages/
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        layer-dashboard/server/api/dashboard/admin/{banner,testimonials,waitlist}/
      </code>
    </td>
    
    <td>
      same path inside <code>
        layers/{banner,testimonials,waitlist}/server/api/
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        layer-dashboard/shared/utils/banner.ts
      </code>
    </td>
    
    <td>
      <code>
        layers/banner/server/utils/useBanner.ts
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        apps/web/server/api/banner.get.ts
      </code>
    </td>
    
    <td>
      <code>
        layers/banner/server/api/banner.get.ts
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        layer-dashboard/app/components/DashboardAvatarUploader.vue
      </code>
    </td>
    
    <td>
      <code>
        layers/storage/app/components/StorageAvatarUploader.global.vue
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        layer-dashboard/app/pages/dashboard/storage-test.vue
      </code>
    </td>
    
    <td>
      <code>
        layers/storage/app/pages/dashboard/storage-test.vue
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        layer-core/server/utils/useCache.ts
      </code>
    </td>
    
    <td>
      <code>
        layers/storage/server/utils/useCache.ts
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        layer-emails/app/emails/WaitlistConfirmation.vue
      </code>
    </td>
    
    <td>
      <code>
        layers/waitlist/app/emails/WaitlistConfirmation.vue
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      i18n keys of a feature in <code>
        layer-core/i18n/locales/*.json
      </code>
    </td>
    
    <td>
      <code>
        layers/<feature>/i18n/locales/{en,de}.json
      </code>
    </td>
  </tr>
</tbody>
</table>

`banner` is a new layer. Before, its code was spread over `layer-auth`, `layer-dashboard` and `apps/web`.

## 4. Code changes

### Imports between layers

Package imports such as `layer-auth/server/db/schema` no longer exist, and neither does the barrel file `server/db/schema/index.ts`. Import the table file directly with a relative path, because drizzle-kit doesn't resolve aliases:

```ts
// before
import { user } from 'layer-auth/server/db/schema'

// after (from apps/web/layers/<layer>/server/api/…)
import { user } from '../../../auth/server/db/schema/auth'
```

`User` and `Session` stay auto-imported (`layers/auth/shared/types/db.ts`). The types of each feature are now in `layers/<feature>/shared/types/` and are auto-imported too.

### Navigation and slots

Required code (`apps/web`, `core`, `auth`, `emails`, `payment`, `dashboard`) no longer references optional features. If you added links or sections for your own features, register them in your layer's `app/app.config.ts`. See [Layers](https://nuxtstarterkit.com/docs/architecture/layers#extension-points).

### Emails

`useEmail()` keeps `sendContactSubmissionEmail`, `sendPasswordResetEmail` and `sendVerificationEmail`. New: `sendTemplate({ template, props, subject, to })` sends any component from an `app/emails/` folder of any layer. `sendWaitlistVerificationEmail` moved to the waitlist layer as a server util with the same signature.

### Loggers and server errors

`useLogger()` and `useServerLogger()` return a `consola` instance and take an optional tag: `useServerLogger('billing')`. They no longer call `consola.wrapConsole()`, so `console.*` isn't redirected any more (ESLint forbids it anyway).

A Nitro plugin (`layers/core/server/plugins/error-logger.ts`) logs every 5xx response. You can remove `try/catch` blocks that only log and rethrow. Throw `createError({ statusCode, statusMessage })` as before.

### Auth

`useAuth()` returns the same API. It now creates one better-auth client per app and loads the session only once. After that, better-auth's session store keeps it up to date, also across tabs: when a user signs out in one tab, the other tabs go to the login page on their next navigation. If your code called `fetchSession()` on every navigation, you can drop that. The unused `user.stripeCustomerId` default is gone.

### Admin API handlers

Every handler under `server/api/dashboard/admin/` now starts with `await requireAdmin(event)` (401 without a session, 403 without the admin role), in addition to the admin middleware. Add the same line to your own admin handlers; the unit test `layers/dashboard/test/admin-handlers.test.ts` fails for handlers without it. `hasAdminRole` moved to `layers/auth/server/lib/roles.ts`.

### Removed dependencies

If your own code used one of these, add it back to `apps/web/package.json` or switch to the replacement:

<table>
<thead>
  <tr>
    <th>
      Removed
    </th>
    
    <th>
      Replacement
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        @vueuse/nuxt
      </code>
      
       (VueUse auto-imports)
    </td>
    
    <td>
      Import composables explicitly: <code>
        import { refDebounced } from '@vueuse/core'
      </code>
      
      . <code>
        @vueuse/core
      </code>
      
       stays.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        uuid
      </code>
    </td>
    
    <td>
      <code>
        import { randomUUIDv7 } from 'node:crypto'
      </code>
      
       (server only)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        nanoid
      </code>
    </td>
    
    <td>
      <code>
        import { randomUUID } from 'node:crypto'
      </code>
      
       (server only)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        @unovis/vue
      </code>
      
      , <code>
        @unovis/ts
      </code>
    </td>
    
    <td>
      The dashboard revenue chart (<code>
        HomeChart.client.vue
      </code>
      
      ) is now a plain SVG component
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        better-sqlite3
      </code>
    </td>
    
    <td>
      Nuxt Content uses Node's built-in <code>
        node:sqlite
      </code>
      
      . The Docker build no longer installs <code>
        python3
      </code>
      
      , <code>
        make
      </code>
      
       and <code>
        g++
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        tsx
      </code>
      
      , <code>
        happy-dom
      </code>
      
      , <code>
        @vue/test-utils
      </code>
      
      , <code>
        playwright-core
      </code>
    </td>
    
    <td>
      Unused, or already installed by other packages
    </td>
  </tr>
</tbody>
</table>

### SEO and LLM files

The skew-protection and AI-ready modules of `@nuxtjs/seo` are disabled in `layers/core/nuxt.config.ts`. `/llms.txt` and `/llms-full.txt` come from `nuxt-llms`. The Markdown copies of every page (`/pricing.md`, …) and their `Link` headers are gone; the docs and blog posts are available as Markdown under `/raw/…`.

### Docs routes

`/docs` is now a redirect route rule to `/docs/getting-started`. `pages/docs/index.vue` and the `docs-redirect` server middleware were removed.

### Uploads (breaking)

The upload API detects the file type from the file content and no longer trusts the MIME type or file name sent by the client. The stored MIME type and extension come from the detected type.

- Only PNG, JPEG, GIF, WebP, AVIF and PDF can be uploaded. SVG, HTML, CSV and every other type return `415`, even if `NUXT_PRIVATE_STORAGE_ALLOWED_MIME_TYPES` lists them.
- Without `NUXT_PRIVATE_STORAGE_ALLOWED_MIME_TYPES`, only the image types are allowed (before: every type). Add `application/pdf` to allow PDFs.
- Without `NUXT_PRIVATE_STORAGE_MAX_FILE_SIZE`, the limit is 10 MB (before: no limit).

Files uploaded before stay as they are.

## 5. Database

No schema change and no new migration. The migrations only moved folders, so `pnpm db:migrate` on an existing database has nothing to apply. drizzle-kit now collects the schema from `apps/web/layers/*/server/db/schema/*.ts`.

If you added your own tables, put them into `server/db/schema/` of the layer they belong to, run `pnpm db:generate` and check that the generated migration is empty. If it isn't, a table is missing from the new paths.

## 6. Check the result

```bash
pnpm install
pnpm lint
pnpm typecheck
pnpm build
pnpm test:e2e
```

Then start the build with your real `apps/web/.env` and click through login, billing and the admin pages before you deploy.

<tip>

New in this version: you can delete the optional features you don't need (blog, docs, waitlist, testimonials, banner, storage). See [Layers](https://nuxtstarterkit.com/docs/architecture/layers#remove-an-optional-feature).

</tip>

## Sitemap

See the full [sitemap](https://nuxtstarterkit.com/sitemap.md) for all pages.
