@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
Maintainers
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 ๋ด ๋ค๋น๊ฒ์ด์
- โ ํ ๊ธฐ๋ฐ ๋ค๋น๊ฒ์ด์
