Skip to content

Applies to CLI v2.8.0

Special feature generator

Generate an auth feature scaffold

Naming a feature auth activates the dedicated generator. It creates auth UI and integration scaffolding and adapts the output to the stack saved in fsd.config.json.

In CLI 2.8.0, generated API endpoints are examples. Connect an application backend and verify session handling and authorization before deployment. The opt-in Supabase adapter (--auth-provider supabase) ships since CLI 2.7.0; its staging end-to-end acceptance is still pending. See the Supabase integration guide.

Feature status

Auth generatorStable
Forms, validation, state, and example API requests for all five frameworks. The endpoints are placeholders: connect your own backend and review session handling before production.
Supabase adapterPreview
Released in CLI 2.7.0 behind --auth-provider supabase. Generated output builds in all five frameworks; end-to-end checks against a live Supabase project (sign-up confirmation, recovery mail, password reset, refresh and logout, RLS) are still pending. Browser only: SSR cookies and server authorization need your own integration.

Commands

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

Generated flow

Login
Registration
Forgot password
Reset password
Verification code

Stack-aware output

Axios or Fetch

Creates API functions using the configured client.

TanStack Query

Adds React Query hooks, Vue Query composables, or Svelte Query accessors for the selected framework.

Framework-native stores

Creates Zustand, Redux Toolkit, Pinia, or Svelte store auth state and reusable helpers.

Redux Toolkit

Creates a reducer, actions, selectors, and registers the reducer.

Typed form validation

Uses React Hook Form, VeeValidate, or Superforms with Zod for every auth step.

Minimal stack

Keeps the generated feature UI-focused when optional tools are disabled.

SvelteKit output

In sveltekit projects, the command generates native Svelte 5 components for all five auth steps, TanStack Svelte Query v6 accessors, a Svelte auth store, and Superforms + Zod 4 validation. Forms use SvelteKit progressive enhancement while keeping their server-ready validation contract.

Vue output

In vue-vite and nuxt projects, the same command generates Vue single-file components for login, registration, password recovery, reset, and verification, plus Vue Query composables, a Pinia store, and VeeValidate + Zod forms when enabled. Nuxt uses its configured modules and SSR-aware Vue Query plugin.

Generated structure

text
src/features/auth/
├── api/
├── lib/
├── model/
├── ui/
└── index.ts

Exact files vary with the configured API, state, and forms choices. Existing auth files are protected unless you pass --force.

Nuxt writes the same feature under app/features/authbecause its framework adapter owns the app/ source root. SvelteKit writes it under src/features/auth.

Generated files

Output from --dry-run with the React defaults (React Query, Zustand, React Hook Form + Zod):

text
src/features/auth/
├── api/
│   ├── login.api.ts  register.api.ts  forgot-password.api.ts
│   ├── reset-password.api.ts  verify-code.api.ts
│   └── auth.query.ts                 # React Query hooks
├── lib/
│   ├── auth.keys.ts                  # query keys
│   └── auth.helpers.ts
├── model/
│   ├── auth.types.ts  auth.store.ts  # Zustand store
│   ├── <flow>.types.ts               # one per flow
│   └── <flow>.schema.ts              # Zod schema per flow
├── ui/
│   ├── login-form.tsx  register-form.tsx  forgot-password-form.tsx
│   └── reset-password-form.tsx  verify-code-form.tsx
└── index.ts

The five flows are login, register, forgot password, reset password, and verify code. Vue and SvelteKit produce the same API, store, query, and schema modules with LoginForm.vue or LoginForm.svelte components, and share one auth.types.ts instead of a types file per flow.

What your stack changes

  • In React projects, serverState: "none" skips the API modules, auth.query.ts, and the query keys; wire the forms to your own requests.
  • clientState: "none" skips auth.store.ts. Redux projects get auth.slice.ts and auth.selectors.ts instead of a Zustand store.
  • forms: "none" drops the Zod schemas; the components keep plain form handling.
  • --auth-provider supabase adds api/supabase.adapter.js, its type declarations, api/supabase.ts (exporting configureSupabaseAuth), and SUPABASE.md.

After generating

  1. Point the API modules at your backend, or configure the Supabase client once at app start.
  2. Render the forms from a page, for example -g page login, importing them from @/features/auth.
  3. Verify session handling, token storage, and authorization on the server before shipping. The generated code is a starting point, not a security review.

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

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