motion-solid

Installation

Install motion-solid together with Solid 2. This page also lists the package's entry points.

Install the package

motion-solid needs Solid 2.0 (solid-js and @solidjs/web, version 2.0.0-rc.15 or later). Solid 2 is a release candidate and is published under the next tag:

pnpm add @motion-s/solid solid-js@next @solidjs/web@next
npm install @motion-s/solid solid-js@next @solidjs/web@next
yarn add @motion-s/solid solid-js@next @solidjs/web@next
bun add @motion-s/solid solid-js@next @solidjs/web@next

motion-dom and motion-utils, the engine shared with Motion for React, are installed as dependencies.

Builds

The package ships three builds and picks one through export conditions:

ConditionBuildUsed by
solidSource with JSX preservedApps compiled by Solid's compiler (@solidjs/vite-plugin, SolidStart)
browserCompiled for the browserBundlers without Solid's compiler
nodeCompiled for the serverServer rendering without Solid's compiler

With Solid's compiler, your app compiles motion-solid's JSX together with its own code, for the target it builds (client, server, hydration). You don't need to configure anything for this.

Solid's runtime must exist only once in your app. If you see errors about missing owners or context, check that only one copy of solid-js and @solidjs/web is installed.

Entry points

import { motion, AnimatePresence, animate } from "@motion-s/solid"
ImportContents
@motion-s/solidEverything: motion, m, the components, the hooks, animate(), scroll(), inView(), and everything exported by motion-dom and motion-utils
@motion-s/solid/domThe parts without Solid: animate(), scroll(), scrollInfo(), inView(), animateMini(), and the motion-dom/motion-utils exports
@motion-s/solid/dom/miniA smaller animate() that only animates elements with the Web Animations API, and animateSequence()
@motion-s/solid/miniA smaller useAnimate() built on the mini animate()
@motion-s/solid/projectionLow-level parts of the layout projection system (HTMLProjectionNode, nodeGroup, scale correctors, frame, mix)
@motion-s/solid/debugrecordStats(), to record performance statistics of animations

Most apps only need the main entry. To keep the initial bundle small, see Reduce bundle size and LazyMotion.

TypeScript

Types are included. Motion's types (Transition, Variants, MotionValue, ...) are exported from the main entry:

import { motion, type Variants } from "@motion-s/solid"

const variants: Variants = {
    hidden: { opacity: 0 },
    visible: { opacity: 1 },
}