# @pbots/nrc

> A simple CLI for creating functional react components

Latest version **2.3.2** (published 2023-03-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @pbots/nrc
pnpm add @pbots/nrc
yarn add @pbots/nrc
bun add @pbots/nrc
```

Provides the command `nrc`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.2 |
| Published | 2023-03-01 |
| First published | 2022-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Parker Botsford |
| Maintainers | pbots |
| Keywords | cli, react, component, boilerplate |

## Links

- npm: https://www.npmjs.com/package/@pbots/nrc
- Repository: https://github.com/parkerbotsford/nrc
- Homepage: https://github.com/parkerbotsford/nrc#readme
- Issues: https://github.com/parkerbotsford/nrc/issues
- npm.io page: https://npm.io/package/@pbots/nrc

## Dependencies (2)

- [chalk](https://npm.io/package/chalk.md) ^5.2.0
- [commander](https://npm.io/package/commander.md) ^10.0.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.3.2 (latest) — 2023-03-01
- 2.3.1 — 2023-03-01
- 2.2.0 — 2022-08-11
- 2.1.0 — 2022-03-01
- 2.0.0 — 2022-02-28
- 1.2.1 — 2022-02-16
- 1.2.0 — 2022-02-11
- 1.1.1 — 2022-02-11
- 1.1.0 — 2022-02-10
- 1.0.3 — 2022-02-06
- 1.0.2 — 2022-02-06
- 1.0.1 — 2022-02-06
- 1.0.0 — 2022-02-05

## README

# `nrc`

Simple CLI to create a functional react component

<br>

## Quickstart

```bash
npm i -g @pbots/nrc
```

<br>

## Usage

```bash
nrc <component-name>
```

nrc looks for the `src/components` and `components` directories by default

<br>

#### Output:

```tree
./src/components/<component-name>
├──index.js
└──<component-name>.js
```

<br>

## Importing

The `index.js` file allows the component to be imported by its directory name.

### Example

1.  Create the component:

    ```bash
    nrc Button
    ```

2.  Import the component into another component:

    ```js
    // OtherComponent.js

    import Button from '../Button';
    ```

    Or if using **absolute imports**:

    ```js
    // OtherComponent.js

    import Button from 'components/Button';
    ```

<br>

## To specify a different directory, use `-d` or `--dir`

```bash
nrc <component-name> -d /path/to/dir
nrc <component-name> -dir /path/to/dir
```

#### Output:

```tree
./path/to/dir/<component-name>
├──index.js
└──<component-name>.js
```

<br>

## Using Typescript

```bash
nrc <component-name> -t
nrc <component-name> --typescript
```

Creates `.tsx` files instead of `.js`.

<br>

#### Output:

```tree
./src/components/<component-name>
├──index.tsx
└──<component-name>.tsx
```

<br>

## Using CSS modules

```bash
nrc <component-name> -m
nrc <component-name> --module
```

Creates a `<component-name>.module.css` file and imports it into `<component-name>.js`.

<br>

#### Output:

```tree
./src/components/<component-name>
├──index.js
├──<component-name>.js
└──<component-name>.module.css
```

<br>

## Example Usage

```bash
nrc Button -m -t
```

#### Output

```tsx
// Button.tsx

import styles from './Button.module.css';
import React from 'react';

const Button = () => {
    return (
        <div>
            <h1>Button</h1>
        </div>
    );
};

export default Button;
```

```tsx
// index.tsx
export { default } from './Button.tsx';
```

```css
/* Button.module.css */
/* This file is left blank so you can add your own styles */
```

Inspired by [joshwcomeau/new-component](https://github.com/joshwcomeau/new-component).

---
_Source: https://npm.io/package/@pbots/nrc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
