पाठ 2 / 25

Creating a Project With sv

Scaffold a SvelteKit app and know the files.

npx sv create

The official CLI is sv. Running npx sv create my-app asks for a template (for example the minimal SvelteKit app), TypeScript or JSDoc type checking, and optional add-ons such as Prettier, ESLint, Vitest, Playwright and Tailwind CSS. Then npm install and npm run dev start the Vite dev server. Key files: svelte.config.js (compiler and SvelteKit options, including the adapter), vite.config.ts (with the sveltekit() plugin), src/routes (pages), src/lib (shared code, imported via the $lib alias) and src/app.html (the HTML shell). Add-ons can be added later with npx sv add. The older create-svelte package is superseded by sv.

Scaffold and configure

Commands as comments, then the generated config.

// Terminal:
//   npx sv create my-app      # choose SvelteKit minimal, TypeScript, add-ons
//   cd my-app
//   npm install
//   npm run dev               # Vite dev server, usually http://localhost:5173
//   npx sv add vitest         # add an integration later

// svelte.config.js
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
const config = {
  preprocess: vitePreprocess(),
  kit: { adapter: adapter() }
};

export default config;

Plain Svelte without SvelteKit

For a widget or an app without routing or SSR, a Vite + Svelte template is enough; SvelteKit is recommended for full applications. Check the docs for the templates your sv version offers.

त्वरित जाँच: Where do you configure the SvelteKit deployment adapter?

  • In svelte.config.js under kit.adapter
  • In src/app.html
  • In +page.svelte
  • In package.json under "adapter"
Answer

In svelte.config.js under kit.adapter — svelte.config.js holds compiler and kit options.