Skip to content

mattwoodco/next-view-transitions

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

next-view-transitions

Use CSS View Transitions API in Next.js App Router.

Demo.

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>
  )
}

That's it!

License

MIT.

About

Use CSS View Transitions API in Next.js App Router.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 46.3%
  • JavaScript 33.6%
  • CSS 20.1%