@flareapp/sveltekit
v2.3.0
Published
SvelteKit integration for flareapp.io
Readme
@flareapp/sveltekit
SvelteKit integration for Flare error tracking and logging. Wraps SvelteKit's client and server
handleError hooks to report unexpected errors with route context. Also provides manual capture helpers and route
tracking for browser-side reports.
Installation
npm install @flareapp/sveltekit @flareapp/jsQuick start
Set up Flare in your SvelteKit hooks:
// src/hooks.client.ts
import { dev } from '$app/environment';
import { flare } from '@flareapp/js';
import { handleErrorWithFlare } from '@flareapp/sveltekit/client';
if (!dev) {
flare.light('YOUR_FLARE_API_KEY');
}
export const handleError = handleErrorWithFlare();// src/hooks.server.ts
import { dev } from '$app/environment';
import { flare } from '@flareapp/js';
import { handleErrorWithFlare } from '@flareapp/sveltekit/server';
if (!dev) {
flare.light('YOUR_FLARE_API_KEY');
}
export const handleError = handleErrorWithFlare();Logging
Beyond errors, the client can send structured logs. Logs are opt-in: enable them with enableLogs, then call any of the
eight syslog levels (debug, info, notice, warning, error, critical, alert, emergency).
import { flare } from '@flareapp/js';
flare.configure({ enableLogs: true });
flare.logger.info('Checkout started', { cartId: cart.id, total: cart.total });Documentation
Full documentation on handleErrorWithFlare, captureError, trackRouteContext, lifecycle callbacks, and more is
available at flareapp.io/docs/svelte/general/installation.
Compatibility
- Svelte 5.3+
- SvelteKit 2.12+
License
The MIT License (MIT). Please see License File for more information.
