Skip to content

Get started

Project structure

The kit lives in layers/kit/, a Nuxt layer, and your app lives at the root around it. Inside both, code is split by where it runs: app/ in the browser, server/ on the Worker, shared/ in both. A file of yours at the same path as one of the kit's replaces it, for the kinds Your files and the kit's lists. Check this page before you add a file under server/: in some directories a new file becomes a route, a job or a provider, and in others it does nothing until you import it.

Top level

Your app's root:

PathWhat lives there
layers/kit/(Licensees only)The kit. Every update replaces it whole (Updating from the kit)
app/Your pages, components, layouts and composables. The kit ships an empty app.config.ts here
server/Your routes, jobs, listeners, tasks, providers and tables
shared/Your types and helpers that both the app and the server import
emails/Your mail templates (Email)
i18n/locales/Your catalogues, merged over the kit's (Languages)
content/Blog posts and legal pages, one folder per locale (Blog)
public/Static files, served as they are
test/Your suites, which pnpm test runs with the kit's (Testing)
scripts/Your scripts, and your seeds in scripts/seed/ (Database)
starter.config.ts(Licensees only)Which parts are on, and with which providers (Configuration)
blog.config.mjs(Licensees only)The blog pipeline's context, author, models and Images account (Blog)
wrangler.jsonc(Licensees only)Cloudflare bindings, queues and crons (Deployment)
nuxt.config.ts(Licensees only)Empty. Nuxt merges it over the kit's
drizzle.config.ts(Licensees only)Your tables' migration chain (Database)

Inside the kit:

PathWhat lives there
layers/kit/app/(Licensees only)The kit's Vue app: pages, components, layouts, composables, Pinia stores
layers/kit/server/(Licensees only)Everything of the kit's that runs on the Worker
layers/kit/shared/(Licensees only)Types, zod schemas and pure helpers that both the app and the server import
layers/kit/modules/(Licensees only)Nuxt modules that run at build time and generate the registries
layers/kit/build/(Licensees only)Plain functions the kit's nuxt.config.ts calls while it loads
layers/kit/emails/(Licensees only)The kit's mail templates, written as Vue components
layers/kit/i18n/(Licensees only)The English and Serbian catalogues and the vue-i18n config
layers/kit/test/(Licensees only)The kit's unit, nuxt and e2e suites and their shared helpers
layers/kit/scripts/(Licensees only)Node scripts for the database, the seed, the blog pipeline and kit:update. Never bundled

Which of these are yours and which the kit updates is on Updating from the kit.

Your files and the kit's

A file of yours replaces the kit's when Nuxt or the kit looks both up by the same name:

KindYours, at the app rootReplaces the kit's
Pageapp/pages/…page at the same path, route-group folders included
Componentapp/components/…component of the same name
Composable or helperapp/composables/, app/utils/kit export of that name in app/composables/ or app/utils/, unless imported by path (below)
Layout, route middlewareapp/layouts/, app/middleware/one of the same name
Root componentapp/app.vue, app/error.vuethe kit's
Server routeserver/api/…, server/routes/…route in layers/kit/server/api/ or layers/kit/server/routes/ with the same path and method
Scheduled taskserver/tasks/…task of the same name
Job, listenerserver/jobs/<kind>.ts, server/listeners/<name>.tsfile of the same name
Providerserver/<subsystem>/adapters/<id>.ts for ai, email, payments, flags and monitoring; server/signals/<axis>/<id>.ts; OAuth in server/auth/adapters/<id>.tsshipped adapter with the same id
Mail templateemails/<name>.vuetemplate of the same name
Stringsi18n/locales/<file> holding only the keys you changethe kit's string under each key
Configurationnuxt.config.ts, app/app.config.tsmerged over the kit's, yours winning a key unless it holds an array (below)

A copy keeps only what the kit's file had on the day you made it. Put it at the path of the kit file it replaces, so each update that changes the original names it (Updating from the kit). A component or auto-import of yours under another file name still replaces the kit's, but no update names it. Where you only surround or restyle a kit file, prefer a wrapper that renders the kit's own through #layers/kit/, which keeps taking the kit's fixes:

<script setup lang="ts">
import KitAuthCard from '#layers/kit/app/components/auth/Card.vue'
import type { AuthCardProps } from '#layers/kit/app/types/auth-components'

defineProps<AuthCardProps>()
</script>

<template>
  <div class="bg-primary/5 flex flex-1 flex-col">
    <KitAuthCard :title :subtitle>
      <slot />
    </KitAuthCard>
  </div>
</template>

Some files take no replacement:

  • Plugins, server middleware and modules add, never replace. Nuxt runs every app plugin, nitro plugin, server middleware and file in modules/ of every layer, so one of yours under a kit file's name runs beside the kit's.
  • Routes a kit module registers stay the kit's. Sign-in and account routes under /api/auth/, the organization routes, the storage purposes' read routes, the contact routes and the analytics ingest are added by layers/kit/modules/, after the routes nitro finds in files, so a file of yours at the same path never answers. Change them through starter.config.ts.
  • A route of yours may not leave another unreached. The server's router keeps one branch per parameter name at a path segment and does not backtrack between them, so a route of yours under server/api/orgs/[orgId]/ would leave the kit's routes under /api/orgs/:org/ answering 404, and one under server/api/avatars/[user]/ every stored photo. The build looks each route that is not yours up in that router with yours beside it, refuses the route of yours that leaves one unreached, and names the rename. Read the new name in your handler too, as getRouterParam(event, 'org'). A parameter named otherwise where every lookup still lands, as server/routes/[code].get.ts beside the kit's /:locale/blog/rss.xml, passes. A route file you add while pnpm dev runs is checked when it next starts.
  • A name the kit's helpers auto-import stays the kit's. Every export of layers/kit/shared/utils/ is auto-imported under its name in the app and on the server, and every export of layers/kit/server/utils/ on the server, where the kit's own code calls it by that name. A helper of yours under the same name would stand in for the kit's there, or lose to it in your own code, so the build refuses one in app/composables/, app/utils/, shared/utils/ or server/utils/ under a name the kit's shared/utils/ exports, and one in shared/utils/ or server/utils/ under a name its server/utils/ exports. A copy of a kit file in server/utils/ or shared/utils/ is refused the same way. The refusal names both files: rename yours, or keep the file outside those folders and import it by path. A type of the same name is not refused.
  • What the kit imports by path stays the kit's. Its own files import one another through #layers/kit/, so layers/kit/shared/, layers/kit/build/, layers/kit/modules/ and every server module the kit does not look up by name above are reached only there. Change them through starter.config.ts and the seams on the other pages. The same holds for a composable or helper that a kit file imports from #layers/kit/app/, such as most query definitions in composables/queries.ts, OAUTH_META, and the error, billing, chart, search and page-view analytics helpers in app/utils/. Every kit file that uses one imports it, so an export of yours under its name is used by your files and by none of the kit's. Replace the component, page or composable that uses it instead; the page-view helpers serve the analytics plugin, which takes no replacement.
  • An array in the configuration adds to the kit's. An array of yours in nuxt.config.ts or app/app.config.ts, under a key the kit also sets, goes ahead of the kit's entries rather than in their place, so it can add entries and remove none. Under ui that includes compoundVariants: an entry of yours for a colour and variant the kit also styles is applied first, and the kit's classes win where the two clash. Mark the classes that must win as important, such as dark:bg-transparent!. The kit's app/app.config.ts holds no arrays outside ui, so a value of yours there replaces the kit's: forms: { validateOn: { blur: true, input: false, change: false } } checks a field when it loses focus instead of while it is typed in.
  • A kit file cannot be deleted. The update brings layers/kit/ back whole. Replace it instead: a component of the same name can render nothing, and a page at the same path can send its visitors elsewhere.

Keep app/ at your root, even with nothing in it but app.config.ts. Without it Nuxt reads the root itself as its source folder, which moves ~/ and every generated type, so the build refuses to start.

Aliases

AliasResolves to
~~/, @@/your app's root
~/, @/your app/
#shared/your shared/
#server/your server/
#layers/kit/layers/kit/
#starter/layers/kit/shared/starter/*.ts, for starter.config.ts alone

So import a kit file through #layers/kit/, and your own through the aliases Nuxt defines. ~~/starter.config reads your config wherever it is imported.

server/

Nitro scans six directories, in the kit and in your app alike. A file in api/ or routes/ is a route, middleware/ runs on every request, plugins/ runs once when the Worker starts, and a file in tasks/ is a task, which runs once schedule.tasks gives it a cron (Background jobs). Every named export in utils/ becomes a global in server code. The build refuses a route of yours beside which the server's router no longer reaches one of the kit's, naming the file and the way out (Your files and the kit's).

Your middleware runs before all of the kit's, in filename order among your own; the kit's then run in theirs. layers/kit/test/unit/middleware-order.test.ts(Licensees only) pins the order the kit relies on.

The kit's own build code scans a few more:

DirectoryA .ts file there becomesScanned by
server/jobs/, yours and the kit'sA background job, with the filename as kindlayers/kit/modules/jobs-registry.ts(Licensees only)
server/listeners/, yours and the kit'sAn event listenerlayers/kit/modules/listeners-registry.ts(Licensees only)
server/{ai,auth,email,flags,monitoring,payments}/adapters/A provider, with the filename as its idlayers/kit/build/custom-adapters.ts(Licensees only)
server/signals/analytics/, server/signals/marketing/An analytics or marketing providerlayers/kit/build/custom-adapters.ts(Licensees only)

Your job or listener with the name of one of the kit's replaces it. The adapter folders are read at your root only; create one when you add a provider. The registries read these directories when Nuxt starts, so restart pnpm dev after you add, rename or delete a file in them.

Everything else under the kit's server/ is plain code that nothing scans: ai/, auth/, cache/, contact/, database/, durable/, email/, events/, flags/, monitoring/, notifications/, payments/, signals/, storage/, tenancy/ and types/. The two handlers in layers/kit/server/contact/routes/ are registered by name, one per entry in contact.channels, from layers/kit/modules/contact-routes.ts(Licensees only) (Contact), so a file you add there is not a route. Import the rest through the #layers/kit/server/* alias:

import { defineListener } from '#layers/kit/server/events/types'
import { requireOrgScope } from '#layers/kit/server/tenancy/scope'

Nuxt refuses an import from server/ in app code, so nothing here can reach the browser bundle by accident. Code that both sides need goes in shared/.

layers/kit/modules/ and layers/kit/build/

Both run at build time. A file in layers/kit/modules/ is a Nuxt module: Nuxt registers every file directly under a layer's modules/ and every modules/*/index.ts. The kit's modules generate the registries (#jobs-registry, #payments-registry and the rest), add routes, and fail the build when the config doesn't add up. layers/kit/modules/support/ has no index.ts, so the helpers there are shared by the modules and never registered. A module of yours goes in a modules/ folder at your root, which Nuxt registers the same way.

layers/kit/build/ holds plain functions that the kit's nuxt.config.ts calls while it is being evaluated, before Nuxt or its aliases exist, so it imports them by relative path. That covers reading wrangler.jsonc, the binding checks in layers/kit/build/assertions.ts(Licensees only), the runtime-config slots in layers/kit/build/runtime-config.ts(Licensees only), the schedule checked against triggers.crons in layers/kit/build/schedule.ts(Licensees only), the locale list and its catalogues. Nothing in layers/kit/build/ is bundled.

app/ and shared/

app/ follows Nuxt's defaults, in the kit and in your app: components/, composables/ and utils/ are auto-imported in the app, and pages/ is the router. layers/kit/app/types/ holds the types of the kit's own components and queries.

In shared/, the exports of shared/utils/ are auto-imported on both sides, and so are the types in shared/types/, such as PlanId and Permission. Import anything else of the kit's there through #layers/kit/shared/*:

import { planRefSlots } from '#layers/kit/shared/payments/ref-slots'

test/

DirectoryRunnerEnvironment
layers/kit/test/unit, your test/unitvitest, project unitNode
layers/kit/test/nuxt, your test/nuxtvitest, project nuxtA built Nuxt app
layers/kit/test/e2e, your test/e2ePlaywrightA running nuxt dev

layers/kit/test/helpers is shared by the two vitest projects. pnpm test --run runs both, the kit's suites and yours; pnpm test:e2e runs Playwright. Your suites read your starter.config.ts, and the kit's read the config the kit ships. A Playwright spec of yours imports test and expect from #layers/kit/test/e2e/fixtures (Testing).

Good to know

  • Every .ts file in server/jobs/ and server/listeners/, yours and the kit's, is registered as a job or a listener. Keep helpers out of both.
  • An export added to server/utils/ or shared/utils/ becomes a global, and can collide with an existing auto-import. Put a helper you don't want global somewhere else and import it.
  • Vitest collects the kit's suites directly inside layers/kit/test/unit/ and layers/kit/test/nuxt/, and yours at any depth under test/unit/ and test/nuxt/.
  • Code in layers/kit/build/ runs before Nuxt's aliases exist. It imports by relative path, as its files do with ../../../starter.config, never through ~~/ or #layers/kit/.
  • A runtimeConfig.session in your nuxt.config.ts sets password: '' beside the keys you change, as the kit's does. Nuxt checks the config against nuxt-auth-utils' session type, which requires the key, so pnpm typecheck refuses the block without it. Leave it empty: NUXT_SESSION_PASSWORD sets the real one at runtime, and a value written there is built into the Worker.

A link with a lock opens the kit’s private repository, which every licensee can read.