# React / Next.js / Vue Integration --- ## React / Vite Install: ```bash npm install @splinetool/react-spline ``` Basic: ```jsx import Spline from '@splinetool/react-spline'; export default function App() { return (
); } ``` With object interaction + event listeners: ```jsx import { useRef } from 'react'; import Spline from '@splinetool/react-spline'; export default function App() { const splineRef = useRef(); function onLoad(splineApp) { splineRef.current = splineApp; } function triggerAnimation() { splineRef.current.emitEvent('mouseHover', 'Cube'); } function onSplineEvent(e) { console.log('Object interacted:', e.target.name); } return (
); } ``` **Lazy loading (recommended for performance):** ```jsx import { lazy, Suspense } from 'react'; const Spline = lazy(() => import('@splinetool/react-spline')); export default function Hero() { return ( }> ); } ``` --- ## Next.js Install: ```bash npm install @splinetool/react-spline ``` **Use the `/next` import** for SSR support + auto blurred placeholder: ```jsx import Spline from '@splinetool/react-spline/next'; export default function Page() { return ( ); } ``` **With dynamic import (if you get hydration errors):** ```jsx import dynamic from 'next/dynamic'; const Spline = dynamic(() => import('@splinetool/react-spline/next'), { ssr: false, loading: () =>
}); export default function Page() { return ; } ``` --- ## Vue Install: ```bash npm install @splinetool/vue-spline ``` ```vue ``` --- ## Full-Page Background (React) ```jsx import Spline from '@splinetool/react-spline'; import { useState } from 'react'; export default function HeroSection() { const [loaded, setLoaded] = useState(false); // Skip Spline on mobile / low-end devices const isMobile = typeof window !== 'undefined' && window.innerWidth < 768; const isLowEnd = typeof navigator !== 'undefined' && navigator.hardwareConcurrency <= 2; return (
{/* Fallback background — always rendered, hidden once Spline loads */}
{/* Spline scene — only load on capable devices */} {!isMobile && !isLowEnd && ( setLoaded(true)} style={{ position: 'absolute', top: 0, left: 0, width: '100%', height: '100%', zIndex: 0 }} /> )} {/* Content sits on top */}

Your Content Here

); } ``` --- ## React Prop Reference | Prop | Type | Description | |---|---|---| | `scene` | string | Scene URL (required) | | `onLoad` | function | Called with splineApp when loaded | | `onMouseDown` | function | Mouse/touch down on object | | `onMouseUp` | function | Mouse/touch up | | `onMouseHover` | function | Hover over object | | `onKeyDown` | function | Key pressed | | `onKeyUp` | function | Key released | | `onStart` | function | Scene started | | `onScroll` | function | Scroll event | | `style` | object | CSS styles for the canvas | | `className` | string | CSS class | See [PERFORMANCE.md](PERFORMANCE.md) and [COMMON_PROBLEMS.md](COMMON_PROBLEMS.md) before finishing.