sveltekit-structure

Guide SvelteKit project structure with routing, layouts, and SSR conventions.

Updated Nov 7, 2025
One-click install
npx skills add https://github.com/junwonp/portfolio --skill sveltekit-structure-junwonp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sveltekit-structure
Source: https://github.com/junwonp/portfolio/tree/main/.agents/skills/sveltekit-structure
Command: npx skills add https://github.com/junwonp/portfolio --skill sveltekit-structure-junwonp

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

SvelteKit project structure guidance helps teams apply consistent routing, layout, and hydration practices to scale apps.

Core Features & Use Cases

  • File naming conventions for pages, layouts, and errors (+page.svelte, +layout.svelte, +error.svelte, +server.ts)
  • Nested layouts and layout groups to compose UIs without URL changes
  • Error handling patterns and SSR hydration guidelines for robust apps

Quick Start

Create a minimal SvelteKit project demonstrating root +layout and nested +page routes to illustrate the recommended structure.

Frequently Asked Questions about sveltekit-structure

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a SvelteKit project with routing and layouts?

SvelteKit routing uses file-based naming conventions where +page.svelte defines routes and +layout.svelte wraps them. This guide prescribes a quick-start skeleton to scaffold multi-route apps with nested layouts and error boundaries.

What are SvelteKit layout groups and when do I need them?

SvelteKit layout groups let you compose UIs without URL changes. You need them when multiple routes share a layout but should not alter the URL path, enabling nested layout composition for scalable interfaces.

How does SSR hydration work in SvelteKit?

SSR hydration in SvelteKit attaches interactivity to server-rendered HTML. This guide provides hydration guidelines and patterns to ensure robust apps during scaffolding and maintenance without mismatches.

Can I use +server.ts for API routes in SvelteKit?

Yes, +server.ts files create API routes in SvelteKit. This naming convention defines server-side endpoints within your project structure, handling requests alongside pages and layouts for full-stack capabilities.

What is the best way to handle errors in SvelteKit routing?

Use +error.svelte files to handle errors in SvelteKit routing. This guide provides error handling patterns that act as error boundaries within your layout structure, catching load failures and rendering fallback UI.

Why are my SvelteKit nested layouts not applying to child routes?

SvelteKit nested layouts fail when file naming conventions are incorrect. Ensure +layout.svelte files are placed in the correct directory hierarchy to wrap child +page.svelte routes, establishing a consistent structure for scalable apps.