.gitignore and .npmrc (and .prettierrc and eslint.config.js if you chose those options when running npx sv create).
Project files
src
Thesrc directory contains the core of your project. Everything except src/routes and src/app.html is optional.
lib - Library code
lib - Library code
Contains your library code (utilities and components), which can be imported via the
$lib alias, or packaged up for distribution using svelte-package.lib/server - Server-only code
lib/server - Server-only code
Contains your server-only library code. It can be imported by using the
$lib/server alias. SvelteKit will prevent you from importing these in client code.params - Route param matchers
params - Route param matchers
Contains param matchers for advanced routing. These allow you to validate route parameters.Use in routes like:
src/params/uuid.js
src/routes/user/[id=uuid]/+page.svelteroutes - Your application routes
routes - Your application routes
Contains the routes of your application. You can also colocate other components that are only used within a single route here.Routes are determined by the file structure:
+page.svelte— A page component+page.js— Universal load function+page.server.js— Server-only load function and actions+layout.svelte— Layout component+layout.js— Layout load function+server.js— API endpoint+error.svelte— Error page
app.html - Page template
app.html - Page template
Your page template — an HTML document containing placeholders:Available placeholders:
src/app.html
%sveltekit.head%—<link>and<script>elements, plus any<svelte:head>content%sveltekit.body%— the markup for a rendered page%sveltekit.assets%— the configured assets path%sveltekit.nonce%— a CSP nonce for manually included links and scripts%sveltekit.env.[NAME]%— environment variables beginning with the public prefix%sveltekit.version%— the app version
error.html - Error page fallback
error.html - Error page fallback
The page that is rendered when everything else fails. It can contain the following placeholders:
src/error.html
%sveltekit.status%— the HTTP status%sveltekit.error.message%— the error message
hooks.client.js - Client hooks
hooks.client.js - Client hooks
Contains your client-side hooks. These run in the browser:
src/hooks.client.js
hooks.server.js - Server hooks
hooks.server.js - Server hooks
Contains your server-side hooks. The
handle hook runs on every request:src/hooks.server.js
service-worker.js - Service worker
service-worker.js - Service worker
Contains your service worker for offline support and caching:
src/service-worker.js
instrumentation.server.js - Observability setup
instrumentation.server.js - Observability setup
Contains your observability setup and instrumentation code. Requires adapter support and runs prior to loading your application code.
src/instrumentation.server.js
static
Any static assets that should be served as-is — such asrobots.txt or favicon.png — go in here.
It’s generally preferable to minimize the number of assets in
static/ and instead import them. Using an import allows Vite’s built-in handling to give a unique name to an asset based on a hash of its contents so that it can be cached.tests
If you added Playwright for browser testing when you set up your project, the tests will live in this directory.tests/test.js
package.json
Yourpackage.json file must include @sveltejs/kit, svelte and vite as devDependencies.
package.json
svelte.config.js
This file contains your Svelte and SvelteKit configuration:svelte.config.js
tsconfig.json
This file (orjsconfig.json, if you prefer type-checked .js files over .ts files) configures TypeScript.
Since SvelteKit relies on certain configuration being set a specific way, it generates its own .svelte-kit/tsconfig.json file which your own config extends.
tsconfig.json
vite.config.js
A SvelteKit project is really just a Vite project that uses the@sveltejs/kit/vite plugin:
vite.config.js
Generated files
.svelte-kit
As you develop and build your project, SvelteKit will generate files in a.svelte-kit directory (configurable as outDir). You can ignore its contents, and delete them at any time (they will be regenerated when you next dev or build).