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

mochi-motion

v1.1.0

Published

🍑 Epic spring animations for React & Next.js - Professional-grade motion that feels like butter!

Readme

Mochi Motion 🍑

Epic spring animations for React & Next.js β€” Professional-grade motion that feels like butter!

πŸš€ Why Mochi Motion?

  • βœ… Visually impressive smooth page transitions + scroll reveals
  • βœ… Next.js optimized with built-in router integration
  • βœ… App Router & Pages Router support
  • βœ… Framer Motion powered for buttery smooth animations
  • βœ… TypeScript ready with full type safety
  • βœ… Plug-and-play β€” works out of the box

Installation

npm install mochi-motion framer-motion react-intersection-observer

Quick Start

React/Vite/CRA (Universal)

// For any React app (Vite, Create React App, etc.)
import { ReactTransition, RevealOnScroll } from 'mochi-motion'

function App() {
  return (
    <ReactTransition>
      <div>
        <RevealOnScroll effect="fade-up">
          <h1>Hello Mochi World!</h1>
        </RevealOnScroll>
      </div>
    </ReactTransition>
  )
}

Next.js App Router (13+)

// app/layout.tsx
import { AppRouterTransition } from 'mochi-motion'

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="en">
      <body>
        <AppRouterTransition>
          {children}
        </AppRouterTransition>
      </body>
    </html>
  )
}

Pages Router (Legacy)

// pages/_app.tsx
import { PageTransition } from 'mochi-motion'
import type { AppProps } from 'next/app'

export default function App({ Component, pageProps }: AppProps) {
  return (
    <PageTransition>
      <Component {...pageProps} />
    </PageTransition>
  )
}

Scroll Reveals (Both Routers)

import { RevealOnScroll } from 'mochi-motion'

<RevealOnScroll 
  effect="fade-up" 
  preset="wobbly" 
  delay={0.3}
  distance={60}
>
  <h1>Hello World</h1>
</RevealOnScroll>

Components

ReactTransition (Recommended for React/Vite)

Perfect for any React app (Vite, Create React App, etc.). Zero dependencies on Next.js.

// For Vite, CRA, or any React app  
import { ReactTransition } from 'mochi-motion'

function App() {
  return (
    <ReactTransition>
      <YourAppContent />
    </ReactTransition>
  )
}

Props:

  • children: React node to animate
  • className: Additional CSS classes

AppRouterTransition (Recommended for Next.js App Router)

Perfect for Next.js 13+ App Router. Provides smooth page transitions without router events.

// app/layout.tsx
import { AppRouterTransition } from 'mochi-motion'

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        <AppRouterTransition>
          {children}
        </AppRouterTransition>
      </body>
    </html>
  )
}

Props:

  • children: React node to animate
  • className: Additional CSS classes

PageTransition (Pages Router)

For Next.js Pages Router with automatic route change detection.

// pages/_app.tsx
import { PageTransition } from 'mochi-motion'

export default function MyApp({ Component, pageProps }) {
  return (
    <PageTransition>
      <Component {...pageProps} />
    </PageTransition>
  )
}

RevealOnScroll

Reveals content when it enters the viewport with customizable animations.

import { RevealOnScroll } from 'mochi-motion'

function MyComponent() {
  return (
    <div>
      <RevealOnScroll effect="fade-up" delay={0.2}>
        <h1>This slides up when scrolled into view</h1>
      </RevealOnScroll>
      
      <RevealOnScroll effect="fade-left" delay={0.4}>
        <p>This slides in from the left with a delay</p>
      </RevealOnScroll>
    </div>
  )
}

Props:

  • effect: Animation type - 'fade-up' | 'fade-down' | 'fade-left' | 'fade-right' | 'scale-up' | 'blur-up' | 'rotate-up' (default: 'fade-up')
  • preset: Spring feel - 'gentle' | 'wobbly' | 'stiff' | 'slow' (default: 'gentle')
  • delay: Animation delay in seconds (default: 0)
  • duration: Animation duration in seconds (default: 0.6)
  • distance: Slide distance in pixels (default: 50)
  • scale: Scale factor for scale animations (default: 0.8)
  • threshold: Intersection observer threshold (default: 0.1)
  • children: React node to animate

Advanced Usage:

<RevealOnScroll 
  effect="fade-left"
  preset="wobbly"
  distance={80}
  scale={0.9}
  delay={0.2}
  threshold={0.3}
  spring={{ stiffness: 200, damping: 15 }}
>
  <div>Epic animations! πŸ”₯</div>
</RevealOnScroll>

Advanced Usage

App Router with Per-Page Transitions

// app/page.tsx
import { RevealOnScroll } from 'mochi-motion'

export default function HomePage() {
  return (
    <div>
      <RevealOnScroll effect="fade-up">
        <h1>Welcome to App Router</h1>
      </RevealOnScroll>
      
      <RevealOnScroll effect="fade-up" delay={0.3}>
        <p>Smooth animations with zero config</p>
      </RevealOnScroll>
    </div>
  )
}

Pages Router with Custom Transitions

// pages/index.tsx
import { RevealOnScroll } from 'mochi-motion'

export default function Home() {
  return (
    <div>
      <RevealOnScroll effect="fade-up">
        <h1>Pages Router Support</h1>
      </RevealOnScroll>
      
      <RevealOnScroll effect="fade-left" delay={0.4}>
        <button>Call to Action</button>
      </RevealOnScroll>
    </div>
  )
}

Multiple Scroll Reveals

import { RevealOnScroll } from 'mochi-motion'

function HomePage() {
  return (
    <div>
      <RevealOnScroll effect="fade-up">
        <h1>Welcome</h1>
      </RevealOnScroll>
      
      <RevealOnScroll effect="fade-up" delay={0.2}>
        <p>This appears 200ms after the title</p>
      </RevealOnScroll>
      
      <RevealOnScroll effect="fade-left" delay={0.4}>
        <button>Call to Action</button>
      </RevealOnScroll>
    </div>
  )
}

Migration Guide

From Pages Router to App Router

Before (Pages Router):

// pages/_app.tsx
import { PageTransition } from 'mochi-motion'

export default function App({ Component, pageProps }) {
  return (
    <PageTransition>
      <Component {...pageProps} />
    </PageTransition>
  )
}

After (App Router):

// app/layout.tsx
import { AppRouterTransition } from 'mochi-motion'

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        <AppRouterTransition>
          {children}
        </AppRouterTransition>
      </body>
    </html>
  )
}

🎯 Complete TypeScript Support

Mochi Motion is built with TypeScript and includes comprehensive type definitions for maximum developer experience:

Core Animation Types

// Animation effect types with full IntelliSense
type AnimationEffect = 
  | 'fade-up' 
  | 'fade-down' 
  | 'fade-left' 
  | 'fade-right'
  | 'scale-up' 
  | 'scale-down' 
  | 'blur-up' 
  | 'rotate-up'

// Spring preset configurations
type SpringPreset = 'gentle' | 'wobbly' | 'stiff' | 'slow' | 'custom'

// Custom spring physics configuration
interface SpringConfig {
  stiffness: number  // 80-300 (default: 100)
  damping: number    // 8-30 (default: 20) 
  mass: number       // 0.8-1.5 (default: 1)
}

Complete Interface Definitions

// Spring physics configuration
interface SpringConfig {
  stiffness?: number    // Spring stiffness (default: 100)
  damping?: number      // Spring damping (default: 10) 
  mass?: number         // Mass of the spring (default: 1)
  velocity?: number     // Initial velocity (default: 0)
}

// Animation configuration for advanced usage
interface AnimationConfig {
  duration?: number     // Animation duration in seconds (default: 0.6)
  delay?: number        // Animation delay in seconds (default: 0)
  preset?: SpringPreset // Spring animation preset
  spring?: SpringConfig // Custom spring configuration
  distance?: number     // Distance for slide animations (default: 50px)
  scale?: number        // Scale factor for scale animations (default: 0.8)
  blur?: number         // Blur amount for blur effects (default: 10px)
  rotate?: number       // Rotation angle for rotate effects (default: 10deg)
}

// Base props for all Mochi Motion components
interface MochiMotionProps {
  children: React.ReactNode  // Content to animate
  className?: string        // Additional CSS classes
}

// RevealOnScroll component props (extends AnimationConfig)
interface RevealOnScrollProps extends AnimationConfig, MochiMotionProps {
  // Animation & Effects
  effect?: AnimationEffect           // default: 'fade-up'
  
  // Intersection Observer Configuration  
  threshold?: number                // 0-1 visibility ratio (default: 0.1)
  rootMargin?: string              // CSS margin string (default: '0px')
  triggerOnce?: boolean            // Animate only once (default: true)
  
  // Control
  disabled?: boolean               // Disable animation (default: false)
  
  // Styling
  style?: React.CSSProperties      // Inline styles
}

Page Transition Props

interface PageTransitionProps {
  children: React.ReactNode
  className?: string
  preset?: SpringPreset
  spring?: SpringConfig
}

interface AppRouterTransitionProps extends PageTransitionProps {
  // Same props as PageTransition
}

interface ReactTransitionProps extends PageTransitionProps {
  // Same props as PageTransition  
}

Spring Presets Type Definitions

// Exported preset configurations
export const SPRING_PRESETS: Record<SpringPreset, SpringConfig> = {
  gentle: { stiffness: 80, damping: 20, mass: 1 },
  wobbly: { stiffness: 120, damping: 8, mass: 1.2 },
  stiff: { stiffness: 300, damping: 30, mass: 0.8 },
  slow: { stiffness: 60, damping: 25, mass: 1.5 },
  custom: { stiffness: 100, damping: 20, mass: 1 }
}

Advanced Type Usage Examples

import { 
  RevealOnScroll, 
  SpringConfig,
  AnimationEffect,
  SPRING_PRESETS 
} from 'mochi-motion'

// Custom spring with full type safety
const customSpring: SpringConfig = {
  stiffness: 200,  // βœ… Type checked
  damping: 15,     // βœ… IntelliSense works  
  mass: 1.1        // βœ… Auto-completion
}

// Typed animation effects
const effects: AnimationEffect[] = [
  'fade-up',     // βœ… All effects available
  'scale-up',    // βœ… in autocomplete
  'blur-up',     // βœ… 
  'rotate-up'    // βœ…
]

// Component with full prop typing
function EpicCard({ title, delay }: { title: string, delay: number }) {
  return (
    <RevealOnScroll
      effect="scale-up"        // βœ… Typed union
      preset="wobbly"          // βœ… Preset validation  
      spring={customSpring}    // βœ… SpringConfig interface
      delay={delay}            // βœ… number type
      distance={60}            // βœ… Pixel distance
      threshold={0.2}          // βœ… 0-1 range hint
      className="epic-card"    // βœ… Optional string
    >
      <h3>{title}</h3>
    </RevealOnScroll>
  )
}

Generic Component Typing

// For wrapper components with children
interface MyComponentProps {
  title: string
  variant?: 'primary' | 'secondary'
  children: React.ReactNode
}

function MyComponent({ title, variant = 'primary', children }: MyComponentProps) {
  return (
    <RevealOnScroll 
      effect={variant === 'primary' ? 'fade-up' : 'scale-up'}
      preset="gentle"
    >
      <div className={`card card--${variant}`}>
        <h2>{title}</h2>
        {children}
      </div>
    </RevealOnScroll>
  )
}

Error Prevention with Types

// ❌ TypeScript will catch these errors:
<RevealOnScroll 
  effect="invalid-effect"     // ❌ Type error
  preset="wrong-preset"       // ❌ Type error  
  delay="not-a-number"        // ❌ Type error
  spring={{ wrong: 'config' }} // ❌ Type error
/>

// βœ… Correct usage with full type safety:
<RevealOnScroll
  effect="fade-up"            // βœ… Valid effect
  preset="wobbly"             // βœ… Valid preset
  delay={0.3}                 // βœ… Correct type
  spring={{ 
    stiffness: 150,           // βœ… Valid spring config
    damping: 12, 
    mass: 1.1 
  }}
>
  <div>Perfect type safety!</div>
</RevealOnScroll>

IDE Benefits

  • 🎯 IntelliSense: Complete autocomplete for all props and values
  • πŸ” Hover Info: JSDoc descriptions for every prop
  • ⚠️ Error Detection: Catch mistakes before runtime
  • πŸ”„ Refactoring: Safe renames across your entire codebase
  • πŸ“– Documentation: Inline prop documentation in your IDE

Requirements

For React/Vite/CRA:

  • React 17.0.0 or higher
  • Framer Motion 10.0.0 or higher

For Next.js:

  • Next.js 13.0.0 or higher (App Router) or Next.js 12.0.0+ (Pages Router)
  • Framer Motion 10.0.0 or higher

License

MIT License - Copyright (c) 2025 @mirayatech


Made with ❀️ and mochi by @mirayatech for the Next.js community

πŸ”₯ Epic Animation Showcase

Professional Spring Presets

import { RevealOnScroll, SPRING_PRESETS } from 'mochi-motion'

// Gentle - Perfect for elegant interfaces
<RevealOnScroll preset="gentle" effect="fade-up">
  <Card>Smooth as silk</Card>
</RevealOnScroll>

// Wobbly - Add personality to your UI
<RevealOnScroll preset="wobbly" effect="scale-up">
  <Button>Bouncy interactions</Button>
</RevealOnScroll>

// Stiff - Snappy, responsive feel
<RevealOnScroll preset="stiff" effect="fade-left" distance={60}>
  <Alert>Quick and precise</Alert>
</RevealOnScroll>

Advanced Effects Collection

// Blur reveal with custom spring
<RevealOnScroll 
  effect="blur-up" 
  preset="gentle"
  distance={40}
>
  <Hero>Cinematic entrance</Hero>
</RevealOnScroll>

// Rotate with bounce
<RevealOnScroll 
  effect="rotate-up"
  preset="wobbly"
  spring={{ stiffness: 200, damping: 12 }}
>
  <Card>Playful twist</Card>
</RevealOnScroll>

// Scale with custom timing
<RevealOnScroll 
  effect="scale-up"
  scale={0.7}
  preset="slow"
  delay={0.5}
>
  <Modal>Dramatic reveal</Modal>
</RevealOnScroll>

Staggered Animations (Like Framer, but better)

function FeatureGrid() {
  return (
    <div className="grid grid-cols-3 gap-4">
      {features.map((feature, i) => (
        <RevealOnScroll
          key={feature.id}
          effect="fade-up"
          preset="wobbly"
          delay={i * 0.1} // Stagger effect
          distance={60}
        >
          <FeatureCard {...feature} />
        </RevealOnScroll>
      ))}
    </div>
  )
}

Performance-Optimized Reveals

// Custom threshold for better performance
<RevealOnScroll 
  effect="fade-left"
  threshold={0.3}
  rootMargin="50px"
  preset="stiff"
>
  <ExpensiveComponent />
</RevealOnScroll>