Community Framer Motion Best Practices
Comprehensive performance optimization guide for Framer Motion animations in React applications. Contains 42 rules across 9 categories, prioritized by impact to guide automated refactoring and code generation.
When to Apply
Reference these guidelines when:
- Adding animations to React components with Framer Motion
- Optimizing bundle size for animation-heavy applications
- Preventing unnecessary re-renders during animations
- Implementing layout transitions or shared element animations
- Building scroll-linked or gesture-based interactions
Rule Categories by Priority
Quick Reference
1. Bundle Optimization (CRITICAL)
bundle-lazy-motion[blocked] - Use LazyMotion and m component instead of motionbundle-dynamic-features[blocked] - Dynamically import motion featuresbundle-dom-animation[blocked] - Use domAnimation for basic animationsbundle-use-animate-mini[blocked] - Use mini useAnimate for simple casesbundle-strict-mode[blocked] - Enable strict mode to catch accidental imports
2. Re-render Prevention (CRITICAL)
rerender-motion-value[blocked] - Use useMotionValue instead of useStatererender-use-transform[blocked] - Derive values with useTransformrerender-stable-callbacks[blocked] - Keep animation callbacks stablererender-variants-object[blocked] - Define variants outside componentrerender-animate-prop[blocked] - Use stable animate valuesrerender-motion-value-event[blocked] - Use motion value events
3. Animation Properties (HIGH)
anim-transform-properties[blocked] - Animate transform propertiesanim-opacity-filter[blocked] - Prefer opacity and filter for visual effectsanim-hardware-acceleration[blocked] - Leverage hardware accelerationanim-will-change[blocked] - Use willChange prop judiciouslyanim-independent-transforms[blocked] - Animate transforms independentlyanim-keyframes-array[blocked] - Use keyframe arrays for sequences
4. Layout Animations (HIGH)
layout-dependency[blocked] - Use layoutDependency to limit measurementslayout-position-size[blocked] - Use layout="position" or "size" appropriatelylayout-group[blocked] - Group related layout animationslayout-id-shared[blocked] - Use layoutId for shared element transitionslayout-scroll[blocked] - Add layoutScroll to scrollable ancestors
5. Scroll Animations (MEDIUM-HIGH)
scroll-use-scroll[blocked] - Use useScroll hook for scroll-linked animationsscroll-use-spring-smooth[blocked] - Smooth scroll animations with useSpringscroll-element-tracking[blocked] - Track specific elements entering viewportscroll-offset-configuration[blocked] - Configure scroll offsetsscroll-container-ref[blocked] - Track scroll within specific containers
6. Gesture Optimization (MEDIUM)
gesture-while-props[blocked] - Use whileHover/whileTap instead of handlersgesture-variants-flow[blocked] - Let gesture variants flow to childrengesture-drag-constraints[blocked] - Use dragConstraints ref for boundariesgesture-drag-elastic[blocked] - Configure dragElastic for natural feelgesture-tap-cancel[blocked] - Use onTapCancel for interrupted gestures
7. Spring & Physics (MEDIUM)
spring-physics-based[blocked] - Use physics-based springs for interruptibilityspring-damping-ratio[blocked] - Configure damping to control oscillationspring-mass-inertia[blocked] - Adjust mass for heavier/lighter feelspring-use-spring-hook[blocked] - Use useSpring for reactive values
8. SVG & Path Animations (LOW-MEDIUM)
svg-path-length[blocked] - Use pathLength for line drawing animationssvg-motion-components[blocked] - Use motion.path and motion.circlesvg-viewbox-animation[blocked] - Animate viewBox for zoom effectssvg-morph-matching-points[blocked] - Match point counts for morphing
9. Exit Animations (LOW)
exit-animate-presence[blocked] - Wrap conditional renders with AnimatePresenceexit-unique-keys[blocked] - Provide unique keys for AnimatePresence childrenexit-mode-wait[blocked] - Use mode="wait" for sequential transitions
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions [blocked] - Category structure and impact levels
- Rule template [blocked] - Template for adding new rules


