Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/janszewczyk/nextjs-szumplate

This is Next.js Szumplate, an open source template for enterprise projects! It is packed with features that will help you create an efficient, maintainable and enjoyable application.
https://github.com/janszewczyk/nextjs-szumplate

eslint next nextjs nextjs-template playwright prettier react semantic-release starter-kit starter-template tailwindcss typescript vercel vitest

Last synced: 26 days ago
JSON representation

This is Next.js Szumplate, an open source template for enterprise projects! It is packed with features that will help you create an efficient, maintainable and enjoyable application.

Awesome Lists containing this project

README

        

# Next.js Szumplate

#### Hello there !!!

This is Next.js Szumplate, an open source template for enterprise projects! It is packed with features that will help you create an efficient, maintainable and enjoyable application. This template will save you a lot of time, so sit back, relax and get ready to conquer the whole world with your new awesome app! ๐Ÿš€

## ๐Ÿ“š Features

This template has all the incredible you need:

- ๐ŸŽ๏ธ **[Next.js](https://nextjs.org/)** - Fast by default, with config optimized for performance
- ๐Ÿ’… **[Tailwind CSS](https://tailwindcss.com/)** - A utility-first CSS framework
- ๐Ÿ’ป **[T3 Env](https://env.t3.gg/)** - Manage your environment variables with ease
- โœจ **[ESlint](https://eslint.org/)** and **[Prettier](https://prettier.io/)** - For clean, consistent, and error-free code
- ๐Ÿ› ๏ธ **[Extremely strict TypeScript](https://www.typescriptlang.org/)** - With [`ts-reset`](https://github.com/total-typescript/ts-reset) library for ultimate type safety
- ๐Ÿ“Š **[Bundle analyzer plugin](https://www.npmjs.com/package/@next/bundle-analyzer)** - Keep an eye on your bundle size
- ๐Ÿงช **[Vitest](https://vitest.dev/)** and **[React Testing Library](https://testing-library.com/react)** - For rock-solid and highly speed unit and integration tests
- ๐ŸŽญ **[Playwright](https://playwright.dev/)** - Write end-to-end tests like a pro
- ๐ŸŽฏ **[Absolute imports](https://nextjs.org/docs/advanced-features/module-path-aliases)** - No more spaghetti imports
- โš•๏ธ **[Health checks](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/)** - Kubernetes-compatible for robust deployments
- ๐Ÿค– **[Dependabot](https://github.com/dependabot)** - Auto-checking dependencies, Dependabot will do it for you
- ๐Ÿšข **[Semantic Release](https://github.com/semantic-release/semantic-release)** - Fully configured tool for changelog, versioning and releasing app ๐Ÿ˜ฎ
- ๐Ÿš€ **[GitHub Actions](https://github.com/features/actions)** - Pre-configured actions for smooth workflows, including code review, PRs checks (test, e2e, Prettier, ESlint, and more...) and app releasing
- ๐Ÿค–๐Ÿง  **[Automated ChatGPT Code Reviews](https://openai.com/chatgpt)** - **Stay on the cutting edge with AI-powered code reviews!**
- ๐Ÿ’ฏ **Perfect Lighthouse score** - Because performance matters

## Table of Contents

- [Next.js Szumplate](#nextjs-szumplate)
- [๐Ÿ“š Features](#-features)
- [๐Ÿ“– Table of Contents](#table-of-contents)
- [๐ŸŽฏ Getting Started](#-getting-started)
- [๐Ÿš€ Deployment](#-deployment)
- [๐Ÿ“ƒ Scripts Overview](#-scripts-overview)
- [๐Ÿงช Testing](#-testing)
- [Running Tests](#running-tests)
- [๐ŸŽจ Styling and Design System](#-styling-and-design-system)
- [๐Ÿค– ChatGPT Code Review](#-chatgpt-code-review)
- [๐Ÿ’ป Environment Variables handling](#-environment-variables-handling)
- [๐Ÿš€ Github Actions](#-github-actions)
- [๐Ÿ”’ Keeping Server-only Code out of the Client Environment](#-keeping-server-only-code-out-of-the-client-environment)
- [๐Ÿ“œ License](#-license)

## ๐ŸŽฏ Getting Started

To get started with this boilerplate, follow these steps:

#### 1. Fork & clone repository:

```bash
## Don't forget to โญ star and fork it first :)
git clone https://github.com/

## ๐ŸŽจ Styling and Design System

This boilerplate uses Tailwind CSS for styling and [Szum-Tech Design System](https://www.npmjs.com/package/@szum-tech/design-system), which contains fully designed components, color palette, utils and more... ([Check DOCS](https://szum-tech-design-system.vercel.app/?path=/docs/introduction--docs))

## ๐Ÿค– ChatGPT Code Review

We've integrated the innovative [ChatGPT Code Review](https://github.com/anc95/ChatGPT-CodeReview) for AI-powered, automated code reviews. This feature provides real-time feedback on your code, helping improve code quality and catch potential issues.

To use ChatGPT Code Review, add an `OPENAI_API_KEY` environment variable with an appropriate key from the OpenAI platform. For setup details, refer to the [Using GitHub Actions](https://github.com/anc95/ChatGPT-CodeReview#using-github-actions) section in the documentation.

![image](https://user-images.githubusercontent.com/28964599/233685071-e1371edf-6359-41c3-a989-335d6ee09cb7.png)

## ๐Ÿ’ป Environment Variables handling

[T3 Env](https://env.t3.gg/) is a library that provides environmental variables checking at build time, type validation and transforming. It ensures that your application is using the correct environment variables and their values are of the expected type. Youโ€™ll never again struggle with runtime errors caused by incorrect environment variable usage.

Config file is located at [`env.js`](./env.js). Simply set your client and server variables and import `env` from any file in your project.

```ts
const env = createEnv({
server: {
// Server variables
SECRET_KEY: z.string()
},
client: {
// Client variables
API_URL: z.string().url()
},
runtimeEnv: {
// Assign runtime variables
SECRET_KEY: process.env.SECRET_KEY,
API_URL: process.env.NEXT_PUBLIC_API_URL
}
});
```

---

If the required environment variables are not set, you'll get an error message:

```shell
โŒ Invalid environment variables: { SECRET_KEY: [ 'Required' ] }
```

## ๐Ÿš€ Github Actions

Github Actions offer multiple smooth workflows that make development easier and reduce the developer's impact on repetitive and boring tasks.

### Code Review ๐Ÿค–Flow

For more details, check paragraph [๐Ÿค– ChatGPT Code Review](#-chatgpt-code-review).

> Code of this workflow, you can find in [`code-review.yml`](./.github/workflows/code-review.yml) file.

### PR Checks โœ… Flow

This action is used only during pull request life, it validates the added code in terms of its correctness, preventing the merge of incorrect code.

**Checks the code for:**

- Build ๐Ÿ—
- Prettier ๐Ÿงน
- Eslint โฌฃ
- TypeScript ๐Ÿ› ๏ธ
- Test ๐Ÿงช
- Playwright ๐ŸŽญ (e2e tests)

image

> Code of this workflow, you can find in [`pr-check.yml`](./.github/workflows/pr-check.yml) file.

### Publish ๐Ÿ“ฆ๐Ÿš€

The action is triggered when a changes are added to the main branch `main`. It uses the [Semantic Release](https://github.com/semantic-release/semantic-release) library. Based on the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/), it determines the next version of the application, boosts it in the [`package.json`](./package.json) file, adds information to the `CHANGELOG.md` file and creates a new [release on Github](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository).

The configuration used in Szumplate comes from the package [`@szum-tech/semantic-release-preset`](https://www.npmjs.com/package/@szum-tech/semantic-release-preset), which contains the shareable configurations used by the Semantic Release.

[Let's see configuration](https://github.com/JanSzewczyk/semantic-release-preset/blob/main/without-npm.js) used in this Repository.

> Code of this workflow, you can find in [`publish.yml`](./.github/workflows/publish.yml) file.

## ๐Ÿ”’ Keeping Server-only Code out of the Client Environment

Since JavaScript modules can be shared between both Server and Client Components modules, it's possible for code that was only ever intended to be run on the server to sneak its way into the client.
To prevent this sort of unintended client usage of server code, we can use the [`server-only`](https://www.npmjs.com/package/server-only) package to give other developers a build-time error if they ever accidentally import one of these modules into a Client Component.

Then import the package into any module that contains `server-only` code:

```tsx
import "server-only";

// The rest of server only code
```

The corresponding package `client-only` can be used to mark modules that contain client-only code โ€“ for example, code that accesses the `window` object.

## ๐Ÿ“œ License

This project is licensed under the MIT License. For more information, see the [LICENSE](./LICENSE) file.