Skip to content
← UI Library

Developer quickstart

A two-column onboarding section with numbered setup steps beside a tabbed, copyable code block.

Svelte 5 · Version 1.0.0 · Zero extra packages

Connect MCP

Live preview

Send your first event in under a minute

Install the SDK, add your key and make one request. Every language returns the same response.

  1. Install the SDK npm install relay
  2. Add your API key

    Set RELAY_API_KEY in your environment.

  3. Send an event

    Choose a language and copy the snippet.

send.ts
import { Relay } from 'relay';const relay = new Relay(process.env.RELAY_API_KEY);await relay.events.send({  name: 'signup.completed',  user: 'usr_8f2k1',  properties: { plan: 'pro' }});

Design decision

Show the first useful request with the fewest steps. Resend’s audit illustrates how code helps explain the product.

Resend audit ↗ · Site score 5

Source and integration

Place the files in the same directory and replace the sample SDK and endpoint with your own. Use --ui-section-bg and the shared --ui-* variables to theme the section.

You may copy and adapt this original SaaSCrisp implementation in personal and commercial websites.

CodeSwitcher.svelte
<script module lang="ts">
	type Kind = 'com' | 'str' | 'num' | 'kw' | 'fn' | 'punc' | 'plain';
	export type Token = { kind: Kind; text: string };

	const pattern =
		/((?<![:\w])\/\/.*|(?<!\S)#.*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`)|\b(\d+(?:\.\d+)?)\b|\b(const|let|var|await|async|import|from|export|return|function|new|if|else|def|for|in|of|true|false|null|None|True|False|curl)\b|([A-Za-z_$][\w$]*)(?=\s*\()|([{}()[\].,;:=])/g;
	const kinds: Kind[] = ['com', 'str', 'num', 'kw', 'fn', 'punc'];

	/** Splits one line of code into coloured tokens without using HTML strings. */
	export function tokenize(line: string): Token[] {
		const tokens: Token[] = [];
		let last = 0;
		for (const match of line.matchAll(pattern)) {
			const at = match.index ?? 0;
			if (at > last) tokens.push({ kind: 'plain', text: line.slice(last, at) });
			const group = match.slice(1).findIndex((value) => value !== undefined);
			tokens.push({ kind: kinds[group] ?? 'plain', text: match[0] });
			last = at + match[0].length;
		}
		if (last < line.length) tokens.push({ kind: 'plain', text: line.slice(last) });
		return tokens;
	}
</script>

<script lang="ts">
	type Example = { label: string; code: string; filename?: string };
	let { examples, label = 'Code example' }: { examples: Example[]; label?: string } = $props();

	const id = $props.id();
	let selected = $state(0);
	let copied = $state(false);
	let status = $state('');
	let tabs: HTMLButtonElement[] = $state([]);
	let indicator = $state({ x: 0, width: 0, ready: false });
	let timer: ReturnType<typeof setTimeout> | undefined;

	const active = $derived(examples[selected] ?? examples[0]);
	const lines = $derived(active ? active.code.split('\n').map(tokenize) : []);

	$effect(() => {
		const tab = tabs[selected];
		if (tab) indicator = { x: tab.offsetLeft, width: tab.offsetWidth, ready: true };
	});
	$effect(() => () => clearTimeout(timer));

	function choose(index: number, focus = false) {
		selected = (index + examples.length) % examples.length;
		copied = false;
		status = '';
		if (focus) tabs[selected]?.focus();
	}

	function onkeydown(event: KeyboardEvent) {
		const target: Record<string, number> = {
			ArrowRight: selected + 1,
			ArrowLeft: selected - 1,
			Home: 0,
			End: examples.length - 1
		};
		if (event.key in target) {
			event.preventDefault();
			choose(target[event.key], true);
		}
	}

	async function copy() {
		if (!active) return;
		clearTimeout(timer);
		try {
			await navigator.clipboard.writeText(active.code);
			copied = true;
			status = 'Copied to clipboard';
		} catch {
			copied = false;
			status = 'Copy failed. Select the code to copy it.';
		}
		timer = setTimeout(() => {
			copied = false;
			status = '';
		}, 2000);
	}
</script>

{#if active}
	<div class="cs">
		<div class="cs-head">
			<div class="cs-tabs" role="tablist" aria-label={label}>
				<span
					class="cs-indicator"
					class:ready={indicator.ready}
					style:transform="translateX({indicator.x}px)"
					style:width="{indicator.width}px"
					aria-hidden="true"
				></span>
				{#each examples as example, index (example.label)}
					<button
						bind:this={tabs[index]}
						type="button"
						role="tab"
						id="{id}-tab-{index}"
						aria-selected={index === selected}
						aria-controls="{id}-panel"
						tabindex={index === selected ? 0 : -1}
						onclick={() => choose(index)}
						{onkeydown}>{example.label}</button
					>
				{/each}
			</div>
			<div class="cs-actions">
				{#if active.filename}<span class="cs-file">{active.filename}</span>{/if}
				<button class="cs-copy" class:copied type="button" onclick={copy} aria-label={copied ? 'Copied' : 'Copy code'}>
					<svg class="cs-icon-copy" viewBox="0 0 24 24" aria-hidden="true"
						><rect x="9" y="9" width="12" height="12" rx="2.5" /><path d="M5 15H4.5A1.5 1.5 0 0 1 3 13.5v-9A1.5 1.5 0 0 1 4.5 3h9A1.5 1.5 0 0 1 15 4.5V5" /></svg
					>
					<svg class="cs-icon-check" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5" /></svg>
				</button>
			</div>
		</div>
		<div class="cs-body" role="tabpanel" id="{id}-panel" aria-labelledby="{id}-tab-{selected}" tabindex="0">
			{#key selected}
				<pre class="cs-code"><code>{#each lines as line, number}<span class="cs-line"><span class="cs-ln" aria-hidden="true">{number + 1}</span><span>{#each line as token}<span class="t-{token.kind}">{token.text}</span>{/each}</span></span>{/each}</code></pre>
			{/key}
		</div>
		<span class="cs-sr" role="status">{status}</span>
	</div>
{/if}

<style>
	.cs {
		--_bg: var(--ui-bg, #0b0b0d);
		--_border: var(--ui-border, rgb(255 255 255 / 0.08));
		--_text: var(--ui-text, #ededf0);
		--_muted: var(--ui-muted, #8b8b94);
		--_accent: var(--ui-accent, #c8ff3c);
		position: relative;
		overflow: hidden;
		border: 1px solid var(--_border);
		border-radius: var(--ui-radius, 14px);
		background:
			radial-gradient(120% 80% at 0% 0%, rgb(255 255 255 / 0.035), transparent 50%),
			var(--_bg);
		color: var(--_text);
		font-family: var(--ui-font, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif);
		box-shadow:
			inset 0 1px 0 rgb(255 255 255 / 0.04),
			0 1px 2px rgb(0 0 0 / 0.4),
			0 16px 40px -16px rgb(0 0 0 / 0.7);
		text-align: left;
	}
	.cs::before {
		content: '';
		position: absolute;
		inset: 0 10% auto;
		height: 1px;
		background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.2), transparent);
	}
	.cs-head {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 12px;
		padding: 6px 6px 6px 8px;
		border-bottom: 1px solid var(--_border);
		background: rgb(255 255 255 / 0.015);
	}
	.cs-tabs {
		position: relative;
		display: flex;
		gap: 2px;
		min-width: 0;
		overflow-x: auto;
		scrollbar-width: none;
	}
	.cs-indicator {
		position: absolute;
		inset: 0 auto 0 0;
		border-radius: 8px;
		background: rgb(255 255 255 / 0.07);
		box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.06);
	}
	.cs-indicator.ready {
		transition:
			transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
			width 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
	}
	.cs-tabs button {
		position: relative;
		border: 0;
		border-radius: 8px;
		padding: 6px 12px;
		background: none;
		color: var(--_muted);
		font-family: inherit;
		font-size: 13px;
		font-weight: 500;
		line-height: 1.3;
		white-space: nowrap;
		cursor: pointer;
		transition: color 0.15s;
	}
	.cs-tabs button:hover,
	.cs-tabs button[aria-selected='true'] {
		color: var(--_text);
	}
	.cs-actions {
		display: flex;
		flex-shrink: 0;
		align-items: center;
		gap: 10px;
	}
	.cs-file {
		color: var(--_muted);
		font: 12px/1 var(--ui-mono, ui-monospace, 'SF Mono', Menlo, monospace);
	}
	.cs-copy {
		position: relative;
		display: grid;
		place-items: center;
		width: 30px;
		height: 30px;
		border: 1px solid var(--_border);
		border-radius: 8px;
		background: rgb(255 255 255 / 0.02);
		color: var(--_muted);
		cursor: pointer;
		transition:
			color 0.15s,
			background-color 0.15s,
			border-color 0.15s;
	}
	.cs-copy:hover {
		background: rgb(255 255 255 / 0.06);
		color: var(--_text);
	}
	.cs-copy svg {
		grid-area: 1 / 1;
		width: 15px;
		height: 15px;
		fill: none;
		stroke: currentColor;
		stroke-width: 1.8;
		stroke-linecap: round;
		stroke-linejoin: round;
		transition:
			opacity 0.18s,
			transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
	}
	.cs-icon-check {
		opacity: 0;
		transform: scale(0.6);
		color: var(--_accent);
	}
	.copied .cs-icon-copy {
		opacity: 0;
		transform: scale(0.6);
	}
	.copied .cs-icon-check {
		opacity: 1;
		transform: none;
	}
	.cs-tabs button:focus-visible,
	.cs-copy:focus-visible,
	.cs-body:focus-visible {
		outline: 2px solid var(--_accent);
		outline-offset: -2px;
	}
	.cs-body {
		max-height: var(--ui-code-max-height, 22rem);
		overflow: auto;
	}
	.cs-code {
		min-width: max-content;
		margin: 0;
		padding: 14px 20px 14px 0;
		font: 13px/1.75 var(--ui-mono, ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace);
		tab-size: 2;
		animation: cs-in 0.22s ease-out;
	}
	.cs-line {
		display: block;
	}
	.cs-ln {
		display: inline-block;
		width: 3rem;
		padding-right: 1.15rem;
		color: rgb(255 255 255 / 0.18);
		text-align: right;
		user-select: none;
	}
	.t-plain {
		color: var(--_text);
	}
	.t-kw {
		color: #c4b5fd;
	}
	.t-str {
		color: #d9f99d;
	}
	.t-num {
		color: #fdba74;
	}
	.t-fn {
		color: #93c5fd;
	}
	.t-punc {
		color: #8b8b94;
	}
	.t-com {
		color: #5b5b66;
		font-style: italic;
	}
	.cs-sr {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}
	@keyframes cs-in {
		from {
			opacity: 0;
			transform: translateY(3px);
		}
	}
	@media (prefers-reduced-motion: reduce) {
		.cs-code {
			animation: none;
		}
		.cs-indicator.ready,
		.cs-copy svg {
			transition: none;
		}
	}
</style>
Quickstart.svelte
<script lang="ts">
	import CodeSwitcher from './CodeSwitcher.svelte';

	const examples = [
		{
			label: 'Node.js',
			filename: 'send.ts',
			code: [
				"import { Relay } from 'relay';",
				'',
				'const relay = new Relay(process.env.RELAY_API_KEY);',
				'',
				'await relay.events.send({',
				"  name: 'signup.completed',",
				"  user: 'usr_8f2k1',",
				"  properties: { plan: 'pro' }",
				'});'
			].join('\n')
		},
		{
			label: 'Python',
			filename: 'send.py',
			code: [
				'import os',
				'from relay import Relay',
				'',
				'relay = Relay(os.environ["RELAY_API_KEY"])',
				'',
				'relay.events.send(',
				'    name="signup.completed",',
				'    user="usr_8f2k1",',
				'    properties={"plan": "pro"},',
				')'
			].join('\n')
		},
		{
			label: 'cURL',
			filename: 'terminal',
			code: [
				'curl https://api.relay.dev/v1/events \\',
				'  -H "Authorization: Bearer $RELAY_API_KEY" \\',
				'  -H "Content-Type: application/json" \\',
				`  -d '{"name": "signup.completed", "user": "usr_8f2k1"}'`
			].join('\n')
		}
	];

	const steps = [
		{ title: 'Install the SDK', detail: 'npm install relay', code: true },
		{ title: 'Add your API key', detail: 'Set RELAY_API_KEY in your environment.', code: false },
		{ title: 'Send an event', detail: 'Choose a language and copy the snippet.', code: false }
	];
</script>

<section class="qs">
	<div class="qs-grid">
		<div class="qs-copy">
			<h2>Send your first event in under a minute</h2>
			<p class="qs-lede">Install the SDK, add your key and make one request. Every language returns the same response.</p>
			<ol>
				{#each steps as step, index (step.title)}
					<li>
						<span class="qs-num" aria-hidden="true">{index + 1}</span>
						<div>
							<strong>{step.title}</strong>
							{#if step.code}<code>{step.detail}</code>{:else}<p>{step.detail}</p>{/if}
						</div>
					</li>
				{/each}
			</ol>
		</div>
		<CodeSwitcher {examples} label="Quickstart language" />
	</div>
</section>

<style>
	.qs {
		--_bg: var(--ui-section-bg, #09090b);
		--_border: var(--ui-border, rgb(255 255 255 / 0.08));
		--_text: var(--ui-text, #ededf0);
		--_muted: var(--ui-muted, #8b8b94);
		--_accent: var(--ui-accent, #c8ff3c);
		position: relative;
		container-type: inline-size;
		overflow: hidden;
		padding: clamp(20px, 5vw, 48px);
		border: 1px solid var(--_border);
		border-radius: var(--ui-section-radius, 24px);
		background: var(--_bg);
		color: var(--_text);
		font-family: var(--ui-font, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif);
		text-align: left;
	}
	.qs::before {
		content: '';
		position: absolute;
		inset: 0;
		background-image:
			linear-gradient(rgb(255 255 255 / 0.035) 1px, transparent 1px),
			linear-gradient(90deg, rgb(255 255 255 / 0.035) 1px, transparent 1px);
		background-size: 32px 32px;
		mask-image: radial-gradient(70% 60% at 70% 20%, #000, transparent);
		pointer-events: none;
	}
	.qs::after {
		content: '';
		position: absolute;
		top: -30%;
		right: -10%;
		width: 60%;
		aspect-ratio: 1;
		background: radial-gradient(closest-side, color-mix(in srgb, var(--_accent) 10%, transparent), transparent);
		pointer-events: none;
	}
	.qs-grid {
		position: relative;
		z-index: 1;
		display: grid;
		gap: 32px;
	}
	@container (min-width: 760px) {
		.qs-grid {
			grid-template-columns: 0.9fr 1.1fr;
			align-items: center;
			gap: 48px;
		}
	}
	h2 {
		max-width: 18ch;
		margin: 0;
		color: var(--_text);
		font-size: clamp(26px, 4cqi, 38px);
		font-weight: 600;
		letter-spacing: -0.03em;
		line-height: 1.1;
	}
	.qs-lede {
		max-width: 44ch;
		margin: 14px 0 0;
		color: var(--_muted);
		font-size: 15px;
		line-height: 1.6;
	}
	ol {
		position: relative;
		display: grid;
		gap: 20px;
		margin: 28px 0 0;
		padding: 0;
		list-style: none;
	}
	ol::before {
		content: '';
		position: absolute;
		top: 14px;
		bottom: 14px;
		left: 13px;
		width: 1px;
		background: linear-gradient(var(--_border), var(--_border) 70%, transparent);
	}
	li {
		position: relative;
		display: flex;
		gap: 14px;
	}
	.qs-num {
		display: grid;
		flex-shrink: 0;
		place-items: center;
		width: 27px;
		height: 27px;
		border: 1px solid var(--_border);
		border-radius: 50%;
		background: var(--_bg);
		box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06);
		color: var(--_text);
		font-size: 12px;
		font-weight: 600;
		font-variant-numeric: tabular-nums;
	}
	li strong {
		display: block;
		padding-top: 3px;
		font-size: 14px;
		font-weight: 600;
	}
	li p {
		margin: 3px 0 0;
		color: var(--_muted);
		font-size: 14px;
	}
	li code {
		display: inline-block;
		margin-top: 6px;
		padding: 3px 8px;
		border: 1px solid var(--_border);
		border-radius: 6px;
		background: rgb(255 255 255 / 0.04);
		color: var(--_text);
		font: 12.5px/1.5 var(--ui-mono, ui-monospace, 'SF Mono', Menlo, monospace);
	}
</style>
Agent prompt

Use the SaaSCrisp UI Library MCP at https://www.saascrisp.com/api/library/mcp. Retrieve developer-quickstart version 1.0.0 for svelte with get_ui_asset. Preview: https://www.saascrisp.com/library/developer-quickstart. Confirm the project's stack, reuse local primitives and map CSS variables to existing design tokens. Integrate the files and run the project's checks. Report changed files and additional dependencies.