Skip to content

Applies to CLI v2.7.1Last updated

Shipping

Deployment

Generated projects deploy like any project of their framework. FSD changes how code is organized, not how it is built. This page lists what each template produces and the settings hosts usually need.

Build output by framework

FrameworkBuild commandOutputAPI base variable
React + Vitenpm run buildStatic files in dist/VITE_API_URL
Vue + Vitenpm run buildStatic files in dist/VITE_API_URL
Next.jsnpm run buildNode.js server (next start)NEXT_PUBLIC_API_URL
Nuxtnpm run build or npm run generateNode.js server in .output/, or static files with generateNUXT_PUBLIC_API_BASE
SvelteKitnpm run buildDepends on the adapter (adapter-auto by default)PUBLIC_API_BASE

Use Node.js 22.12.0 or later on the build machine, and 22.22.2 or later for Nuxt and SvelteKit. Most hosts read the version from .nvmrc or an engines field, or let you set it in the project settings.

Environment variables

The generated API client reads its base URL from the variable above. These variables are public: they are embedded in the browser bundle at build time, so set them in the host before building and never put secrets in them.

bash
# React + Vite, Vue + Vite
VITE_API_URL=https://api.example.com

# Next.js
NEXT_PUBLIC_API_URL=https://api.example.com

# Nuxt (overrides runtimeConfig.public.apiBase)
NUXT_PUBLIC_API_BASE=https://api.example.com

# SvelteKit
PUBLIC_API_BASE=https://api.example.com

React and Vue: static hosting with an SPA fallback

Both templates use history-mode routing (React Router's createBrowserRouter, Vue Router's createWebHistory). Deep links such as /catalog only work when the host serves index.html for unknown paths.

json
// vercel.json
{ "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }] }
text
# Netlify: public/_redirects (copied into dist/)
/*  /index.html  200
nginx
location / {
  try_files $uri $uri/ /index.html;
}

Deploying under a sub-path such as GitHub Pages? Set Vite's base option to that path before building.

Next.js

Vercel detects the project with no extra settings. On your own server, build once and run the Node.js server:

bash
npm ci
npm run build
npm run start   # listens on PORT, default 3000

Nuxt

npm run build produces a server-rendered app in .output/. Most hosts detect it automatically; on your own server, run it with Node.js. For a fully static site, use npm run generate and deploy .output/public.

bash
npm run build
node .output/server/index.mjs

SvelteKit

The template uses @sveltejs/adapter-auto, which detects Vercel, Netlify, and Cloudflare Pages during their builds. For any other target, install a specific adapter and set it in vite.config.ts:

bash
npm install -D @sveltejs/adapter-node     # Node.js server
npm install -D @sveltejs/adapter-static   # static files

Before you ship

Run npm run ci locally or in CI first: it runs the FSD architecture check, lint, type checks, and the production build that the host will run.

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

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