Skip to content
tezvyn:

SvelteKit: From Zero to Dev Server

Source: svelte.devEasyHow cards are made

SvelteKit: From Zero to Dev Server

Spin up a new SvelteKit app with npx sv create. This command scaffolds a project, prompting you to add tools like TypeScript. Then, npm run dev starts your dev server. The key footgun: forgetting to install dependencies before starting the server.

Why it exists

Frameworks need a standardized way to create new projects with a sensible directory structure and build tooling configured. SvelteKit's create-svelte package handles this, providing a consistent, interactive starting point for all developers and eliminating manual setup.

The mental model

Think of npx sv create as an interactive project generator. It asks you a few questions about your desired setup (like using TypeScript or a linter) and then builds a ready-to-code SvelteKit application for you. It's the blueprint that sets up the foundation so you can start building.

How it works

The command npx sv create my-app uses npx to download and run the create-svelte package. This starts a command-line interface (CLI) that guides you through setup. After generating files in the my-app directory, you navigate into it (cd my-app), install dependencies (npm install), and start the development server (npm run dev). This server, powered by Vite, typically runs on localhost:5173 and provides a fast development experience with hot module replacement.

When to use it

Use this command every time you start a new SvelteKit project. It is the official and recommended method to ensure your project has the correct structure, dependencies, and configuration files from the very beginning.

When not to use it

You do not run this command inside an existing project; it is strictly for scaffolding new ones. If you are cloning an existing SvelteKit project from a repository, you do not use create. Instead, you clone the repository, then run npm install to install its dependencies.

One canonical example

To create a new app named 'my-blog', you would run npx sv create my-blog. The CLI will ask a series of questions. After it finishes, you run cd my-blog, then npm install (if you didn't during setup), and finally npm run dev. Your new SvelteKit app is now running and ready for you to start creating pages in the src/routes directory.

Interview question

What is the correct sequence of commands to initialize a new SvelteKit project and start its development server?

  • a.npx sv create my-app, then npm run dev inside my-app
  • b.npx sv create my-app, then cd my-app, then npm install, then npm run devCorrect
  • c.npm install, then npx sv create my-app, then npm run dev
  • d.cd my-app, then npx sv create my-app, then npm install, then npm run dev
Why?

The card explicitly states the process: first create the project with npx sv create, then navigate into the directory with cd, install dependencies with npm install, and finally start the server with npm run dev. Option A is a common mistake because it omits the crucial npm install step, which the card identifies as a 'footgun'.

Just read this? Test yourself on what you have been reading.

Read the original → svelte.dev

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on svelte — each one lists the topics its interview covers.

See open roles