Svelte Helpers — the AtomForge character at work

@atom-forge/svelte-helpers · Svelte 5

A shared vocabulary for component props.

Svelte Helpers provides prop types, TypeScript constraints, runtime utilities and a snippet-rendering component for Svelte 5. Use it alongside Svelte’s own types; it does not replace the framework’s reactivity.

Svelte 5 TypeScript Snippets Props

What it is

Contracts first, helpers second.

ClassProp, ChildrenProp and ChildrenPropOptional describe the common props. XOR expresses mutually exclusive variants and AtLeastOne requires at least one of a set of properties.

At runtime there are variantMap for boolean variants, debounce and debounceAsync, an as helper for deliberate type assertions, and RenderSnippet for rendering snippets where a component is expected.

Why choose Svelte Helpers?

Intentional prop combinations

XOR and AtLeastOne make invalid combinations a compile-time error.

Snippet-first

The children types match Svelte 5 {@render ...}, not legacy slots.

Type-only imports

Contracts are imported with import type, so they add nothing to the bundle.

How it works

  1. Type the props

    Combine ClassProp and ChildrenProp with your own props.

  2. Constrain the variants

    Use XOR for exclusive options and variantMap to turn them into one value.

  3. Keep it reactive

    Use $derived for values that must follow changing props.

An honest fit check

Trade-offs, not fine print

Compile-time only

XOR, AtLeastOne and type assertions do not validate runtime input.

Svelte 5 only

The helpers assume runes and snippets and are not a drop-in for older Svelte projects.

In practice

Exclusive variants

Type contracts adapted from the package guide.

TypeScript · Illustrative · adapted from the source texts; package API not verified here
import type { XOR, AtLeastOne } from '@atom-forge/svelte-helpers';

type SizeProps = XOR<{ small: true }, { compact: true }, {}>;
type Contact = AtLeastOne<{ email: string; phone: string }>;

const compact: SizeProps = { compact: true };
const contact: Contact = { email: 'ada@example.test' };