Skip to content

Commit 06423fe

Browse files
docs(js): Create SvelteKit Quick Start guide (Wizard setup) (#13480)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR Reworked the SvelteKit Getting Started guide into a Quick Start guide (for wizard setup). closes: #13398 ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
1 parent 5ce5721 commit 06423fe

File tree

2 files changed

+60
-76
lines changed

2 files changed

+60
-76
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: SvelteKit
3+
description: "Learn how to set up and configure Sentry in your SvelteKit application using the installation wizard, capture your first errors, and view them in Sentry."
34
sdk: sentry.javascript.sveltekit
45
categories:
56
- javascript
@@ -8,110 +9,71 @@ categories:
89
- server-node
910
---
1011

11-
Sentry's SvelteKit SDK enables automatic reporting of errors and performance data.
12-
13-
## Compatibility
14-
15-
The minimum supported SvelteKit version is `2.0.0`.
16-
This SDK works best with **Vite 4.2** and newer. Older Vite versions might not generate source maps correctly.
17-
18-
<Alert>
19-
20-
The SvelteKit SDK is designed to work out of the box with the following SvelteKit adapters:
21-
22-
- [Adapter-auto](https://kit.svelte.dev/docs/adapter-auto) - for Vercel; other platforms might work but we don't guarantee compatibility at this time.
23-
- [Adapter-vercel](https://kit.svelte.dev/docs/adapter-vercel) - only for Node (Lambda) runtimes, not yet Vercel's edge runtime.
24-
- [Adapter-cloudflare](https://kit.svelte.dev/docs/adapter-cloudflare) - supported but requires [additional Setup](/platforms/javascript/guides/cloudflare/frameworks/sveltekit/).
25-
- [Adapter-node](https://kit.svelte.dev/docs/adapter-node).
26-
27-
Other adapters may work but aren't currently supported.
28-
We're looking into extending first-class support to [more adapters](https://kit.svelte.dev/docs/adapters) in the future.
29-
30-
The SvelteKit SDK does not yet work with all non-node server runtimes, such as Vercel's edge runtime.
31-
32-
</Alert>
33-
3412
<PlatformContent includePath="getting-started-prerequisites" />
3513

36-
## Install
14+
## Step 1: Install
3715

38-
Sentry captures data by using an SDK within your application’s runtime.
39-
40-
We recommend installing the SDK by running our installation wizard in the root directory of your project:
16+
To install Sentry using the installation wizard, run the following command within your project:
4117

4218
```bash
4319
npx @sentry/wizard@latest -i sveltekit
4420
```
4521

46-
The wizard will prompt you to log in to Sentry. It will then automatically do the following steps for you:
47-
48-
- create or update SvelteKit files with the default Sentry configuration:
49-
- `hooks.(client|server).js` to initialize the SDK and instrument [SvelteKit's hooks](https://kit.svelte.dev/docs/hooks)
50-
- `vite.config.js` to add source maps upload and auto-instrumentation via Vite plugins.
51-
- create a `.sentryclirc` file with an auth token to upload source maps (this file is automatically added to `.gitignore`)
52-
- add an example page to your app to verify your Sentry setup
22+
The wizard then guides you through the setup process, asking you to enable additional (optional) Sentry features for your application beyond error monitoring.
5323

54-
After the wizard setup is completed, the SDK will automatically capture unhandled errors, and monitor performance.
55-
You can also <PlatformLink to="/usage/">manually capture errors</PlatformLink>.
24+
<PlatformContent includePath="getting-started-features-expandable" />
5625

57-
<Alert>
26+
This guide assumes that you enable all features and allow the wizard to create an example page. You can add or remove features at any time, but setting them up now will save you the effort of configuring them manually later.
5827

59-
If the setup through the wizard doesn't work for you, you can also <PlatformLink to="/manual-setup/">set up the SDK manually</PlatformLink>.
28+
<Expandable title="What does the installation wizard change inside your application?">
6029

61-
</Alert>
30+
- Creates or updates `hooks.(client|server).js` to initialize the SDK and instrument [SvelteKit's hooks](https://kit.svelte.dev/docs/hooks)
31+
- Creates or updates `vite.config.js` to add source maps upload and auto-instrumentation via Vite plugins
32+
- Creates `.sentryclirc` with an auth token to upload source maps (this file is automatically added to `.gitignore`)
33+
- Adds an example page to your application to help verify your Sentry setup
6234

63-
## Configure
35+
</Expandable>
6436

65-
Configuration should happen as early as possible in your application's lifecycle.
37+
## Step 2: Verify Your Setup
6638

67-
To complete your configuration, add <PlatformLink to="/configuration/options/">options</PlatformLink> to your `Sentry.init()` calls.
68-
Here you can also set context data - data about the <PlatformLink to="/enriching-events/identify-user/">user</PlatformLink>, for example, or <PlatformLink to="/enriching-events/tags/">tags</PlatformLink>, or even <PlatformLink to="/enriching-events/context/">arbitrary data</PlatformLink> - which will be added to every event sent to Sentry.
39+
If you haven't tested your Sentry configuration yet, let's do it now. You can confirm that Sentry is working properly and sending data to your Sentry project by using the example page and route created by the installation wizard:
6940

41+
1. Open the example page `/sentry-example-page` in your browser
42+
2. Click the "Throw Sample Error" button. This triggers two errors:
43+
- a frontend error
44+
- an error within the API route
7045

71-
## Verify
46+
Sentry captures both of these errors for you. Additionally, the button click starts a trace to measure the time it takes for the API request to complete.
7247

73-
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.
48+
<Alert level="success" title="Tip">
7449

75-
Add a button to a frontend component that throws an error:
76-
77-
```javascript {filename:src/routes/sentry/+page.svelte} {3}
78-
<button
79-
on:click={() => {
80-
throw new Error("Sentry Frontend Error");
81-
}}
82-
>
83-
Throw error
84-
</button>
85-
```
50+
Don't forget to explore the example files' code in your project to understand what's happening after your button click.
8651

87-
Or throw an error in one of your `load` functions:
52+
</Alert>
8853

89-
```javascript {filename:src/routes/sentry/+page.js} {2}
90-
export const load = () => {
91-
throw new Error("Sentry Load Error");
92-
};
93-
```
54+
### View Captured Data in Sentry
9455

95-
Or throw an error in an API route:
56+
Now, head over to your project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear).
9657

97-
```javascript {filename:src/routes/sentry/+server.js} {2}
98-
export const GET = () => {
99-
throw new Error("Sentry API Error");
100-
};
101-
```
58+
<PlatformContent includePath="getting-started-browser-sandbox-warning" />
10259

103-
The possibilities are endless!
60+
<PlatformContent includePath="getting-started-verify-locate-data" />
10461

105-
<Alert>
62+
## Next Steps
10663

107-
Errors triggered from within Browser DevTools are sandboxed and will not trigger error monitoring. Keep this in mind when verifying your Sentry SDK installation.
64+
At this point, you should have integrated Sentry into your SvelteKit application and should already be sending error and performance data to your Sentry project.
10865

109-
</Alert>
66+
Now's a good time to customize your setup and look into more advanced topics.
67+
Our next recommended steps for you are:
11068

111-
<Alert>
69+
- Learn how to [manually capture errors](/platforms/javascript/guides/sveltekit/usage/)
70+
- Continue to [customize your configuration](/platforms/javascript/guides/sveltekit/configuration/)
71+
- Get familiar with [Sentry's product features](/product) like tracing, insights, and alerts
11272

113-
Learn more about manually capturing an error or message in our <PlatformLink to="/usage/">Usage documentation</PlatformLink>.
73+
<Expandable permalink={false} title="Are you having problems setting up the SDK?">
11474

115-
</Alert>
75+
- If you encountered issues with our installation wizard, try [setting up Sentry manually](/platforms/javascript/guides/sveltekit/manual-setup/)
76+
- Find various support topics in [troubleshooting](/platforms/javascript/guides/sveltekit/troubleshooting/)
77+
- [Get support](https://sentry.zendesk.com/hc/en-us/)
11678

117-
To view and resolve the recorded error, log into [sentry.io](https://sentry.io) and select your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
79+
</Expandable>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## Prerequisites
2+
3+
You need:
4+
5+
- A Sentry [account](https://sentry.io/signup/) and [project](/product/projects/)
6+
- Your application up and running
7+
- SvelteKit version `2.0.0`+
8+
- Vite version `4.2`+
9+
10+
<Expandable title="Notes on SvelteKit adapter compatibility">
11+
The SvelteKit Sentry SDK is designed to work out of the box with the following SvelteKit adapters:
12+
13+
- [Adapter-auto](https://kit.svelte.dev/docs/adapter-auto) – for Vercel; other platforms might work but we don't guarantee compatibility at this time
14+
- [Adapter-vercel](https://kit.svelte.dev/docs/adapter-vercel) – only for Node (Lambda) runtimes, not yet Vercel's edge runtime
15+
- [Adapter-cloudflare](https://kit.svelte.dev/docs/adapter-cloudflare) – supported but requires [additional setup](https://docs.sentry.io/platforms/javascript/guides/cloudflare/frameworks/sveltekit/)
16+
- [Adapter-node](https://kit.svelte.dev/docs/adapter-node)
17+
18+
Other adapters may work but aren't currently supported. We're looking into extending first-class support to more adapters in the future.
19+
20+
Also, Sentry's SvelteKit SDK does not yet work with all non-node server runtimes, such as Vercel's edge runtime.
21+
22+
</Expandable>

0 commit comments

Comments
 (0)