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

react-basic-component-generator

v0.0.2

Published

a set of commands to generate a basic structure for react components

Downloads

11

Readme

React Component Generator

A powerful CLI tool to generate React components with support for both CSS Modules and Styled Components. This generator helps streamline your React development workflow by creating consistent, well-structured component files.

Features

  • 🚀 Generate React components with a single command
  • 🎨 Support for both CSS Modules and Styled Components
  • 📁 Creates organized folder structure
  • 📝 TypeScript-ready templates
  • 🔧 Customizable template system
  • 🛠️ Includes utility functions file
  • ✅ Consistent code style across components

Installation

Global Installation (Recommended)

npm install -g react-component-generator

Local Installation

npm install --save-dev react-component-generator

Usage

Basic Usage

# Generate component with CSS Modules (default)
generate-component ComponentName

# Generate component with Styled Components
generate-component ComponentName styled

Using with npx

# Without installing
npx react-component-generator ComponentName

# With Styled Components
npx react-component-generator ComponentName styled

Local Installation Usage

If installed locally, add a script to your package.json:

{
  "scripts": {
    "generate": "generate-component"
  }
}

Then run:

npm run generate ComponentName

Generated Structure

With CSS Modules (Default)

components/
└── ComponentName/
    ├── index.tsx
    ├── styles.module.css
    └── functions.ts

With Styled Components

components/
└── ComponentName/
    ├── index.tsx
    ├── styles.tsx
    └── functions.ts

Templates

CSS Modules Template

index.tsx

import styles from "./styles.module.css";
import { HelloWorld } from "./functions";

export const ComponentName = () => {
  return (
    <div className={styles.container}>
      <HelloWorld />
    </div>
  );
};

styles.module.css

.container {
  display: flex;
  justify-items: center;
  align-items: center;
}

functions.ts

export const HelloWorld: string = () => {
  return "Hello World";
};

Styled Components Template

index.tsx

import React from "react";
import { ComponentName } from "./styles";

export function ComponentName() {
  return <ComponentName></ComponentName>;
}

styles.tsx

import styled from "styled-components";

export const ComponentName = styled.div`
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
`;

Customization

You can customize the templates by modifying the files in the templates directory:

  1. Clone the repository
  2. Modify the template files in the templates folder
  3. Install your customized version globally

API Reference

Command Line Options

generate-component <ComponentName> [styled]

Arguments:
  ComponentName   Name of the component to generate (PascalCase recommended)
  styled          Optional flag to use Styled Components instead of CSS Modules

Contributing

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

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Development

To set up the development environment:

  1. Clone the repository
git clone https://github.com/stsmuniz/react-component-generator.git
cd react-component-generator
  1. Install dependencies
npm install
  1. Link for local development
npm link

Testing

To test the generator:

# Test CSS Modules generation
node generate-component.js TestComponent

# Test Styled Components generation
node generate-component.js TestComponent styled

# Test error handling
node generate-component.js

License

This project is licensed under the GPLv3 License - see the LICENSE file for details.

Author

Salustiano Muniz

Support

If you encounter any issues or have questions, please file an issue on the GitHub issue tracker.

Changelog

v1.0.0

  • Initial release
  • Support for CSS Modules and Styled Components
  • Basic template structure
  • Command-line interface

Roadmap

  • [ ] Add TypeScript types generation
  • [ ] Support for different testing frameworks (Jest, Testing Library)
  • [ ] Option to generate storybook stories
  • [ ] Custom template path configuration
  • [ ] Interactive mode with prompts

Acknowledgments

  • Inspired by the need for consistent component structure in React projects
  • Thanks to the React community for best practices and patterns