sveltekit-structure

Specify SvelteKit routing, layouts, error handling, and SSR file structures.

218|21|Updated Nov 11, 2025
One-click install
npx skills add https://github.com/spences10/svelte-claude-skills --skill sveltekit-structure
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sveltekit-structure
Source: https://github.com/spences10/svelte-claude-skills/tree/main/.claude/skills/sveltekit-structure
Command: npx skills add https://github.com/spences10/svelte-claude-skills --skill sveltekit-structure

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Navigating SvelteKit's file-based routing, layouts, and error handling can be complex. This skill provides clear, concise guidance to structure your SvelteKit applications correctly, reducing development time and preventing common architectural mistakes.

Core Features & Use Cases

  • File Naming Conventions: Understand +page, +layout, +error, and +server files.
  • Nested Layouts & Groups: Implement complex UI structures and authentication boundaries effortlessly.
  • Error Handling: Correctly place error boundaries (+error.svelte) to catch and display errors gracefully.
  • SSR & Hydration: Learn how to write code that works seamlessly across server and client environments.
  • Use Case: Quickly set up a new SvelteKit project with nested layouts for authenticated and public routes, ensuring proper error handling and SSR compatibility from the start.

Quick Start

Help me structure a SvelteKit application with a root layout, a dashboard layout, and an admin layout. Show me how to implement error boundaries for a specific route.

Frequently Asked Questions about sveltekit-structure

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

FAQPage Schema
How do I organize routing and layouts in a SvelteKit application?

SvelteKit uses file-based routing with `+page.svelte` for pages, `+layout.svelte` for layouts, and `+server.js` for API routes. Nest these files in directories to create route hierarchies; layouts automatically wrap child pages and inherit down the routing tree.

What's the correct way to implement error handling in SvelteKit?

Place `+error.svelte` files at any routing level to create error boundaries that catch and display errors for that route and its children. Error boundaries inherit down the layout tree, so root-level `+error.svelte` catches unhandled errors across your entire app.

How do I structure nested layouts for authentication in SvelteKit?

Use route groups and nested `+layout.svelte` files to create authentication boundaries. Place `+layout.server.js` at each level to load user data and redirect unauthenticated requests, ensuring protected routes only render for authorized users.

What's the difference between `+page` and `+server` files in SvelteKit?

`+page.svelte` renders UI components on the client; `+server.js` handles server-only logic like API requests and database access. Use `+server.js` for sensitive operations and `+page.svelte` to display results.

How does SSR and hydration work in SvelteKit routing?

SvelteKit renders pages on the server first, sending HTML to the browser, then hydrates with JavaScript to make pages interactive. Write code that works in both environments—avoid browser-only APIs in `+layout.svelte` or `+page.svelte` during server rendering.

Can I use layout groups to organize routes without affecting the URL structure?

Yes. Wrap route directories in parentheses—`(groupName)`—to organize layouts and shared structure without changing the URL. Groups let you apply different `+layout.svelte` files to separate route sections independently.