An open API service indexing awesome lists of open source software.

https://github.com/hossein-i/nextjs-rtk-starter

A modern and scalable starter template for Next.js, following best practices with clean architecture based on Feature-Sliced Design (FSD). This setup is ready to go with TypeScript, Redux Toolkit (RTK), RTK Query, ESLint, Prettier, Commitlint, and Husky.
https://github.com/hossein-i/nextjs-rtk-starter

commitizen commitlint eslint feature-sliced-design husky lint-staged nextjs nextjs-template prettier redux-toolkit rtk-query tailwindcss template typescript

Last synced: 3 months ago
JSON representation

A modern and scalable starter template for Next.js, following best practices with clean architecture based on Feature-Sliced Design (FSD). This setup is ready to go with TypeScript, Redux Toolkit (RTK), RTK Query, ESLint, Prettier, Commitlint, and Husky.

Awesome Lists containing this project

README

          

# Next.js RTK Starter

A modern and scalable starter template for **Next.js**, following best practices with clean architecture based on **Feature-Sliced Design (FSD)**. This setup is ready to go with **TypeScript**, **Redux Toolkit (RTK)**, **RTK Query**, **ESLint**, **Prettier**, **Commitlint**, and **Husky**.

## ๐Ÿš€ Features

- **Next.js** โ€“ The production-ready React framework.
- **TypeScript** โ€“ Static typing for JavaScript.
- **Redux Toolkit (RTK)** โ€“ Efficient and scalable state management.
- **RTK Query** โ€“ Built-in data fetching and caching.
- **Feature-Sliced Design (FSD)** โ€“ Modular architecture for large applications.
- **Prettier** โ€“ Code formatter for consistent style.
- **ESLint** โ€“ Code linter to ensure code quality.
- **Commitlint** โ€“ Enforce conventional commit messages.
- **Husky** โ€“ Git hooks for pre-commit and commit-msg checks.

## ๐Ÿ“ฆ Getting Started

### Prerequisites

- Node.js (v18 or higher)
- npm or yarn

### Installation

1. Clone the repository:

```bash
git clone https://github.com/Hossein-i/nextjs-rtk-starter.git
```

2. Navigate to the project directory:

```bash
cd nextjs-rtk-starter
```

3. Install dependencies:

```bash
npm install
# or
yarn install
```

### Running the Development Server

Start the dev server:

```bash
npm run dev
# or
yarn dev
```

Then open [http://localhost:3000](http://localhost:3000) in your browser.

## ๐Ÿงฑ Project Structure (FSD)

This project uses the **Feature-Sliced Design** architecture to enhance scalability and maintainability:

```bash
src/
โ”œโ”€โ”€ app/ # Next.js app router (layouts, pages)
โ”œโ”€โ”€ entities/ # Business entities like user, product
โ”‚ โ”œโ”€โ”€ api/ # Entity-related API logic
โ”‚ โ”œโ”€โ”€ model/ # Types, stores, services
โ”‚ โ””โ”€โ”€ ui/ # Entity-specific UI components
โ”œโ”€โ”€ features/ # Independent, reusable features
โ”‚ โ”œโ”€โ”€ api/ # Feature-specific API calls
โ”‚ โ”œโ”€โ”€ config/ # Feature-level configuration
โ”‚ โ”œโ”€โ”€ lib/ # Internal libraries for the feature
โ”‚ โ”œโ”€โ”€ model/ # Logic, stores, types
โ”‚ โ””โ”€โ”€ ui/ # UI for feature interactions
โ”œโ”€โ”€ shared/ # Cross-cutting code (global utils, UI, config)
โ”‚ โ”œโ”€โ”€ api/ # API client setup and base query
โ”‚ โ”œโ”€โ”€ config/ # App-wide config and env vars
โ”‚ โ”œโ”€โ”€ i18n/ # Internationalization setup
โ”‚ โ”œโ”€โ”€ lib/ # Utilities and helper functions
โ”‚ โ”œโ”€โ”€ styles/ # Global styles and themes
โ”‚ โ””โ”€โ”€ ui/ # Design system components
โ”œโ”€โ”€ views/ # Top-level views composed of widgets/features
โ””โ”€โ”€ widgets/ # UI blocks that encapsulate full use cases
```

## โš™๏ธ State Management & Data Fetching

This template comes with:

- **Redux Toolkit** for managing global app state.
- **RTK Query** for fetching, caching, and managing server state with minimal boilerplate.

> Store setup and slices can be found in `shared/api` and `features/model`.

## ๐Ÿงน Code Quality Tools

### Prettier

Ensures consistent code formatting:

```bash
npm run format
# or
yarn format
```

### ESLint

Checks code for style and quality issues:

```bash
npm run lint
# or
yarn lint
```

### Commitlint

Enforces [Conventional Commits](https://www.conventionalcommits.org/) for all commit messages:

```bash
npm run commit
# or
yarn commit
```

## ๐Ÿ”’ Git Hooks (Husky)

Husky ensures quality checks before code is committed:

- **Pre-commit**: Runs ESLint and Prettier
- **Commit-msg**: Validates commit message format

## ๐Ÿค Contributing

We welcome contributions! To get started:

1. Fork the repo.
2. Create a new branch: `git checkout -b feature/YourFeatureName`.
3. Commit your changes: `git commit -m 'feat: Add awesome feature'`.
4. Push the branch: `git push origin feature/YourFeatureName`.
5. Open a Pull Request.

## ๐Ÿ“„ License

This project is licensed under the MIT License โ€“ see the [LICENSE](LICENSE) file for details.

## ๐Ÿ™Œ Acknowledgments

- [Next.js Docs](https://nextjs.org/docs)
- [Feature-Sliced Design](https://feature-sliced.design/)
- [Redux Toolkit](https://redux-toolkit.js.org/)
- [RTK Query](https://redux-toolkit.js.org/rtk-query/overview)
- [Conventional Commits](https://www.conventionalcommits.org/)