Motion SVG Explained: The motion-svg Engine, Its API and Two Namesakes
Motion SVG usually points to the motion-svg npm package, a zero-dependency, TypeScript-first declarative SVG animation engine at version 1.1. This guide covers its parser, actors, timelines, triggers, path morphing, bundle format, React and Web Component bindings, and plugin hooks. It also separates the library from a SaaS product with the same name and from the Motion animation library, so you can tell which Motion SVG a search result means.
View 4 referencesAllow the functional cookie to save your likes. Privacy details
What is Motion SVG?
Motion SVG, as the motion-svg npm package, is a declarative animation engine built specifically for path-level control of SVG graphics. It parses an SVG, wraps paths in controllable actors, animates them with keyframes and triggers, and exports a self-contained animation bundle.
The documentation calls it the first declarative SVG animation engine designed for path-level control. Version 1.1 is MIT licensed, has zero dependencies, ships TypeScript types and runs in both Node.js and browsers. Install it with npm install motion-svg.
The term is not unique, so check which product a result describes before adopting it. This article focuses on the library; the section below separates it from the other two uses of the Motion SVG name.
Is Motion SVG the library, a SaaS product, or Motion?
Three distinct things share the name. The motion-svg package is a code library, MotionSVG is a hosted generator for SaaS launch pages, and Motion is a general animation library that also supports SVG. Checking the package name or the domain is the fastest way to tell which one a particular article or tutorial is describing.
The hosted MotionSVG product generates animated SVGs from prompts and brand colours, with free, Pro and Team tiers at 0, 29 and 99 US dollars per month. The Motion library is installed as motion and animates HTML, SVG and WebGL, with a mini HTML/SVG animate() build of about 2.3 kB.
None of these is a drop-in replacement for another. If you need a JSON bundle and path morphing in your own code, the npm engine is the match; if you need a generated launch-page asset from a prompt, the hosted product is.
How do you build an animation with the motion-svg engine?
The minimal flow has five steps: parse an SVG string, create an actor from a path, define a timeline of keyframes, bind a trigger, and export a bundle. Every step is a plain function call, so the animation can be generated at build time or in the browser.
import { parseSvg, createActor, timeline, trigger, exportBundle } from 'motion-svg';
const scene = parseSvg(svgString);
const star = createActor({ id: 'star', paths: [scene.paths[0]], origin: { x: 100, y: 100 } });
const anim = timeline(star, { keyframes: [
{ at: 0, scale: 1, rotation: 0 },
{ at: 600, scale: 1.3, rotation: 180, curve: 'easeInOutBack' },
{ at: 1200, scale: 1, rotation: 360, curve: 'easeOutCubic' }
] });
const binding = trigger(anim, { type: 'hover', reverse: true });
const json = exportBundle({ scene, actors: [star], timelines: [anim], triggers: [binding] });
The parser is regex-based and needs no DOM. It returns a Scene with paths, groups, viewBox, colors, gradients and metadata, which is why the same code works in a server build step.
What can actors and timelines animate?
An actor wraps one or more SVG paths and has its own transform origin and z-order. A timeline sorts keyframes by time and fills the first keyframe from the actor's defaults. The actor model keeps transforms independent per path, so several shapes can share one scene without inheriting each other keyframes.
Keyframe properties include position, scale, rotation, opacity, fill, stroke, strokeWidth, blurRadius, backdropBlur, width, height, pathD and curve. The library ships more than twenty easing curves, including quad, cubic, back, elastic and bounce families, and accepts custom cubic bezier definitions.
Orchestration helpers cover sequence, stagger and parallelDuration. Stagger supports starting from the beginning, end, centre or edges of a group, which removes a lot of hand-written delay arithmetic.
Path morphing and triggers
| Feature | Main functions | Notes |
|---|---|---|
| Morphing | lerpPath, parsePathD, normalizeToCubic, balanceCommands |
Supports M, L, H, V, C, S, Q, T, A and Z |
| Triggers | trigger with hover, click, loop, scroll, appear, manual |
Scroll uses 0–1 viewport percentages |
| Playback | createPlayback |
Play, pause, stop, seek, reverse and events |
| State | AnimationStore |
Batched updates via queueMicrotask |
What is the .motionsvg.json bundle format?
A bundle is a versioned JSON document holding the scene, actors, timelines, triggers and optional variants. Version 1.1 adds variants; v1.0 bundles without a variants field still load correctly. Because the file is portable and versioned, an animation produced in one tool can be validated and replayed by the React player or the Web Component.
The I/O functions are exportBundle, importBundle, validateBundle and getVariant. Validation matters here because a bundle is meant to be saved, transported and played by a different runtime than the one that created it.
Variants let one bundle carry multiple states, such as idle and active, under names that the player can switch at runtime. React bindings expose those names through useMotionSvg.
How do you use it in React or plain HTML?
The package has four entry points: motion-svg for the core engine, motion-svg/react for components and hooks, motion-svg/vanilla for a framework-free Web Component, and motion-svg/plugins for official plugins. Both bindings read the same bundle format, so the choice of framework does not force a separate animation pipeline or a second export step.
React exports MotionSvgPlayer, MotionSvgActor, MotionSvgCanvas, useMotionSvg and useActorState. A player takes a bundle, dimensions and an optional variant name:
React exports a player component that takes the bundle as its data prop, with width, height and an optional variant name; the same bundle can also be handed to the vanilla Web Component.
For plain HTML, registerMotionSvg() from the vanilla entry point registers a custom element that accepts src, data, variant, autoplay, width and height attributes and emits motionsvg:ready, motionsvg:play and motionsvg:complete events.
What does the plugin system cover?
Plugins register hooks at defined points in the pipeline: after parsing, after actor creation, before and after interpolation, before export, after import, and for individual property interpolation. The official plugin entry includes spring physics, stepped easing, slow-motion easing and elastic easing.
The documentation also mentions a visual editor called motion-svg-kit, with a timeline, canvas editor, shape tools, live preview and variant manager. Access is described as coming through contributions to the core repository, so it should not be assumed to be a generally available download.
Frequently asked questions
The questions below resolve the naming confusion and the two most common technical doubts about the engine. Each answer is drawn from the package documentation checked on 2 December 2026, not from a general description of SVG animation. The naming question matters most because search results mix all three products.
Does Motion SVG need a browser to parse files?
No. The parser is regex-based and explicitly works without a DOM, so the same package can run in Node.js during a build step and in the browser at runtime.
Can it animate colours and gradients?
Yes. Keyframes can animate fill and stroke, and the library includes lerpGradientDef for interpolating gradient definitions, including across linear and radial gradient types.
Which Motion SVG should I choose?
Choose the motion-svg package if you are writing code and need exportable bundles, the hosted MotionSVG product if you want a generated launch-page asset, or the motion package if you need a general animation library that also handles HTML and WebGL.
Bottom line: Motion SVG the npm engine is a small, focused library for developers who want precise SVG path control and portable animation bundles. Its documentation is detailed about API behaviour, but the visual editor's availability is described in terms of contribution access rather than a public release.