Skip to content

Setup

React has three mainstream starting points: Create React App (now deprecated), Vite with the React plugin, and Next.js for full-stack/SSR work. Svelte mirrors this split almost exactly — Vite + Svelte plugin for SPAs and SvelteKit for full-stack/SSR. If you know the React toolchain you already understand the shape of the Svelte one; the names just changed.

ReactSvelte
npm create vite@latest my-app -- --template react-tsnpm create vite@latest my-app -- --template svelte-ts
npx create-next-app my-appnpx sv create my-app
  • The Vite command is identical except for the template name: react-tssvelte-ts.
  • npx sv create is the official SvelteKit scaffolder — the direct equivalent of create-next-app. It prompts for TypeScript, ESLint, Prettier, Vitest, and more.

Because both ecosystems use Vite under the hood, the scripts look almost the same. The only difference is that the React/Vite template runs tsc before vite build as a type-check step.

React
{
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
}
}
Svelte
{
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
}
}

Key points:

  • dev, build, and preview exist in both — muscle memory transfers directly.
  • Svelte’s Vite plugin runs the Svelte compiler and TypeScript checks together via svelte-check, so there is no separate tsc && prefix needed.
  • SvelteKit adds a check script (svelte-kit sync && svelte-check) and an optional test script on top of these basics.

Both a Vite+Svelte SPA and a SvelteKit project are thin wrappers around familiar patterns:

Vite + Svelte SPA (equivalent to Vite + React):

flowchart TB
  root(["project root"])
  root --> src["src/"]
  src --> main["main.ts — entry point (was main.tsx)"]
  src --> app["App.svelte — root component (was App.tsx)"]
  src --> lib["lib/ — shared components and utilities"]
  root --> indexHtml["index.html"]
  root --> viteConfig["vite.config.ts"]
Vite + Svelte SPA project structure

SvelteKit (equivalent to Next.js):

flowchart TB
  root(["project root"])
  root --> src["src/"]
  src --> routes["routes/ — file-based routing (was app/ or pages/ in Next.js)"]
  routes --> page["+page.svelte — a route's UI"]
  routes --> layout["+layout.svelte — shared layout wrapper"]
  src --> lib["lib/ — shared utilities and components"]
  root --> staticDir["static/ — public assets (was public/)"]
  root --> svelteConfig["svelte.config.js"]
  root --> viteConfig["vite.config.ts"]
SvelteKit project structure

The mental model maps cleanly: src/routes/ in SvelteKit does what app/ (or pages/) does in Next.js. The +page.svelte naming convention is SvelteKit-specific — the + prefix distinguishes framework files from your own helper files.

vite.config.ts — just a different plugin

Section titled “vite.config.ts — just a different plugin”

React and Svelte both configure Vite with a single plugin import:

// React
import react from '@vitejs/plugin-react';
export default { plugins: [react()] };
// Svelte
import { svelte } from '@sveltejs/vite-plugin-svelte';
export default { plugins: [svelte()] };

Everything else — aliases, server options, build targets — is identical Vite config.

Playground note: This is a project scaffolding lesson — there is no runnable in-browser snippet. Run the commands above in your terminal to scaffold a real project.

What is the SvelteKit equivalent of Next.js?
Which command scaffolds a plain Svelte SPA with Vite?
Where do SvelteKit routes live?