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 ๐Ÿ™

ยฉ 2025 โ€“ย Pkg Stats / Ryan Hefner

@choi2021/next-route-visualizer

v1.0.10

Published

๐Ÿ—บ๏ธ Visualize Next.js routes as an interactive diagram with advanced function analysis. Supports dynamic route detection, function-based navigation patterns, and comprehensive Next.js route mapping. Generate JSON data and beautiful HTML reports to explore

Readme

๐Ÿ—บ๏ธ Next.js Route Visualizer

Next.js ํ”„๋กœ์ ํŠธ์˜ ๋ผ์šฐํŠธ ๊ตฌ์กฐ์™€ ๋„ค๋น„๊ฒŒ์ด์…˜์„ ํ•œ ๋ˆˆ์— ์‹œ๊ฐํ™”ํ•ด๋ณด์„ธ์š”!

ํ•œ ๋ฒˆ์˜ ๋ช…๋ น์–ด๋กœ ๋ผ์šฐํŠธ ๊ทธ๋ž˜ํ”„ JSON๊ณผ ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒ HTML ๋ฆฌํฌํŠธ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

โœจ ํŠน์ง•

  • ๐Ÿš€ ์›ํด๋ฆญ ์‹คํ–‰: npx ๋ช…๋ น์–ด ํ•˜๋‚˜๋กœ ์ฆ‰์‹œ ์‹œ๊ฐํ™”
  • ๐Ÿ“Š ๋ผ์šฐํŠธ ๋ถ„์„: ํŽ˜์ด์ง€์™€ ๋‹ค์ด๋‚ด๋ฏน ๋ผ์šฐํŠธ ๊ด€๊ณ„ ์ถ”์ 
  • ๐ŸŽฏ ๋™์  ํ•จ์ˆ˜ ๋ถ„์„: Router.push(getRoute())์™€ ๊ฐ™์€ ๋™์  ํ•จ์ˆ˜ ํ˜ธ์ถœ ๋‚ด๋ถ€ ๋ถ„์„
  • ๐Ÿ” ๊ณ ๊ธ‰ ๋„ค๋น„๊ฒŒ์ด์…˜ ๊ฐ์ง€: Routes ์ƒ์ˆ˜, ํ™”์‚ดํ‘œ ํ•จ์ˆ˜, ์กฐ๊ฑด๋ถ€ ๋„ค๋น„๊ฒŒ์ด์…˜ ์ง€์›
  • ๐ŸŽจ ๋‘ ๊ฐ€์ง€ ์‹œ๊ฐํ™” ๋ชจ๋“œ:
    • ๐Ÿ“ˆ ๊ทธ๋ž˜ํ”„ ๋‹ค์ด์–ด๊ทธ๋žจ: ๋“œ๋ž˜๊ทธ, ์คŒ, ํ•„ํ„ฐ๋ง ๊ฐ€๋Šฅํ•œ ๋…ธ๋“œ-๋งํฌ ์‹œ๊ฐํ™”
    • ๐Ÿ“‹ ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒ ๋ฆฌํฌํŠธ: ํŽ˜์ด์ง€ ์„ ํƒํ˜• ์—ฐ๊ฒฐ ํƒ์ƒ‰ ์ธํ„ฐํŽ˜์ด์Šค
  • ๐Ÿ’พ JSON ์ถœ๋ ฅ: ๋‹ค๋ฅธ ๋„๊ตฌ์—์„œ๋„ ํ™œ์šฉ ๊ฐ€๋Šฅํ•œ ๋ฐ์ดํ„ฐ
  • ๐ŸŒ ์ž๋™ ๋ธŒ๋ผ์šฐ์ €: ์ƒ์„ฑ ์ฆ‰์‹œ ๋ธŒ๋ผ์šฐ์ €์—์„œ ์—ด๋ฆผ

๐Ÿš€ ๋น ๋ฅธ ์‹œ์ž‘

Next.js ํ”„๋กœ์ ํŠธ์—์„œ ๋ฐ”๋กœ ์‹คํ–‰

# ํ˜„์žฌ ๋””๋ ‰ํ„ฐ๋ฆฌ ๋ถ„์„ (๊ธฐ๋ณธ: ๊ทธ๋ž˜ํ”„ ๋‹ค์ด์–ด๊ทธ๋žจ)
npx @choi2021/next-route-visualizer

# ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒ HTML ๋ฆฌํฌํŠธ ์ƒ์„ฑ
npx @choi2021/next-route-visualizer report

# ํŠน์ • ํ”„๋กœ์ ํŠธ ๋ถ„์„
npx @choi2021/next-route-visualizer ./my-next-app
npx @choi2021/next-route-visualizer report ./my-next-app

๋ช…๋ น์–ด ์˜ต์…˜

# ๊ธฐ๋ณธ ๊ทธ๋ž˜ํ”„ ์‹œ๊ฐํ™”
npx @choi2021/next-route-visualizer map [project-path]

# ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒ HTML ๋ฆฌํฌํŠธ
npx @choi2021/next-route-visualizer report [project-path] [-o output.html]

๊ฒฐ๊ณผ

๊ทธ๋ž˜ํ”„ ์‹œ๊ฐํ™” (map ๋ช…๋ น์–ด):

  • route-graph.json - ๋ผ์šฐํŠธ ๋ฐ์ดํ„ฐ
  • route-visualizer.html - ๋…ธ๋“œ-๋งํฌ ๊ทธ๋ž˜ํ”„ ์‹œ๊ฐํ™”

HTML ๋ฆฌํฌํŠธ (report ๋ช…๋ น์–ด):

  • route-graph.json - ๋ผ์šฐํŠธ ๋ฐ์ดํ„ฐ
  • route-report.html - ํŽ˜์ด์ง€ ์„ ํƒํ˜• ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒ ๋ฆฌํฌํŠธ

๐Ÿ“‹ ์‹œ์Šคํ…œ ์š”๊ตฌ์‚ฌํ•ญ

  • Node.js 14.0.0 ์ด์ƒ
  • Next.js ํ”„๋กœ์ ํŠธ (pages/ ๋˜๋Š” src/pages/ ๊ตฌ์กฐ)

๐Ÿ’ก ์‚ฌ์šฉ ์˜ˆ์‹œ

$ npx @choi2021/next-route-visualizer report

๐Ÿ“Š Next.js Route HTML Report Generator v1.0.0

๐Ÿ”„ ๋ผ์šฐํŠธ ๋ถ„์„ ์ค‘...
๐Ÿ“Š HTML ๋ฆฌํฌํŠธ ์ƒ์„ฑ ์ค‘...

โœ… HTML ๋ฆฌํฌํŠธ๊ฐ€ ์ƒ์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค: route-report.html
๐Ÿ“Š ์ด 9๊ฐœ ํŽ˜์ด์ง€, 139๊ฐœ ์—ฐ๊ฒฐ ๋ถ„์„ ์™„๋ฃŒ

๐ŸŒ ๋ธŒ๋ผ์šฐ์ €์—์„œ ๋ฆฌํฌํŠธ๋ฅผ ์—ด์—ˆ์Šต๋‹ˆ๋‹ค!

๐ŸŽจ ์‹œ๊ฐํ™” ๋ชจ๋“œ

1. ๐Ÿ“ˆ ๊ทธ๋ž˜ํ”„ ๋‹ค์ด์–ด๊ทธ๋žจ (map)

  • ์ปฌ๋Ÿฌ ์ฝ”๋”ฉ: ํŽ˜์ด์ง€(ํŒŒ๋ž€์ƒ‰), ๋‹ค์ด๋‚ด๋ฏน ๋ผ์šฐํŠธ(์ฃผํ™ฉ์ƒ‰)
  • ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒ ๊ทธ๋ž˜ํ”„: ๋…ธ๋“œ ๋“œ๋ž˜๊ทธ, ์คŒ ์ธ/์•„์›ƒ, ํŒฌ
  • ์„ธ๋ถ€ ์ •๋ณด: ํ˜ธ๋ฒ„์‹œ ํŒŒ์ผ ๊ฒฝ๋กœ, ์ฝ”๋“œ ์Šค๋‹ˆํŽซ, ๋ผ์ธ ๋ฒˆํ˜ธ ํ‘œ์‹œ
  • ์—ฐ๊ฒฐ ์ถ”์ : ํŽ˜์ด์ง€๊ฐ„ ๋„ค๋น„๊ฒŒ์ด์…˜ ๊ด€๊ณ„ ์‹œ๊ฐํ™”

2. ๐Ÿ“‹ ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒ ๋ฆฌํฌํŠธ (report)

  • ์‚ฌ์ด๋“œ๋ฐ”: ์—ฐ๊ฒฐ ์ˆ˜ ๊ธฐ์ค€ ์ •๋ ฌ๋œ ํŽ˜์ด์ง€ ๋ชฉ๋ก
  • ํŽ˜์ด์ง€ ์ƒ์„ธ: ์„ ํƒ๋œ ํŽ˜์ด์ง€์˜ incoming/outgoing ์—ฐ๊ฒฐ ํ‘œ์‹œ
  • ํ”„๋กœ์ ํŠธ ํ†ต๊ณ„: ์ „์ฒด ํŽ˜์ด์ง€, ์—ฐ๊ฒฐ ์ˆ˜, ํ‰๊ท  ์—ฐ๊ฒฐ ์ˆ˜
  • ๊ฒ€์ƒ‰ ๊ธฐ๋Šฅ: ํŽ˜์ด์ง€ ๊ฒฝ๋กœ ์‹ค์‹œ๊ฐ„ ๊ฒ€์ƒ‰
  • ํด๋ฆญ ๋„ค๋น„๊ฒŒ์ด์…˜: ์—ฐ๊ฒฐ๋œ ํŽ˜์ด์ง€ ๊ฐ„ ์‰ฌ์šด ์ด๋™

๐Ÿ“Š ์ถœ๋ ฅ ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ

route-graph.json์˜ ๊ตฌ์กฐ:

{
  "nodes": [
    {
      "id": "/",
      "path": "/",
      "type": "page",
      "filePath": "pages/index.tsx",
      "fileSize": 2203,
      "metadata": { "depth": 0, "segments": [""] }
    }
  ],
  "edges": [
    {
      "source": "/",
      "target": "/about",
      "method": "link",
      "lineNumber": 25,
      "codeSnippet": "<Link href='/about'>",
      "fileName": "pages/index.tsx"
    }
  ],
  "summary": {
    "totalPages": 9,
    "totalConnections": 139,
    "avgConnections": 15.4
  }
}

๐Ÿ” ์—ฐ๊ฒฐ ๋ถ„์„ ํƒ€์ž…

  • link: Next.js Link ์ปดํฌ๋„ŒํŠธ
  • router: router.push(), router.replace() ๋“ฑ
  • component: ์ปดํฌ๋„ŒํŠธ๋ฅผ ํ†ตํ•œ ๊ฐ„์ ‘ ๋„ค๋น„๊ฒŒ์ด์…˜

๐Ÿ› ๏ธ ๊ฐœ๋ฐœ ๋ฐ ๋””๋ฒ„๊น…

๋กœ์ปฌ ๊ฐœ๋ฐœ

git clone https://github.com/your-username/next-route-map.git
cd next-route-map
npm install
npm run build

# ์˜ˆ์ œ ํ”„๋กœ์ ํŠธ ํ…Œ์ŠคํŠธ
npm run test:example

# HTML ๋ฆฌํฌํŠธ ํ…Œ์ŠคํŠธ
npm run test:report

๐Ÿค ๊ธฐ์—ฌํ•˜๊ธฐ

๋ฒ„๊ทธ ๋ฆฌํฌํŠธ์™€ ๊ธฐ๋Šฅ ์ œ์•ˆ์€ GitHub Issues์—์„œ ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ“„ ๋ผ์ด์„ ์Šค

MIT License


โญ ํ”„๋กœ์ ํŠธ๊ฐ€ ์œ ์šฉํ•˜๋‹ค๋ฉด GitHub์—์„œ ๋ณ„ํ‘œ๋ฅผ ๋ˆŒ๋Ÿฌ์ฃผ์„ธ์š”!

๐ŸŽฏ ๊ณ ๊ธ‰ ๋ถ„์„ ๊ธฐ๋Šฅ (v1.1.0)

๋™์  ํ•จ์ˆ˜ ๋ถ„์„

์ด์ œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ณต์žกํ•œ ๋„ค๋น„๊ฒŒ์ด์…˜ ํŒจํ„ด๋„ ์ •ํ™•ํžˆ ๋ถ„์„ํ•ฉ๋‹ˆ๋‹ค:

// 1. ์กฐ๊ฑด๋ถ€ ๋™์  ํ•จ์ˆ˜ (โœ… ๋ชจ๋“  ๊ฐ€๋Šฅํ•œ ๊ฒฝ๋กœ ๊ฐ์ง€)
const getRoute = () => {
  if (condition) {
    return V2_Routes.ADMIN_PANEL(); // โ†’ /v2/admin/panel
  } else {
    return Routes.PROFILE(); // โ†’ /profile
  }
};

const handleClick = () => {
  Router.push(getRoute()); // ๋‘ ๊ฒฝ๋กœ ๋ชจ๋‘ ์‹œ๊ฐํ™”๋จ!
};

// 2. ํ™”์‚ดํ‘œ ํ•จ์ˆ˜ Routes ์ƒ์ˆ˜ (โœ… ์ง€์›)
export const V2_Routes = {
  ADMIN_PANEL: () => "/v2/admin/panel",
  USER_PROFILE: (id) => `/v2/user/${id}`,
};

// 3. getServerSideProps ๋ฆฌ๋””๋ ‰์…˜ (โœ… ์ง€์›)
export async function getServerSideProps() {
  if (!authenticated) {
    return { redirect: { destination: "/login" } };
  }
}

// 4. ๋Œ€์†Œ๋ฌธ์ž ๊ตฌ๋ถ„ (โœ… ๋ชจ๋‘ ๊ฐ์ง€)
Router.push(Routes.HOME()); // ๋Œ€๋ฌธ์ž Router
router.push(Routes.PROFILE()); // ์†Œ๋ฌธ์ž router

์ง€์›ํ•˜๋Š” ๋„ค๋น„๊ฒŒ์ด์…˜ ํŒจํ„ด

  • โœ… ์ •์  ๊ฒฝ๋กœ: "/dashboard", '/profile'
  • โœ… Routes ์ƒ์ˆ˜: Routes.HOME, ROUTES.DASHBOARD
  • โœ… ํ•จ์ˆ˜ํ˜• Routes: Routes.PROFILE(), V2_Routes.ADMIN()
  • โœ… ๋™์  ํ•จ์ˆ˜ ํ˜ธ์ถœ: Router.push(getRoute())
  • โœ… ์กฐ๊ฑด๋ถ€ ๋ฆฌํ„ด: if/else ๋ธ”๋ก ๋‚ด ๋„ค๋น„๊ฒŒ์ด์…˜
  • โœ… ํ…œํ”Œ๋ฆฟ ๋ฆฌํ„ฐ๋Ÿด: `/dashboard?tab=${tab}`
  • โœ… getServerSideProps ๋ฆฌ๋””๋ ‰์…˜
  • โœ… useEffect ๋‚ด ๋„ค๋น„๊ฒŒ์ด์…˜
  • โœ… ํ›… ๊ธฐ๋ฐ˜ ๋„ค๋น„๊ฒŒ์ด์…˜