# use-spring

> [![](https://badgen.net/bundlephobia/minzip/use-spring)](https://bundlephobia.com/result?p=use-spring) ![](https://badgen.net/david/dep/pomber/use-spring) ![](https://badgen.net/npm/types/use-spring)

Latest version **0.2.4** (published 2021-06-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-spring
pnpm add use-spring
yarn add use-spring
bun add use-spring
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.4 |
| Published | 2021-06-17 |
| First published | 2019-09-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 59.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 56 |
| Author | Rodrigo Pombo |
| Maintainers | pomber |
| Keywords | react, hook, spring, physics, motion, animation, transition |

## Links

- npm: https://www.npmjs.com/package/use-spring
- Repository: https://github.com/pomber/use-spring
- Homepage: https://github.com/pomber/use-spring#readme
- Issues: https://github.com/pomber/use-spring/issues
- npm.io page: https://npm.io/package/use-spring

## Alternatives

- [@luma.gl/experimental](https://npm.io/package/@luma.gl/experimental.md) — 77.1K weekly downloads
- [persona-harness](https://npm.io/package/persona-harness.md) — 4.7K weekly downloads
- [@tsparticles/effect-bubble](https://npm.io/package/@tsparticles/effect-bubble.md) — 4.6K weekly downloads
- [f3d](https://npm.io/package/f3d.md) — 730 weekly downloads
- [spark-html-motion](https://npm.io/package/spark-html-motion.md) — 298 weekly downloads

## Recent versions

- 0.2.4 (latest) — 2021-06-17
- 0.2.3 — 2020-05-07
- 0.2.2 — 2020-03-25
- 0.2.1 — 2020-03-08
- 0.2.0 — 2020-03-08
- 0.1.1 — 2019-09-14
- 0.1.0 — 2019-09-14
- 0.0.1 — 2019-09-12

## README

# use-spring

[![](https://badgen.net/bundlephobia/minzip/use-spring)](https://bundlephobia.com/result?p=use-spring) ![](https://badgen.net/david/dep/pomber/use-spring) ![](https://badgen.net/npm/types/use-spring)

Install

```bash
npm install use-spring
```

Use

```jsx
import React, { useState } from "react";
import ReactDOM from "react-dom";
import { useSpring } from "use-spring";

function App() {
  const [target, setTarget] = useState(0);
  const handleTargetChange = e => setTarget(+e.target.value);
  const [current] = useSpring(target);
  return (
    <div>
      <input type="range" value={target} onChange={handleTargetChange} />
      <br />
      <input type="range" value={current} readOnly />
    </div>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
```

## Demos

- [Basic Demo](https://codesandbox.io/s/use-spring-demo-fbbvn)
- [Emoji Heads](https://codesandbox.io/s/use-spring-demo-irfq5?hidenavigation=1)

## API

```js
// default values:
const [x, isMoving] = useSpring(target, {
  stiffness: 170,
  damping: 26,
  mass: 1,
  decimals: 2,
  teleport: false,
  from: target,
  initialSpeed: 0
});
```

You can try different values of `stiffness`, `damping` or `mass` on the [Spring Editor](https://springs.pomb.us/).

## Related

- [react-spring](https://github.com/react-spring/react-spring)
- [react-motion](https://github.com/chenglou/react-motion)
- [framer-motion](https://www.framer.com/api/motion/)

## MIT License

Copyright (c) 2019 Rodrigo Pombo

---
_Source: https://npm.io/package/use-spring · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
