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

create-product-page-cli

v1.0.1

Published

CLI tool to create product page and API route in Next.js projects

Readme

Create Product Page CLI for Next.js

A CLI tool that automatically generates a product creation page and API route for your Next.js application.

Features

  • ✅ Creates a styled product form page with name, description, and price fields
  • ✅ Creates an API route with validation for handling product creation
  • ✅ Checks for existing files before overwriting
  • ✅ TypeScript support
  • ✅ Works with Next.js App Router

Installation

Global Installation

npm install -g create-product-page-cli

Local Installation

npm install create-product-page-cli --save-dev

Usage

Run the CLI tool in your Next.js project directory:

npx create-product-page-cli

The CLI will:

  1. Check if you're in a Next.js project
  2. Look for existing files and ask if you want to overwrite them
  3. Generate the necessary files:
    • src/app/products/page.tsx - Product creation form page
    • src/app/api/products/route.ts - API route for handling POST requests

After running the CLI, you can access your product creation page at:

http://localhost:3000/products

Generated Files

Product Page (page.tsx)

A React component with a form for creating products, including:

  • Input fields for name, description, and price
  • Form validation
  • Styled with simple CSS classes
  • Responsive design
  • Form submission handling

API Route (route.ts)

A Next.js API route that handles POST requests for product creation, including:

  • Request validation
  • TypeScript interfaces
  • Error handling
  • Response formatting

Documentation

For more detailed information, check out these documentation files:

Development

If you want to contribute to this project:

  1. Clone the repository
  2. Install dependencies: npm install
  3. Build the project: npm run build
  4. Link for local development: npm link
  5. Run tests: npm test

Project Structure

my-cli-tool/
├── bin/
│   └── cli.js              # Main CLI tool file that handles execution
├── src/
│   ├── createProductPage.ts # Wrapper for product page generator
│   ├── createApiRoute.ts    # Wrapper for API route generator
│   ├── index.ts             # Main export file
│   ├── utils.ts             # Utility functions
│   └── generators/          # Generator classes (following SOLID principles)
│       ├── baseGenerator.ts        # Abstract base generator
│       ├── productPageGenerator.ts # Concrete product page generator
│       └── apiRouteGenerator.ts    # Concrete API route generator
├── tests/                   # Tests
├── dist/                    # Compiled TypeScript
├── package.json             # NPM package configuration
└── tsconfig.json            # TypeScript configuration

SOLID Principles Implementation

This project follows SOLID principles:

  • Single Responsibility: Each class has a single responsibility
  • Open/Closed: BaseGenerator can be extended without modification
  • Liskov Substitution: Concrete generators can be used interchangeably
  • Interface Segregation: Clean interfaces with only necessary methods
  • Dependency Inversion: High-level modules depend on abstractions

License

MIT