Welcome to Sveltick! This is a super lightweight 🦋 and fun performance&traffic-tracking library for your Svelte apps.
✅ v5 Svelte support
onMount but also afterUpdate and use this code in our src/+layout.svelte for tracking traffic.Install Sveltick via npm:
npm install sveltick
Install Sveltick via yarn:
yarn add sveltick
Import Sveltick into your Svelte app and start tracking your app's performance!
import { onMount } from 'svelte';
import { runPerformanceTracker } from 'sveltick';
onMount(() => {
// Run the performance tracker with custom options
runPerformanceTracker({
trackMetrics: true, // Track all metrics
showAlerts: true, // Enable alerts
enableGamification: true, // Enable gamification
thresholds: {
fcp: 1800, // Custom threshold for FCP
lcp: 2300, // Custom threshold for LCP
tti: 2800, // Custom threshold for TTI
cls: 0.15, // Custom threshold for CLS
fid: 100, // Custom threshold for FID
inp: 200, // Custom threshold for INP
ttfb: 800, // Custom threshold for TTFB
componentRenderTime: 400 // Custom threshold for component render time
}
});
});
📌 Note:
The thresholds object is optional, and each metric has a default value. If you don't provide a custom threshold for a particular metric, the following default values will be used:
First Contentful Paint, 🕒Time to Interactive, 📏Largest Contentful Paint & 📊 Cumulative Layout Shift, 🖱️ First Input Delay, 🖌️ Interaction to Next Paint, 📡 Time to First Byte<script>
import { onMount } from 'svelte';
import { trackFirstContentfulPaint, trackTimeToInteractive, trackLargestContentfulPaint, trackCumulativeLayoutShift, trackFirstInputDelay, trackInteractionToNextPaint, trackTimeToFirstByte } from 'sveltick';
onMount(async () => {
const ftp = await trackFirstContentfulPaint()
const tti = await trackTimeToInteractive()
const lcp = await trackLargestContentfulPaint();
const cls = await trackCumulativeLayoutShift();
const fid = await trackFirstInputDelay();
const inp = await trackInteractionToNextPaint();
const ttfb = await trackTimeToFirstByte();
console.log(ftp, tti, lcp, cls, fid, inp, ttfb)
});
</script>
Component Render Times import { onMount } from 'svelte';
import { trackComponentRender } from 'sveltick';
onMount(() => {
const now = performance.now(); // Measure render time
const { name, renderTime } = trackComponentRender('YourComponent', now); // Get the name and render time
console.log(name, renderTime);
});
You can access all performance metrics (including components one) at any point using:
import { onMount } from 'svelte';
import { trackComponentRender, getPerformanceMetrics } from 'sveltick';
onMount(async () => {
const now = performance.now(); // Measure render time
trackComponentRender('YourComponent', now); // Get the name and render time
const metrics = await getPerformanceMetrics();
console.log(metrics)
});
import { onMount } from 'svelte';
import { getPerformanceMetrics, checkPerformanceAlerts } from 'sveltick';
onMount(async () => {
const metrics = await getPerformanceMetrics();
console.log('Updated Performance Metrics:', metrics);
// Check for any performance alerts with custom thresholds
checkPerformanceAlerts({
fcp: 1800, // Custom threshold for FCP
lcp: 2300, // Custom threshold for LCP
tti: 2800, // Custom threshold for TTI
cls: 0.15, // Custom threshold for CLS
fid: 100, // Custom threshold for FID
inp: 200, // Custom threshold for INP
ttfb: 800, // Custom threshold for TTFB
componentRenderTime: 400 // Custom threshold for component render time
});
});
import { onMount } from 'svelte';
import { runGamification } from 'sveltick';
onMount(() => {
// Run the gamification logic
runGamification();
});
For the best experience we need to use onMount but also afterUpdate and use this code in our src/+layout.svelte.
import { onMount, afterUpdate } from 'svelte';
import { trackAllActivities } from 'sveltick';
// Track all activities on component mount and update
let trackedData = {};
// This function will track and log activities when the component is mounted
onMount(() => {
trackedData = trackAllActivities();
console.log('Tracked Data on Mount:', trackedData);
});
// This function will track and log activities every time the component is updated
afterUpdate(() => {
trackedData = trackAllActivities();
console.log('Tracked Data after Update:', trackedData);
});
import { onMount, afterUpdate } from 'svelte';
import { trackAllActivities, getPageViews } from 'sveltick';
let pageViews = 0;
let trackedData = {};
// This function will track and log activities when the component is mounted
onMount(() => {
trackedData = trackAllActivities();
pageViews = getPageViews();
console.log(pageViews)
});
// This function will track and log activities every time the component is updated
afterUpdate(() => {
trackedData = trackAllActivities();
pageViews = getPageViews();
console.log(pageViews)
});
import { onMount, afterUpdate } from 'svelte';
import { trackAllActivities, getUniqueVisitors } from 'sveltick';
let uniqueVisitors = 0;
let trackedData = {};
// This function will track and log activities when the component is mounted
onMount(() => {
trackedData = trackAllActivities();
uniqueVisitors = getUniqueVisitors();
console.log(uniqueVisitors)
});
// This function will track and log activities every time the component is updated
afterUpdate(() => {
trackedData = trackAllActivities();
uniqueVisitors = getUniqueVisitors();
console.log(uniqueVisitors)
});
import { onMount, afterUpdate } from 'svelte';
import { trackAllActivities, getRouteViews } from 'sveltick';
let routeViews = [];
let trackedData = {};
// This function will track and log activities when the component is mounted
onMount(() => {
trackedData = trackAllActivities();
routeViews = getRouteViews();
console.log(routeViews)
});
// This function will track and log activities every time the component is updated
afterUpdate(() => {
trackedData = trackAllActivities();
routeViews = getRouteViews();
console.log(routeViews)
});
Direct, Facebook, Google and Others import { onMount, afterUpdate } from 'svelte';
import { trackAllActivities, getTrafficSources} from 'sveltick';
let trafficSources = {};
let trackedData = {};
// This function will track and log activities when the component is mounted
onMount(() => {
trackedData = trackAllActivities();
trafficSources = getTrafficSources();
console.log(trafficSources)
});
// This function will track and log activities every time the component is updated
afterUpdate(() => {
trackedData = trackAllActivities();
trafficSources = getTrafficSources();
console.log(trafficSources)
});
📌 Note:

For now it is just this simple console info about the project (of course you could implement it into something bigger!). But in the upcoming days I will create a dashboard performance-tracking webapp for this library, where you could use Sveltick from anywhere around the globe! So stay tuned guys!
MIT ©️ Adam Stadnik
$ claude mcp add sveltick \
-- python -m otcore.mcp_server <graph>