npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@zouloux/next-app-transition

v0.1.5

Published

This React hook help creating smooth transition between all pages on **Next 15+** with **App Router** ( Not compatible with legacy router ). This package is about <picture style="display: inline-block"><source media="(prefers-color-scheme: dark)" srcset="

Downloads

161

Readme

Next App Transition

This React hook help creating smooth transition between all pages on Next 15+ with App Router ( Not compatible with legacy router ). This package is about . It contains only a hook, you'll have to code your own PageTransition component.

Demo

next-app-transition.gif

See the demo running here on StackBlitz

Install

npm i @zouloux/next-app-transition

Available on NPM

Basic usage

Here is the minimal code needed to patch the Next router and hook for smooth transitions.

"use client"
import { usePreventNextRouter } from "@zouloux/next-app-transition"

export function PageTransition () {
  async function animateTransition (state: boolean) {
    // ... animate here
  }
  usePreventNextRouter({
    // Called when router wants to change page
    // It can be triggered from a push-state event
    transitionHandler: async (state: boolean) => {
      // Code your async transition here with state.
      // If true, enable transition panel, if false, disable transition panel
      // Please note that router is locked while handler's promise is not complete
      // Ex :
      await animateTransition( state ) // .4s animation
    }
  })
  return <div>{/* transition elements */}</div>
}

Usage with anchor global listener

Anchor global listener will listen all <a> elements on the page, and check if they point to a local next URL. If so, it can trigger the animation.

"use client"
import { usePreventNextRouter, useAnchorGlobalListener } from "@zouloux/next-app-transition"

export function PageTransition () {
  async function transitionHandler (state: boolean) {
    // ... animate here
  }
  // Export patched router push, which triggers animations when called
  const { routerPush } = usePreventNextRouter({ transitionHandler })
  // Listen for all <a> clicks to override default Next's behavior
  useAnchorGlobalListener({
    // User clicks on any internal and relative link
    relativeHandler: (event, href) => {
      // Prevent native browser navigation
      event.preventDefault()
      // Use patched routerPush to change page with custom transition
      routerPush(href)
    },
  })
  return <div>{/* transition elements */}</div>
}

Check PageTransition.tsx source code in the demo

API and other options

import {
  usePreventNextRouter,
  useAnchorGlobalListener,
  onNextRouterTransition
} from "@zouloux/next-app-transition"

// --- USE PREVENT NEXT ROUTER
// Listen for router changes ( push-state events ) and prevent them
const { routerPush, isRouterLocked } = usePreventNextRouter({
  // Locking handler for smooth transitions
  transitionHandler: async (state :boolean) => { /*...*/ },
  // If true, will trigger a full page refresh if the same href is in the push-state event
  reloadOnSameHref: true,
})
// --- ROUTER PUSH
// Trigger a page change to this href on the patched router returned by the hook
routerPush("/new-href")
routerPush("/new-href-with-scroll", { scroll: true })
// Check if router is locked
function anotherFunctionSomewhere () {
  if ( isRouterLocked() ) {
    // Router is locked prevent something related
  }
}

// --- TRANSITION STATE CHANGES
// Be notified when transition state changes
onNextRouterTransition.add( state => {
  // "opening" | "opened" | "closing" | "closed"
})
// The same but in a hook
useEffect(() => {
  // Here the emitter returns the remove function for React hooks
  return onNextRouterTransition.add( state => {
    // ...
  })
}, [dependency])

// --- ANCHOR GLOBAL LISTENER
useAnchorGlobalListener({
  // Called when an <a> link is clicked with a app related href
  relativeHandler: ( event: Event, href: string ) => {
    // Do not follow link with original Next router
    event.preventDefault()
    // Use patched routerPush to change page with custom transition
	routerPush(href)
  },
  hashHandler: ( event: Event, hash: string ) => {
    // Called when an hash link <a href="#hash"> is clicked,
    // same behavior but for hashes
  },
  // React dependencies for those handlers, default is []
  dependencies: [/*...*/]
})

Build and work on the package

Clone

git clone https://github.com/zouloux/next-app-transition.git
cd next-app-transition

Run the demo

npm run demo

This will install npm package and start NextJS

Build the library itself

npm run build

TSP

This package has been created with tsp