Skip to content

Applies to CLI v2.8.0

In-project generation

Generate FSD slices

Generate typed FSD slices directly inside an existing project. The CLI reads fsd.config.json, resolves the framework's source directory, and writes framework-aware files to the matching layer.

Syntax

bash
npx create-fsd-architecture@latest --generate <type> <name>
bash
npx create-fsd-architecture@latest -g <type> <name>

Command examples

bash
npx create-fsd-architecture@latest --generate feature auth
npx create-fsd-architecture@latest -g feature checkout-flow
npx create-fsd-architecture@latest --generate feature product-filters
npx create-fsd-architecture@latest --generate entity product
npx create-fsd-architecture@latest -g entity order
npx create-fsd-architecture@latest --generate widget navbar
npx create-fsd-architecture@latest -g widget dashboard-sidebar
npx create-fsd-architecture@latest --generate page checkout

Examples by slice type

Feature example

feature

Use this for user actions and business interactions such as auth, checkout, filters, search, or forms.

bash
npx create-fsd-architecture@latest --generate feature auth
text
src/features/auth/
├── ui/
├── model/
└── index.ts

Entity example

entity

Use this for business objects such as product, user, order, brand, category, or cart item.

bash
npx create-fsd-architecture@latest --generate entity product
text
src/entities/product/
├── ui/
├── model/
└── index.ts

Widget example

widget

Use this for composed UI blocks such as navbar, sidebar, header, product grid, or checkout summary.

bash
npx create-fsd-architecture@latest --generate widget navbar
text
src/widgets/navbar/
├── ui/
└── index.ts

Page example

page

Use this for route-level page compositions such as checkout, profile, catalog, or dashboard.

bash
npx create-fsd-architecture@latest --generate page checkout
text
src/pages/checkout/
├── ui/
└── index.ts

Overwrite examples

The generator protects existing slices unless you explicitly pass `--force`.

bash
npx create-fsd-architecture@latest --generate feature auth --force
npx create-fsd-architecture@latest -g widget navbar --force

Supported types

featureentitywidgetpage

Overwrite behavior

Existing slices are protected by default. Pass `--force` when you intentionally want to overwrite a generated slice.

Generator behavior

Writes to src/* layers for React, Next.js, Vue + Vite, and SvelteKit projects.
Writes to app/* layers for Nuxt projects.
Uses kebab-case for folders and files.
Uses PascalCase for React components and Vue or Svelte component names.
Uses camelCase for variables and hooks.
Generates TypeScript boilerplate and a public index.ts API.
Prints a success message with the created files list.
Shows clear validation errors for invalid usage.

Generated paths

Project with src/

text
src/features/auth/
src/entities/product/
src/widgets/navbar/
src/pages/checkout/

Nuxt project

text
app/features/auth/
app/entities/product/
app/widgets/navbar/
app/pages/checkout/
app/app/routes/checkout.vue

SvelteKit project

text
src/features/auth/
src/entities/product/
src/widgets/navbar/
src/pages/checkout/
src/routes/checkout/+page.svelte

Project without src/

text
features/auth/
entities/product/
widgets/navbar/
pages/checkout/

Feature presets

Generic features use the API, server-state, client-state, and forms choices already stored in fsd.config.json.

React: React Query + Zustand or Redux Toolkit
Vue: Vue Query + Pinia
Nuxt: Vue Query SSR + Pinia modules
SvelteKit: Svelte Query + Svelte stores
Forms: React Hook Form, VeeValidate, or Superforms + Zod
UI only

Layout widget presets

Since CLI 2.7.0, the widget names navbar, sidebar, footer, and bottom-bar generate accessible layout components instead of an empty placeholder. Links come from an items prop; navbar and footer also accept a brand prop. Next.js uses next/link, Nuxt uses NuxtLink, and SvelteKit resolves typed pathnames. Vue presets are named AppNavbar, AppSidebar, AppFooter, and AppBottomBar.

bash
npx create-fsd-architecture@latest --generate widget navbar sidebar footer bottom-bar

Styling, icons, active-route state, and mounting the widget in a layout stay with your project. Any other widget name keeps the generic placeholder.

Page presets

Since CLI 2.7.1, the page names home, about, and consult generate sample page content: a hero with highlights, an about section with values, and a consultation form with name, email, and message. The consult page calls an optional onSubmit callback (Vue emits submit, Svelte takes onsubmit) and sends nothing by itself. Every page, preset or custom, is registered in the framework's routes.

bash
npx create-fsd-architecture@latest --generate page about consult

Starter templates already include a home page, so -g page home needs --force there.

Shared ui and api

Since CLI 2.7.0, shared ui creates unstyled button, input, label, and card primitives, and shared api creates shared/api/client.ts exporting apiClient for the configured Axios or fetch client (Nuxt uses $fetch with runtimeConfig.public.apiBase).

bash
npx create-fsd-architecture@latest --generate shared ui
bash
npx create-fsd-architecture@latest --generate shared ui button input
bash
npx create-fsd-architecture@latest --generate shared api --dry-run

Existing files are never overwritten. They are reported as KEEP, and only exports for newly created files are added to the segment index.ts. Starter templates already ship a shared API client, so on a new project these commands mainly fill gaps. --force is refused.

Feature preset examples

text
apiClient: axios
serverState: react-query

Creates API helpers, React Query hooks, typed request files, UI entry points,
and a public index.ts export.
text
framework: vue-vite
serverState: vue-query
clientState: pinia
forms: vee-validate-zod

Creates Vue single-file components, composables, a Pinia store,
typed API helpers, validation schemas, and a public index.ts export.
text
framework: sveltekit
apiClient: fetch
serverState: svelte-query
clientState: svelte-store
forms: sveltekit-superforms-zod

Creates Svelte 5 components, Svelte Query accessors, a Svelte store,
Superforms + Zod validation, and a public index.ts export. Page slices also
receive a src/routes/<name>/+page.svelte route wrapper.
text
clientState: zustand

Creates a local store, typed actions/state, UI entry points,
and a public index.ts export.
text
clientState: redux

Creates a slice, actions/selectors, UI entry points,
and a public index.ts export.
text
apiClient: fetch
serverState: none
clientState: none
forms: none

Creates a typed framework-native component, styles-ready structure,
and a public index.ts export.

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

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