Getting Started with SvelteKit

Getting Started with SvelteKit

SvelteKit is a framework for building web applications of all sizes, with a beautiful development experience and flexible filesystem-based routing.

Why SvelteKit?

SvelteKit provides a great developer experience with:

  • File-based routing - Create routes by adding files to your src/routes directory
  • Server-side rendering - Built-in SSR for better performance and SEO
  • API routes - Create API endpoints alongside your pages
  • Hot module replacement - Fast development with instant updates

Getting Started

To create a new SvelteKit project:

npm create svelte@latest my-app
cd my-app
npm install
npm run dev

Key Concepts

Pages

Pages are Svelte components that live in src/routes. The filename determines the route:

  • src/routes/+page.svelte/
  • src/routes/about/+page.svelte/about
  • src/routes/blog/[slug]/+page.svelte/blog/hello-world

Layouts

Layouts wrap pages and provide shared UI. Use +layout.svelte files to create layouts that apply to multiple pages.

Loading Data

Use +page.server.ts or +page.ts to load data for your pages.

This is just the beginning of what SvelteKit can do. The framework is designed to be simple yet powerful, making it perfect for both small projects and large applications.