Skip to content

Applies to CLI v2.8.0

Stable in CLI 2.5.0

SvelteKit-native FSD with the complete structure

The SvelteKit edition combines Svelte 5 runes, SSR-ready routing, and a complete Feature-Sliced Design source tree. Its generators write native.svelte components and keep route files as thin wrappers around FSD page slices.

Create a SvelteKit project

bash
npx create-fsd-architecture@latest my-app --framework sveltekit --yes
bash
npm create fsd-architecture@latest

Interactive setup lets you keep the defaults—native Fetch, Svelte Query, Svelte stores, and Superforms + Zod—or disable optional tools.

Default stack

FrameworkSvelte 5 + SvelteKit 2
API clientNative Fetch by default, Axios optional
Server stateTanStack Svelte Query v6
Client stateSvelte stores
FormsSvelteKit Superforms + Zod 4
QualityTypeScript, ESLint, Steiger, Husky, Commitlint

SvelteKit and FSD directory contract

text
src/
├── app/          # FSD application providers and global setup
├── pages/        # FSD page slices, not SvelteKit route files
├── widgets/      # Composed interface blocks
├── features/     # User interactions
├── entities/     # Business models
├── shared/       # Reusable UI, API, config, and utilities
└── routes/       # SvelteKit file-based route wrappers

SvelteKit reserves $app, so the FSD app layer uses the$fsd-app alias. Other aliases include $pages, $widgets, $features, $entities, and $shared.

Native generators and routes

bash
npx create-fsd-architecture@latest -g feature auth
npx create-fsd-architecture@latest -g entity product
npx create-fsd-architecture@latest -g widget navbar
npx create-fsd-architecture@latest -g page account
text
src/pages/account/
├── ui/AccountPage.svelte
└── index.ts

src/routes/account/+page.svelte

The route wrapper imports the public page-slice API, so SvelteKit owns URL matching while FSD owns the page composition.

Runtime config

Set PUBLIC_API_BASE for generated API helpers. The default Fetch client works in both server and browser code.

Node.js

Generated projects require Node.js 22.22.2 or later. The starter pins Node 22.23.0 for repeatable local and CI checks.

Quality workflow

bash
npm run lint
npm run typecheck
npm run fsd:check
npm run build
npm run ci
View the SvelteKit starter on GitHub

What each generator writes

Output from --dry-run in a project with the SvelteKit defaults (Fetch, Svelte Query, Svelte stores, Superforms + Zod). Every slice gets an index.ts public API.

text
-g feature checkout
  src/features/checkout/model/checkout.types.ts
  src/features/checkout/model/checkout.store.ts     # Svelte store
  src/features/checkout/ui/CheckoutView.svelte
  src/features/checkout/api/checkout.api.ts
  src/features/checkout/api/checkout.query.ts       # Svelte Query
  src/features/checkout/lib/checkout.keys.ts        # query keys
  src/features/checkout/index.ts

-g entity product
  src/entities/product/model/product.types.ts
  src/entities/product/ui/ProductCard.svelte
  src/entities/product/index.ts

-g widget product-list
  src/widgets/product-list/ui/ProductList.svelte
  src/widgets/product-list/index.ts

-g page catalog
  src/pages/catalog/ui/CatalogPage.svelte
  src/pages/catalog/index.ts
  src/routes/catalog/+page.svelte                   # route file (created/updated)

SvelteKit routing is file-based, so a page slice also gets a thin src/routes/<name>/+page.svelte that renders the page through the $pages alias. Route logic such as +page.ts loaders stays yours to add next to it.

Capabilities change the output

Generators read fsd.config.json. With serverState: "none", features skip the API module, the Svelte Query module, and the keys; with clientState: "none", they skip the store; with forms: "none", auth skips the Superforms + Zod schemas. Existing slices are never rewritten when you change the config.

Auth in SvelteKit

-g feature auth writes five flows (login, register, forgot password, reset password, verify code), each with an API module, a Zod schema, and a LoginForm.svelte-style component, plus a shared store, Svelte Query module, and keys. --auth-provider supabase adds the browser adapter (api/supabase.ts) and a SUPABASE.md setup note.

Support FSD CLI

If FSD CLI helps you build, consider supporting its development and documentation. Donations are optional.

GitHub Sponsors (opens in a new tab)Buy Me a Coffee (opens in a new tab)

InstaPay · Egypt

ashrafmo-1

للدعم من مصر عبر إنستا باي. تأكد من بيانات المستلم قبل تأكيد التحويل.