A command-line interface (CLI) tool to quickly generate React components with optional TypeScript support and CSS styles.
Install globally:
npm install -g create-new-react-componentOr install as dev dependency:
npm install create-new-react-component --save-devcreate-new-react-componentThe tool will guide you through an interactive process to create your component with the following options:
- Component Name (must be in PascalCase)
- Component Type (Functional, Arrow Function, Class, Memoized, or ForwardRef)
- Language (JavaScript or TypeScript)
- Styling Solution (CSS, SCSS, or None)
- Props Support (Yes/No)
- React Import Statement (Yes/No)
The tool now supports multiple component type templates:
function MyComponent(props) {
return (
<>
{/* Add your component content here */}
</>
);
}const MyComponent = (props) => {
return (
<>
{/* Add your component content here */}
</>
);
}class MyComponent extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
return (
<>
{/* Add your component content here */}
</>
);
}
}import { memo } from 'react';
const MyComponent = memo((props) => {
return (
<>
{/* Add your component content here */}
</>
);
});import { forwardRef } from 'react';
const MyComponent = forwardRef((props, ref) => {
return (
<div ref={ref}>
{/* Add your component content here */}
</div>
);
});For more information, run the following command:
create-new-react-component --helpor
create-new-react-component -hto see the help message.
# Start the interactive component creation process
create-new-react-component- A simple, customizable utility for adding new React components to your project.
- Delightful React File/Directory Structure
Here are the planned features and improvements:
- Extended Component Template Options
- Enhanced Styling Support
- Storybook Integration
- Automated Test File Generation
- CLI Interaction Improvements
- Basic Component Generation
- CSS Module Support
- Component Type Templates (Functional, Arrow, Class, Memoized, ForwardRef)
- Automated NPM Publishing via GitHub Actions
For detailed development plans, please check our GitHub Projects page.