implement_lenis_scroll
Instructions for implementing Lenis smooth scrolling in a Next.js or React application.
How do I install this agent skill?
npx skills add https://github.com/jerrar670/surf-website --skill implement-lenis-scrollIs this agent skill safe to install?
- Gen Agent Trust Hubpass
This skill provides instructions and code snippets for implementing Lenis smooth scrolling in a React/Next.js application. It is safe as it primarily offers guidance and does not contain any malicious code, prompt injection attempts, data exfiltration, or other security vulnerabilities. The skill instructs the user to install a well-known, legitimate npm package, which is a standard development practice.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
- Runlayerwarn
1/1 file flagged
- ZeroLeakspass
Score: 93/100 · 2 sections analyzed
What does this agent skill do?
Implement Lenis Smooth Scroll
This skill guides you through adding buttery smooth scrolling to a React/Next.js application using @studio-freight/lenis (or the newer lenis package).
Prerequisites
- A React or Next.js project.
Steps
1. Install Dependencies
Install the Lenis package.
npm install lenis
# OR depending on version preference
npm install @studio-freight/lenis
2. Create the Lenis Hook/Component
It's best to encapsulate Lenis in a reusable component or hook.
Option A: Global Component (Recommended for Next.js App Router)
Create src/lib/lenis.ts or src/components/SmoothScroll.tsx.
// src/components/SmoothScroll.tsx
'use client'
import { ReactNode, useEffect } from 'react'
import Lenis from 'lenis'
export default function SmoothScroll({ children }: { children: ReactNode }) {
useEffect(() => {
const lenis = new Lenis({
duration: 1.2,
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
orientation: 'vertical',
gestureOrientation: 'vertical',
smoothWheel: true,
})
function raf(time: number) {
lenis.raf(time)
requestAnimationFrame(raf)
}
requestAnimationFrame(raf)
return () => {
lenis.destroy()
}
}, [])
return <>{children}</>
}
3. Integrate into Layout
Wrap your main application or layout content with the component.
Next.js App Router (layout.tsx):
import SmoothScroll from '@/components/SmoothScroll'
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
<SmoothScroll>
{children}
</SmoothScroll>
</body>
</html>
)
}
Best Practices
- Performance: Ensure
requestAnimationFrameis optimized. - Scroll Restoration: Lenis usually handles this, but verify
scrollRestorationworks as expected in Next.js. - GSAP Integration: If using ScrollTrigger, ensure you update ScrollTrigger on Lenis scroll.
// Inside useEffect // lenis.on('scroll', ScrollTrigger.update) // gsap.ticker.add((time)=>{lenis.raf(time * 1000)}) // gsap.ticker.lagSmoothing(0)
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/jerrar670/surf-website/implement_lenis_scroll">View implement_lenis_scroll on skillZs</a>