1. 從工坊匯出 React 元件
開啟工坊上傳 SVG/PNG 或從 3,400+ 圖示搜尋,選好粒子效果後在 React 分頁下載 PixelLogoLoader.tsx(Pro 方案)。
2. 加上 'use client' 宣告
由於元件呼叫 useRef 與 ResizeObserver,請儲存為 src/components/PixelLogoLoader.tsx 並於第一行加入 'use client';:
'use client';
import { PixelLogoLoader } from '@/components/PixelLogoLoader';
export function HeroLogo() {
return (
<div style={{ width: '100%', maxWidth: 420, margin: '0 auto' }}>
<PixelLogoLoader
variant="mobius-flow"
height={320}
duration={3.2}
interactive
/>
</div>
);
}
3. 避免 SSR 階段版面位移
可用 next/dynamic 搭配 ssr: false 保留等高佔位以維持 CLS 分數:
import dynamic from 'next/dynamic';
const PixelLogoLoader = dynamic(
() => import('@/components/PixelLogoLoader').then((m) => m.PixelLogoLoader),
{ ssr: false, loading: () => <div style={{ height: 320 }} /> }
);
4. 免費版替代做法
將免費匯出的 HTML5 放進 public/logo-loader.html 並以 <iframe> 引入即可。詳見 React 完整教學。