shuding/next-view-transitions
소개
Next.js App Router에서 CSS View Transitions API를 사용합니다.
웹 및 앱측정된 스타 증가
- in 24h
- -1
- in 7 days
- -4
- in 15 days
- -2
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originalnext-view-transitions
Use View Transitions API in Next.js App Router.
Demo.
Disclaimer
This library is aimed at basic use cases of View Transitions and Next.js App Router. With more complex applications and use cases like concurrent rendering, Suspense and streaming, new primitives and APIs still need to be developed into the core of React and Next.js in the future (more).
Installation
Use your favorite package manager to install the next-view-transitions package. For example:
pnpm install next-view-transitions
Usage
Wrap your content with the <ViewTransitions> component inside the layout file:
import { ViewTransitions } from 'next-view-transitions'
export default function Layout({ children }) {
return (
<ViewTransitions>
<html lang='en'>
<body>
{children}
</body>
</html>
</ViewTransitions>
)
}
Then, use the <Link> component for links that need to trigger a view transition:
import { Link } from 'next-view-transitions'
export default function Component() {
return (
<div>
<Link href='/about'>Go to /about</Link>
</div>
)
}
Or use the useTransitionRouter hook for programmatic navigation:
import { useTransitionRouter } from 'next-view-transitions'
export default function Component() {
const router = useTransitionRouter()
return (
<div>
<button onClick={() => {
// All Next.js router methods are supported
router.push('/about')
}}>Go to /about</button>
</div>
)
}
That's it!
License
MIT.
관련 프로젝트 살펴보기
불러오는 중…