How ismamz/next-transition-router works
Project Type and Purpose
• This is an open-source React/Next.js library (“next-transition-router”) designed to add animated page transitions to Next.js App Router applications.
• It provides a provider component (TransitionRouter), a custom Link component, and hooks (useTransitionRouter, useTransitionState) to integrate with any animation library (e.g., GSAP, Framer Motion).
File Structure Analysis
• Top-level
• package.json, pnpm-workspace.yaml, builds the library and example.
• /src – library source
– context.tsx: React Context for transition state
– index.ts: public exports
– link.tsx: custom Link component implementation
– router.tsx: TransitionRouter provider, event interception
– utils.ts: shared helper functions
• /example – demo Next.js App Router project showing usage
– app/layout.tsx, providers.tsx: injects the TransitionRouter
– app/page.tsx, demo pages, components, styles
– Tailwind, PostCSS, TS config for styling/demo
• Patterns
• React Context + Hooks for state management
• Client-side provider wrapping the entire app
• Optional auto-link detection vs explicit Link component
• Provider handles lifecycle: leave → page load → enter
README Insights
• Core API: TransitionRouter props leave, enter, optional auto
• Hooks: useTransitionRouter for programmatic navigation, useTransitionState for transition stage
• Integration points: next/app layout, any animation library callbacks, cleanup functions