Scaffold SvelteKit app with routing and load functions
✓Works with OpenClaudeYou are a SvelteKit specialist. The user wants to scaffold a new SvelteKit application with proper file-based routing and load functions for server-side data fetching.
What to check first
- Run
node --versionto confirm Node.js 16.9+ is installed - Verify
npmorpnpmis available withnpm --version
Steps
- Create a new SvelteKit project using
npm create svelte@latest my-appand select options: Skeleton project, TypeScript, ESLint, Prettier - Navigate into the project with
cd my-appand install dependencies usingnpm install - Create a route directory structure under
src/routes/— each folder becomes a route segment (e.g.,src/routes/blog/becomes/blog) - Add a
+page.sveltefile insrc/routes/for the homepage and insrc/routes/blog/for a blog index route - Create a
+page.js(or+page.tsfor TypeScript) load function insrc/routes/blog/usingexport async function load({ fetch })to fetch server-side data - Define a
+layout.svelteinsrc/routes/for shared layout structure; add a corresponding+layout.jsfor parent route load functions - Use route parameters by creating
src/routes/blog/[slug]/+page.svelteandsrc/routes/blog/[slug]/+page.jswhereload()receivesparams.slug - Start the dev server with
npm run devto test routing athttp://localhost:5173
Code
// src/routes/+page.svelte
<h1>Welcome Home</h1>
<a href="/blog">Read our blog</a>
// src/routes/+page.js
export async function load({ fetch }) {
return {
title: 'Home'
}
}
// src/routes/blog/+page.svelte
<script>
export let data;
</script>
<h1>Blog</h1>
{#each data.posts as post (post.id)}
<article>
<h2><a href="/blog/{post.slug}">{post.title}</a></h2>
<p>{post.excerpt}</p>
</article>
{/each}
// src/routes/blog/+page.js
export async function load({ fetch }) {
const response = await fetch('/api/posts');
const posts = await response.json();
return { posts };
}
// src/routes/blog/[slug]/+page.svelte
<script>
export let data;
</script>
<h1>{data.post.title}</h1>
<p>{data.post.content}</p>
<a href="/blog">← Back to blog</a>
// src/routes/blog/[
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Svelte Skills
Other Claude Code skills in the same category — free to download.
Svelte Component
Create Svelte components with reactivity and stores
Svelte Store
Build Svelte stores for shared state management
Svelte Actions
Create Svelte actions for reusable DOM behavior
Svelte Testing
Test Svelte components with Vitest and Testing Library
Want a Svelte skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.