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

next-page-to-app-converter

v1.1.0

Published

Convert Next.js Pages Router to App Router

Readme

Next.js Pages to App Router Converter

Automate your migration from Next.js Pages Router to App Router with intelligent component analysis and code transformation.

⭐ If this project saves you time, consider starring the repository and supporting its continued development.


🚀 Key Features

  • Smart Component Analysis: Automatically determines if a component should be Server or Client based on hooks and browser API usage.
  • Data Fetching Migration: Converts getServerSideProps and getStaticProps to async Server Components, including generateStaticParams.
  • Routing Updates: Transforms next/router to next/navigation (useRouter, usePathname, useSearchParams).
  • API Routes: Migrates API handlers to Route Handlers, updating res methods to NextResponse.
  • Metadata: Converts <Head> tags to the Metadata API.
  • Layouts & Providers: Automatically generates root layouts, nested layouts, and extracts context providers from _app.tsx.
  • Font Optimization: Migrates next/font configurations.

📦 Installation & Usage

Quick Run

Run directly using npx:

npx next-page-to-app-converter <project-path>

Global Installation

npm install -g next-page-to-app-converter
next-pages-to-app <project-path>

⚙️ Options

| Flag | Description | |------|-------------| | -d, --dry-run | Preview the migration without writing any files. | | -v, --validate | (Experimental) Runs runtime validation using Next.js DevTools (Requires Next.js 16+). | | -h, --help | Show all available commands and options. |


🛠️ How It Works

  1. Scans your pages directory for:

    • Routes
    • API endpoints
    • Special files (_app, _document, _error)
  2. Analyzes every component and its imports to detect:

    • React Hooks (useState, useEffect, etc.)
    • Event handlers (onClick, onChange, etc.)
    • Browser-only APIs (window, document, localStorage, etc.)
  3. Transforms your code by:

    • Adding "use client" directives where required.
    • Rewriting data fetching to async Server Components.
    • Updating navigation and routing logic.
    • Converting metadata handling.
    • Migrating API routes.
  4. Generates a complete app directory while preserving your application's behavior as closely as possible.


✅ Requirements

  • Node.js: 18.0.0 or later
  • Target Project: Next.js 13 or later
  • Validation: Next.js 16+ required for the --validate option

❓ Troubleshooting

Validation Issues

The --validate flag starts your development server for runtime validation.

Before using it, make sure the following command runs successfully:

npm run dev

Complex Projects

While the converter handles most common migration patterns, projects using:

  • Complex custom server logic
  • Dynamic runtime imports
  • Advanced webpack customization
  • Unusual routing patterns

may require manual review after migration.


❤️ Support

If this tool saves you hours of migration work, consider supporting its development.

Your support helps fund:

  • 🚀 New migration features
  • 🐞 Bug fixes
  • ⚡ Performance improvements
  • 📚 Better documentation
  • ❤️ Continued maintenance

Every contribution is greatly appreciated.


📄 License

ISC


🙏 Acknowledgments

  • Built with ts-morph for TypeScript AST manipulation.
  • Inspired by the Next.js community's migration needs.
  • Thanks to everyone who reports bugs, contributes code, and supports the project.