$npx -y skills add getsentry/sentry-for-ai --skill sentry-svelte-sdkFull Sentry SDK setup for Svelte and SvelteKit. Use when asked to "add Sentry to Svelte", "add Sentry to SvelteKit", "install @sentry/sveltekit", or configure error monitoring, tracing, session replay, or logging for Svelte or SvelteKit applications.
| 1 | > [All Skills](../../SKILL_TREE.md) > [SDK Setup](../sentry-sdk-setup/SKILL.md) > Svelte SDK |
| 2 | |
| 3 | # Sentry Svelte SDK |
| 4 | |
| 5 | Opinionated wizard that scans your project and guides you through complete Sentry setup for Svelte and SvelteKit. |
| 6 | |
| 7 | ## Invoke This Skill When |
| 8 | |
| 9 | - User asks to "add Sentry to Svelte" or "set up Sentry" in a Svelte/SvelteKit app |
| 10 | - User wants error monitoring, tracing, session replay, or logging in Svelte or SvelteKit |
| 11 | - User mentions `@sentry/svelte`, `@sentry/sveltekit`, or Sentry SDK for Svelte |
| 12 | |
| 13 | > **Note:** SDK versions and APIs below reflect current Sentry docs at time of writing (`@sentry/sveltekit` ≥10.8.0, SvelteKit ≥2.31.0). |
| 14 | > Always verify against [docs.sentry.io/platforms/javascript/guides/sveltekit/](https://docs.sentry.io/platforms/javascript/guides/sveltekit/) before implementing. |
| 15 | |
| 16 | --- |
| 17 | |
| 18 | ## Phase 1: Detect |
| 19 | |
| 20 | Run these commands to understand the project before making any recommendations: |
| 21 | |
| 22 | ```bash |
| 23 | # Detect framework type |
| 24 | cat package.json | grep -E '"svelte"|"@sveltejs/kit"|"@sentry/svelte"|"@sentry/sveltekit"' |
| 25 | |
| 26 | # Check for SvelteKit indicators |
| 27 | ls svelte.config.js svelte.config.ts vite.config.ts vite.config.js 2>/dev/null |
| 28 | |
| 29 | # Check SvelteKit version (determines which setup pattern to use) |
| 30 | cat package.json | grep '"@sveltejs/kit"' |
| 31 | |
| 32 | # Check if Sentry is already installed |
| 33 | cat package.json | grep '"@sentry/' |
| 34 | |
| 35 | # Check existing hook files |
| 36 | ls src/hooks.client.ts src/hooks.client.js src/hooks.server.ts src/hooks.server.js \ |
| 37 | src/instrumentation.server.ts 2>/dev/null |
| 38 | |
| 39 | # Detect logging libraries (Node side) |
| 40 | cat package.json | grep -E '"pino"|"winston"|"consola"' |
| 41 | |
| 42 | # Detect if there's a backend (Go, Python, Ruby, etc.) in adjacent directories |
| 43 | ls ../backend ../server ../api 2>/dev/null |
| 44 | cat ../go.mod ../requirements.txt ../Gemfile 2>/dev/null | head -3 |
| 45 | ``` |
| 46 | |
| 47 | **What to determine:** |
| 48 | |
| 49 | | Question | Impact | |
| 50 | |----------|--------| |
| 51 | | `@sveltejs/kit` in `package.json`? | SvelteKit path vs. plain Svelte path | |
| 52 | | SvelteKit ≥2.31.0? | Modern (`instrumentation.server.ts`) vs. legacy setup | |
| 53 | | `@sentry/sveltekit` already present? | Skip install, go straight to feature config | |
| 54 | | `vite.config.ts` present? | Source map upload via Vite plugin available | |
| 55 | | Backend directory found? | Trigger Phase 4 cross-link suggestion | |
| 56 | |
| 57 | --- |
| 58 | |
| 59 | ## Phase 2: Recommend |
| 60 | |
| 61 | Present a concrete recommendation based on what you found. Don't ask open-ended questions — lead with a proposal: |
| 62 | |
| 63 | **Recommended (core coverage):** |
| 64 | - ✅ **Error Monitoring** — always; auto-captures unhandled errors on client and server |
| 65 | - ✅ **Tracing** — SvelteKit has both client-side navigation spans and server-side request spans; always recommend |
| 66 | - ✅ **Session Replay** — recommended for user-facing SvelteKit apps (client-side only) |
| 67 | |
| 68 | **Optional (enhanced observability):** |
| 69 | - ⚡ **Logging** — structured logs via `Sentry.logger.*`; recommend when app uses server-side logging or needs log-to-trace correlation |
| 70 | |
| 71 | **Recommendation logic:** |
| 72 | |
| 73 | | Feature | Recommend when... | |
| 74 | |---------|------------------| |
| 75 | | Error Monitoring | **Always** — non-negotiable baseline | |
| 76 | | Tracing | **Always for SvelteKit** (client + server); for plain Svelte when calling APIs | |
| 77 | | Session Replay | User-facing app, login flows, or checkout pages present | |
| 78 | | Logging | App already uses server-side logging, or structured log search is needed | |
| 79 | |
| 80 | Propose: *"I recommend setting up Error Monitoring + Tracing + Session Replay. Want me to also add structured Logging?"* |
| 81 | |
| 82 | --- |
| 83 | |
| 84 | ## Phase 3: Guide |
| 85 | |
| 86 | ### Determine Setup Path |
| 87 | |
| 88 | | Your project | Package | Setup complexity | |
| 89 | |-------------|---------|-----------------| |
| 90 | | SvelteKit (≥2.31.0) | `@sentry/sveltekit` | 5 files to create/modify | |
| 91 | | SvelteKit (<2.31.0) | `@sentry/sveltekit` | 3 files (init in hooks.server.ts) | |
| 92 | | Plain Svelte (no `@sveltejs/kit`) | `@sentry/svelte` | Single entry point | |
| 93 | |
| 94 | --- |
| 95 | |
| 96 | ### Path A: SvelteKit (Recommended — Modern, ≥2.31.0) |
| 97 | |
| 98 | #### Option 1: Wizard (Recommended) |
| 99 | |
| 100 | > **You need to run this yourself** — the wizard opens a browser for login and requires interactive input that the agent can't handle. Copy-paste into your terminal: |
| 101 | > |
| 102 | > ``` |
| 103 | > npx @sentry/wizard@latest -i sveltekit |
| 104 | > ``` |
| 105 | > |
| 106 | > It handles login, org/project selection, SDK installation, client/server hooks, Vite plugin config, source map upload, and adds a `/sentry-example-page`. |
| 107 | > |
| 108 | > **Once it finishes, come back and skip to [Verification](#verification).** |
| 109 | |
| 110 | If the user skips the wizard, proceed with Option 2 (Manual Setup) below. |
| 111 | |
| 112 | #### Option 2: Manual Setup |
| 113 | |
| 114 | **Step 1 — Install** |
| 115 | |
| 116 | ```bash |
| 117 | npm install @sentry/sveltekit --save |
| 118 | ``` |
| 119 | |
| 120 | **Step 2 — `svelte.config.js`** — Enable instrumentation |
| 121 | |
| 122 | ```javascript |
| 123 | import adap |