npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

svelte-physics-spring

v0.1.0

Published

Composable, physics-accurate springs for Svelte 5 runes apps.

Downloads

2

Readme

svelte-physics-spring

Composable, physics-accurate springs for Svelte 5 runes applications. This package provides a drop-in Spring class built on Svelte's internal runes primitives so you can simulate real-world motion for numbers, arrays, objects, and dates with precise control.

Package metadata

  • Description: Composable, physics-accurate springs for Svelte 5 runes apps.
  • Keywords: svelte, spring, motion, animation, physics, runes

Features

  • Works with primitive values, arrays, nested objects, and Date instances.
  • Resolves set() calls only after the spring settles, enabling async flows.
  • Mirrors the familiar spring API from svelte/motion with added hooks for velocity control.
  • Offers Spring.of helper to couple the spring to any reactive source inside a rune.
  • Zero dependencies beyond Svelte 5.

Installation

npm install svelte-physics-spring
# or
pnpm add svelte-physics-spring

Peer dependency: svelte@^5.0.0. This library relies on runes internals and is not meant for Svelte 3/4.

Quick start

<script>
  import { Spring } from "svelte-physics-spring";

  let target = $state({ x: 0, y: 0 });
  const pointer = Spring.of(() => target, {
    stiffness: 220,
    damping: 28,
  });

  function handlePointerMove(event) {
    target = { x: event.clientX, y: event.clientY };
  }
</script>

<div
  class="cursor"
  on:pointermove={handlePointerMove}
  style={`transform: translate(${pointer.current.x}px, ${pointer.current.y}px);`}
/>

Manual control

If you prefer to manage the lifecycle yourself:

import { Spring } from "svelte-physics-spring";

const opacity = new Spring(0, { damping: 18 });

await opacity.set(1); // resolves when settled
await opacity.set(0.3, { velocity: -0.2 });

Spring.of

Spring.of(() => source, options) evaluates source within a render_effect. Whenever source changes, the spring receives the new value automatically. Use this when pairing springs with $state or $derived signals.

API

new Spring(value, options?)

Creates a spring anchored to the provided value.

| Option | Default | Description | |------------|---------|-------------| | stiffness| 170 | Spring stiffness (higher = snappier). | | damping | 26 | Damping factor (higher = less overshoot). | | mass | 1 | Effective mass of the body. | | precision| 0.01 | Threshold for considering the spring settled. | | velocity | 0 | Initial velocity. Mirrors the value shape. |

spring.set(value, options?)

Returns a promise that resolves when the spring settles. Options:

  • instant: skip animation and jump to value immediately.
  • velocity: override the initial velocity for this transition.

spring.current

Getter returning the animated value. Access within reactive contexts to track updates.

spring.target

Getter/setter for the target value. Writing to target is equivalent to calling set.

Tunables

Each spring exposes accessors for mass, stiffness, damping, and precision. Updating them mid-flight influences the ongoing simulation.

Spring.of(fn, options?)

Creates a spring bound to the result of fn. The return value is the Spring instance. The optional velocity is used whenever fn recomputes, while other options match the constructor.

Development & publishing

# Run the playground app
npm run dev

# Type-check and lint
npm run check
npm run lint

# Package for npm
npm run build   # runs vite build + svelte-package + publint
npm pack        # inspect the tarball before publishing
npm publish

The published package exposes dist/index.js and dist/index.d.ts. Any example pages inside src/routes act as documentation and will not be shipped.

License

MIT © lixiaolin94