Sveltekit Structure

spences10/svelte-skills-kit/plugins/svelte-skills/skills/sveltekit-structure

作者 spences102a9d88379bf62cee464a16db852edda7790a58f5无许可证收录于 2026年10月9日更新于 2026年10月9日

SvelteKit structure guidance. Use for routing, layouts, error handling, SSR, or svelte:boundary. Covers file naming, nested layouts, error boundaries, pending UI, and hydration.

AI 生成的概览

SvelteKit 应用结构参考指南:路由、布局、错误处理、SSR 与 hydration。

功能
提供 SvelteKit 项目结构的速查指南,包括 +page.svelte、+layout.svelte、+error.svelte、+server.ts 等文件类型,以及路由与 URL 的对应关系。说明嵌套布局、路由分组、错误边界放置位置、组件级错误与等待界面,以及 SSR 与仅浏览器代码的区别。详细内容放在文件命名、布局模式、错误处理、svelte:boundary 与 SSR/hydration 等参考文件中。
适用场景
适用于组织或审查 SvelteKit 代码库、判断文件与布局应放置的位置,或排查路由、错误边界、SSR 与 hydration 行为时。适合关于 SvelteKit 约定的问题,而非通用 JavaScript 或与框架无关的工作。它是参考资料,不是自动代码生成或检查工具。
运行要求
无需脚本或工具,仅为说明文档与参考文件。

SvelteKit Structure

Quick Start

File types: +page.svelte (page) | +layout.svelte (wrapper) | +error.svelte (error boundary) | +server.ts (API endpoint)

Routes: src/routes/about/+page.svelte → /about | src/routes/posts/[id]/+page.svelte → /posts/123

Layouts: Apply to all child routes. +layout.svelte at any level wraps descendants.

Example

src/routes/├── +layout.svelte              # Root layout (all pages)├── +page.svelte                # Homepage /├── about/+page.svelte          # /about└── dashboard/    ├── +layout.svelte          # Dashboard layout (dashboard pages only)    ├── +page.svelte            # /dashboard    └── settings/+page.svelte   # /dashboard/settings
svelte
<!-- +layout.svelte --><script>	let { children } = $props();</script>
<nav><!-- Navigation --></nav><main>{@render children()}</main><footer><!-- Footer --></footer>

Reference Files

  • file-naming.md [blocked] - File naming conventions
  • layout-patterns.md [blocked] - Nested layouts
  • error-handling.md [blocked] - +error.svelte placement
  • svelte-boundary.md [blocked] - Component-level error/pending
  • ssr-hydration.md [blocked] - SSR and browser-only code

Notes

  • Layouts: {@render children()} | Errors: +error.svelte above failing route
  • Groups: (name) folders don't affect URL | Client-only: check browser
  • Last verified: 2025-01-11
<!-- PROGRESSIVE DISCLOSURE GUIDELINES: - Keep this file ~50 lines total (max ~150 lines) - Use 1-2 code blocks only (recommend 1) - Keep description <200 chars for Level 1 efficiency - Move detailed docs to references/ for Level 3 loading - This is Level 2 - quick reference ONLY, not a manual LLM WORKFLOW (when editing this file): 1. Write/edit SKILL.md 2. Format (if formatter available) 3. Run: npx skills add . --list 4. If the skill is not discovered, check SKILL.md frontmatter formatting 5. Validate again to confirm -->

来源与署名

来源:spences10/svelte-skills-kit位于plugins/svelte-skills/skills/sveltekit-structure提交2a9d883

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架