You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/documentation/docs/01-introduction/02-getting-started.md

2.5 KiB

title
Getting started
  • npm create svelte@latest, describe that it scaffolds SvelteKit project
  • npm create vite@latest, describe that it scaffolds Svelte SPA powered by Vite
  • mention svelte-add
  • Jump off points to tutorial, SvelteKit etc

Start a new project

We recommend using SvelteKit, the official application framework from the Svelte team:

npm create svelte@latest myapp
cd myapp
npm install
npm run dev

SvelteKit will handle calling the Svelte compiler to convert your .svelte files into .js files that create the DOM and .css files that style it. It also provides all the other pieces you need to build a web application such as a development server, routing, deployment, and SSR support. SvelteKit uses Vite to build your code.

Don't worry if you don't know Svelte yet! You can ignore all the nice features SvelteKit brings on top for now and dive into it later.

Alternatives to SvelteKit

If you don't want to use SvelteKit for some reason, you can also use Svelte with Vite (but without SvelteKit) by running npm create vite@latest and selecting the svelte option. With this, npm run build will generate HTML, JS and CSS files inside the dist directory thanks using vite-plugin-svelte. In most cases, you will probably need to choose a routing library as well.

Alternatively, there are plugins for Rollup, Webpack and a few others to handle Svelte compilation — which will output .js and .css that you can insert into your HTML — but setting up SSR with them requires more manual work.

Editor tooling

The Svelte team maintains a VS Code extension and there are integrations with various other editors and tools as well.

You can also check your code from the command line using svelte-check (using the Svelte or Vite CLI setup will install this for you).

Getting help

Don't be shy about asking for help in the Discord chatroom! You can also find answers on Stack Overflow.