πŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more β†’
Socket
Book a DemoInstallSign in
Socket

next-list

Package Overview
Dependencies
Maintainers
0
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-list

A package to render tables in CLI

1.0.10
Source
npm
Version published
Weekly downloads
88
95.56%
Maintainers
0
Weekly downloads
Β 
Created
Source

next-list for Next.js πŸ—ΊοΈ

A command-line utility to explore and visualize all routes in your Next.js application, including both pages and API routes. This tool aims to simplify debugging when working in the Next.js app directory and to provide clear insights into which routes are being rendered, both for pages and API routes. Inspired by the php artisan route:list command.

Features ✨

  • πŸ“‹ Lists all page routes and API routes in your Next.js app
  • 🎨 Color-coded HTTP methods for better visualization
  • πŸ“ Shows the exported function names for each route
  • πŸ” Supports dynamic routes ([param]) and optional segments ((param))
  • πŸ“Š Beautiful CLI table output with full URLs

Screenshots πŸ“Έ

next-list CLI output

Installation πŸ“¦

npm install next-list

Usage πŸš€

To use next-list, you can run the provided npm script from your project root with optional arguments to specify what routes to list:

npm run list [pages|api]

This command is configured in your package.json under the scripts section. Here's how you should set it up:

"scripts": {
  "list": "next-list"
}

If no argument is provided, next-list will list both page and API routes. You can specify pages to list only page routes or api to list only API routes.

Output Example πŸ“„

The utility will generate tables based on the specified argument:

  • Page Routes (if pages is specified or no argument is provided):
| Method | Function Name | Route | Full URL |
|--------|--------------|-------|-----------|
| GET | HomePage | / | https://localhost:3000/ |
| GET | AboutPage | /about | https://localhost:3000/about |
| GET | UserProfile | /users/[id] | https://localhost:3000/users/[id] |
  • API Routes (if api is specified or no argument is provided):
| Method | Function Name | Route | Full URL |
|--------|--------------|-------|-----------|
| GET | handler | /api/users/route | https://localhost:3000/api/users |
| POST | createUser | /api/users/route | https://localhost:3000/api/users |
| DELETE | deleteUser | /api/users/[id]/route | https://localhost:3000/api/users/[id] |

Color Coding 🎨

  • 🟒 GET - Green
  • 🟑 POST - Yellow
  • πŸ”΄ DELETE - Red
  • πŸ”΅ PUT - Blue
  • βšͺ HEAD - Gray
  • Dynamic parameters [param] - Yellow
  • Optional segments (param) - Blue

Requirements πŸ“‹

  • Node.js >= 14.x
  • Next.js project using the App Router

Contributing 🀝

Contributions are welcome! Please feel free to submit a Pull Request.

License πŸ“„

MIT Β© Pablo Lizardo https://www.pablolizardo.dev | https://www.casaa.com.ar

Made with ❀️ for the Next.js community

Keywords

cli

FAQs

Package last updated on 03 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts