Svelte ships several built-in modules that provide standard functionality for state management, animation, transitions, and more.

svelte/store

The svelte/store module provides writable, readable, and derived stores. While Svelte 5 encourages runes over stores for local state, stores remain useful for global state accessed outside .svelte files.

import { writable, derived, readonly } from 'svelte/store'

svelte/transition

Built-in transition functions: fade, fly, slide, scale, blur, crossfade, draw. Custom transitions return CSS keyframes or JavaScript-based animation functions.

svelte/animate

Built-in animation functions for animate: directive. The primary built-in is flip — a FLIP animation for list reordering.

svelte/easing

Easing functions for transitions and animations: linear, easeInOutCubic, backIn, elasticOut, etc. Based on standard easing curves.

svelte/motion

Spring-based motion utilities: spring and tweened stores for physics-based animations. See also the Svelte Motion library for more advanced animations.

svelte/action

The use: directive type definition. Actions are functions that run when elements mount, with update and destroy lifecycle hooks.

svelte/events

Event handling utilities for Svelte components, including event forwarding and custom event creation.

svelte/compiler

The Svelte compiler API, for programmatic compilation of .svelte files. Used by bundler integrations (Vite, Rollup) and build tools.

svelte/legacy

Legacy compatibility helpers for importing and using Svelte 4 components in Svelte 5.

svelte/reactivity

Reactivity primitives for use outside components. SvelteReactivity provides custom reactivity adapters.

svelte/server

Server-side rendering utilities. render() for SSR, ServerComponentNode for server-side component trees.

svelte/attachments

Utilities for Svelte 5 attachments ({@attach}).

Diagnostics

  • svelte/compiler produces compiler errors and warnings with codes for tooling integration
  • Runtime errors and warnings provide diagnostic information during development

Best Practices

  • Prefer runes over stores for component-state
  • Use TypeScript for type-safe store and context interactions
  • Custom elements (<svelte:options customElement="my-component" />) for framework-agnostic component distribution
  • Testing with Vitest + svelte/compiler for component unit tests

See Also